Re: [PATCH] Make printk lock when appropriate...

From: Jeff Garzik (jgarzik@mandrakesoft.mandrakesoft.com)
Date: Sun Jul 02 2000 - 09:57:12 EST


On Sun, 2 Jul 2000, James Simmons wrote:

>
> > > "buf" is a static variable, defined in line 28 [printk.c]
> >
> > Since vsprintf can definitely be slow, maybe buf could be made per-cpu.
> > Tradeoff wasting 1K x max_cpus in uninitialized data space versus
> > locking before vsprintf.
>
> How will this help? Can you explain what you are thinking here.

Assuming reentrancy is not a problem, you can eliminate a spinlock
by going from

        spin_lock(&shared_resource_lock);
        vsprintf(buf, ...);
        spin_unlock(&shared_resource_lock);

to

        vsprintf(buf[smp_processor_id()], ...);

The point is you waste space by creating an array of size NR_CPUS
(max numbers of CPUs possible in your kernel) and allow operations
to occur in parallel. You don't need to spinlock against other CPUs
because each CPU has its own data.

How does this help the printk case? It allows each vsprintf() call
(required by each printk call) to occur in parallel, and not while
console_lock is held.

        Jeff

        Jeff

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:11 EST