Commit:     78ba2faf71c63990cba9997f18cf1d610e06e3f2
Parent:     3678d62f028689abc8ac5693b254e48f605f94ba
Author:     Corey Minyard <[EMAIL PROTECTED]>
AuthorDate: Sat Feb 10 01:45:45 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Sun Feb 11 10:51:31 2007 -0800

    [PATCH] IPMI: Fix some RCU problems
    Fix some RCU problem pointed out by Paul McKenney of IBM.  These are:
    The wholesale move of the command receivers list into a new list was not
    safe because the list will point to the new tail during a traversal, so the
    traversal will never end on a reader if this happens during a read.
    Memory barriers were needed to handle proper ordering of the setting of the
    IPMI interface as valid.  Readers might not see proper ordering of data
    In ipmi_smi_watcher_register(), the use of the _rcu suffix on the list is
    This require the list_splice_init_rcu() patch previously posted.
    Signed-off-by: Corey Minyard <[EMAIL PROTECTED]>
    Cc: Paul E. McKenney <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
 drivers/char/ipmi/ipmi_msghandler.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c 
index 53582b5..230064e 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -406,13 +406,14 @@ static void clean_up_interface_data(ipmi_smi_t intf)
-       /* Wholesale remove all the entries from the list in the
-        * interface and wait for RCU to know that none are in use. */
+       /*
+        * Wholesale remove all the entries from the list in the
+        * interface and wait for RCU to know that none are in use.
+        */
-       list_add_rcu(&list, &intf->cmd_rcvrs);
-       list_del_rcu(&intf->cmd_rcvrs);
+       INIT_LIST_HEAD(&list);
+       list_splice_init_rcu(&intf->cmd_rcvrs, &list, synchronize_rcu);
-       synchronize_rcu();
        list_for_each_entry_safe(rcvr, rcvr2, &list, link)
@@ -451,7 +452,7 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher 
        /* Build a list of things to deliver. */
-       list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
+       list_for_each_entry(intf, &ipmi_interfaces, link) {
                if (intf->intf_num == -1)
                e = kmalloc(sizeof(*e), GFP_KERNEL);
@@ -2760,9 +2761,15 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
                kref_put(&intf->refcount, intf_free);
        } else {
-               /* After this point the interface is legal to use. */
+               /*
+                * Keep memory order straight for RCU readers.  Make
+                * sure everything else is committed to memory before
+                * setting intf_num to mark the interface valid.
+                */
+               smp_wmb();
                intf->intf_num = i;
+               /* After this point the interface is legal to use. */
                call_smi_watchers(i, intf->si_dev);
@@ -3923,6 +3930,14 @@ static void send_panic_events(char *str)
                        /* Interface was not ready yet. */
+               /*
+                * intf_num is used as an marker to tell if the
+                * interface is valid.  Thus we need a read barrier to
+                * make sure data fetched before checking intf_num
+                * won't be used.
+                */
+               smp_rmb();
                /* First job here is to figure out where to send the
                   OEM events.  There's no way in IPMI to send OEM
                   events using an event send command, so we have to
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to