lkml.org 
[lkml]   [2008]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH] printk: robustify printk
    On Mon, Aug 11, 2008 at 01:04:00PM +0200, Peter Zijlstra wrote:
    > On Mon, 2008-08-11 at 12:45 +0200, Ingo Molnar wrote:
    > > ( But that's for a separate cleanup patch i think. )
    > >
    > > No strong feelings though. Peter, which one do you prefer?
    >
    > I personally prefer this printk_tick() driven one over the RCU driven
    > one because it doesn't trade deadlocks.

    One way to break the deadlock within the RCU subsystem would be something
    similar to the following untested (known not to compile) patch. The
    idea is that RCU detects that call_rcu() is being called from printk(), and
    simply enqueues the callback in this case. For this to really work, RCU
    needs something exported from printk() to allow it to make this
    decision. I chose the static variable printk_cpu below just to present
    the general idea.

    Thoughts?

    Buggy, but otherwise:

    Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    ---

    rcupreempt.c | 11 ++++++++---
    1 file changed, 8 insertions(+), 3 deletions(-)

    diff -urpNa -X dontdiff linux-2.6.27-rc1/kernel/rcupreempt.c linux-2.6.27-rc1-printk/kernel/rcupreempt.c
    --- linux-2.6.27-rc1/kernel/rcupreempt.c 2008-07-30 08:48:17.000000000 -0700
    +++ linux-2.6.27-rc1-printk/kernel/rcupreempt.c 2008-08-11 09:02:03.000000000 -0700
    @@ -1118,17 +1118,22 @@ void call_rcu(struct rcu_head *head, voi
    {
    unsigned long flags;
    struct rcu_data *rdp;
    + int this_cpu = smp_processor_id();

    head->func = func;
    head->next = NULL;
    local_irq_save(flags);
    rdp = RCU_DATA_ME();
    - spin_lock(&rdp->lock);
    - __rcu_advance_callbacks(rdp);
    + if (this_cpu == printk_cpu) {
    + spin_lock(&rdp->lock);
    + __rcu_advance_callbacks(rdp);
    + }
    *rdp->nexttail = head;
    rdp->nexttail = &head->next;
    RCU_TRACE_RDP(rcupreempt_trace_next_add, rdp);
    - spin_unlock_irqrestore(&rdp->lock, flags);
    + if (this_cpu == printk_cpu) {
    + spin_unlock_irqrestore(&rdp->lock, flags);
    + }
    }
    EXPORT_SYMBOL_GPL(call_rcu);


    \
     
     \ /
      Last update: 2008-08-11 18:13    [W:0.037 / U:1.960 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site