WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [RFC PATCH 27/33] Add the Xen virtual console driver.

To: Chris Wright <chrisw@xxxxxxxxxxxx>
Subject: [Xen-devel] Re: [RFC PATCH 27/33] Add the Xen virtual console driver.
From: Arjan van de Ven <arjan@xxxxxxxxxxxxx>
Date: Tue, 18 Jul 2006 12:24:38 +0200
Cc: Andrew Morton <akpm@xxxxxxxx>, Zachary Amsden <zach@xxxxxxxxxx>, Jeremy Fitzhardinge <jeremy@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, Ian Pratt <ian.pratt@xxxxxxxxxxxxx>, Rusty Russell <rusty@xxxxxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, Andi Kleen <ak@xxxxxxx>, virtualization@xxxxxxxxxxxxxx, Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
Delivery-date: Thu, 20 Jul 2006 05:12:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20060718091956.653901000@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Intel International BV
References: <20060718091807.467468000@xxxxxxxxxxxx> <20060718091956.653901000@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Tue, 2006-07-18 at 00:00 -0700, Chris Wright wrote:
> +                     } else if (sysrq_requested) {
> +                             unsigned long sysrq_timeout =
> +                                     sysrq_requested + HZ*2;
> +                             sysrq_requested = 0;
> +                             if (time_before(jiffies, sysrq_timeout)) {
> +                                     spin_unlock_irqrestore(
> +                                             &xencons_lock, flags);
> +                                     handle_sysrq(
> +                                             buf[i], regs, xencons_tty);
> +                                     spin_lock_irqsave(
> +                                             &xencons_lock, flags);
> +                                     continue;
> +                             }

Lindent can be harmful...

> +static void xencons_wait_until_sent(struct tty_struct *tty, int timeout)
> +{
> +     unsigned long orig_jiffies = jiffies;
> +
> +     if (TTY_INDEX(tty) != 0)
> +             return;
> +
> +     while (DRV(tty->driver)->chars_in_buffer(tty)) {
> +             set_current_state(TASK_INTERRUPTIBLE);
> +             schedule_timeout(1);
> +             if (signal_pending(current))
> +                     break;
> +             if (timeout && time_after(jiffies, orig_jiffies + timeout))
> +                     break;
> +     }
> +
> +     set_current_state(TASK_RUNNING);
> +}

hmm somehow I find this code scary; we had similar code recently
elsewhere where this turned out to be a real issue; you now sleep for
"1" time, so you sleep for a fixed time if you aren't getting wakeups,
but if you are getting wakeups your code is upside down, I would expect
it to look like

+       set_current_state(TASK_INTERRUPTIBLE);
+       while (DRV(tty->driver)->chars_in_buffer(tty))
+               schedule_timeout(1);
+               if (signal_pending(current))
+                       break;
+               if (timeout && time_after(jiffies, orig_jiffies + timeout))
+                       break;
+               set_current_state(TASK_INTERRUPTIBLE);
+       }

instead, so that you don't have the wakeup race..





_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>