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] Question about printk implementation.

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] Question about printk implementation.
From: "Roger Cruz" <roger.cruz@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 15 Sep 2010 15:24:28 -0500
Delivery-date: Wed, 15 Sep 2010 13:25:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: ActVE/8KJGMvZCPNRuuU7Ovzr4dMxA==
Thread-topic: Question about printk implementation.

I was looking over the implementation of printk (xenunstable) and I have a question about the spin_lock_recursive use and the static "buf" variable in this routine.  Suppose that that in a single processor system the hypervisor is printing using this printk routine and has acquired the console_lock.  Is it possible for a high level interrupt, like an NMI (just as an example, any other interrupts that preempt the current work in the hypervisor will do), to come in and then use printk.  Because we are in single CPU mode, the spin_lock_recursive will succeed (if I interpreted the code correctly).  When the higher level interrupt exits and returns to the hypervisor code that was previously printing, the contents of the static "buf" would have changed.  Is this a possibility??

Thanks
Roger R. Cruz

void printk(const char *fmt, ...)
{
    static char   buf[1024];  <<<<<---------------
    static int    start_of_line = 1, do_print;

    va_list       args;
    char         *p, *q;
    unsigned long flags;

    /* console_lock can be acquired recursively from __printk_ratelimit(). */
    local_irq_save(flags);  <<<<-----------------
    spin_lock_recursive(&console_lock);

    va_start(args, fmt);
    (void)vsnprintf(buf, sizeof(buf), fmt, args);
    va_end(args);       

    p = buf;

    while ( (q = strchr(p, '\n')) != NULL )
    {
        *q = '\0';
        if ( start_of_line )
            do_print = printk_prefix_check(p, &p);
        if ( do_print )
        {
            if ( start_of_line )
                printk_start_of_line();
            __putstr(p);
            __putstr("\n");
        }
        start_of_line = 1;
        p = q + 1;

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