From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: paulus@au1.ibm.com, antonb@au1.ibm.com, benh@kernel.crashing.org
Cc: linux-kernel@vger.kernel.org
Subject: [RFC, PATCH] add rcu_read_lock in ItLpQueue_process()
Date: Sat, 2 Apr 2005 20:42:05 -0800 [thread overview]
Message-ID: <20050403044204.GB1330@us.ibm.com> (raw)
Hello!
I believe that the synchronize_kernel() needs a matching
rcu_read_lock() and rcu_read_unlock() pair as shown below,
along with an rcu_dereference(). Without these, I believe
that the following sequence of events could occur:
o CPU 0 in ItLpQueue_process() tests the lpEventHandler
element, and finds it non-NULL, proceeding into the
"then" clause.
o CPU 1 in HvLpEvent_unregisterHandler() sets the element
to NULL.
o CPU 0 picks up the lpEventHandler once more, and does
a function call through the now-NULL pointer.
That said, there might be some higher-level locking that I missed
that prevents this...
Thanx, Paul
Signed-off-by: <paulmck@us.ibm.com>
diff -urpN -X dontdiff linux-2.6.12-rc1/arch/ppc64/kernel/ItLpQueue.c linux-2.6.12-rc1-ppcfix/arch/ppc64/kernel/ItLpQueue.c
--- linux-2.6.12-rc1/arch/ppc64/kernel/ItLpQueue.c Tue Mar 1 23:37:48 2005
+++ linux-2.6.12-rc1-ppcfix/arch/ppc64/kernel/ItLpQueue.c Sat Apr 2 20:36:16 2005
@@ -107,6 +107,7 @@ unsigned ItLpQueue_process( struct ItLpQ
{
unsigned numIntsProcessed = 0;
struct HvLpEvent * nextLpEvent;
+ LpEventHandler func;
/* If we have recursed, just return */
if ( !set_inUse( lpQueue ) )
@@ -140,9 +141,12 @@ unsigned ItLpQueue_process( struct ItLpQ
*/
if ( nextLpEvent->xType < HvLpEvent_Type_NumTypes )
lpQueue->xLpIntCountByType[nextLpEvent->xType]++;
- if ( nextLpEvent->xType < HvLpEvent_Type_NumTypes &&
- lpEventHandler[nextLpEvent->xType] )
- lpEventHandler[nextLpEvent->xType](nextLpEvent, regs);
+ if ( nextLpEvent->xType < HvLpEvent_Type_NumTypes )
+ rcu_read_lock();
+ func = rcu_dereference(lpEventHandler[nextLpEvent->xType]);
+ if (func)
+ func(nextLpEvent, regs);
+ rcu_read_unlock();
else
printk(KERN_INFO "Unexpected Lp Event type=%d\n", nextLpEvent->xType );
reply other threads:[~2005-04-03 4:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050403044204.GB1330@us.ibm.com \
--to=paulmck@us.ibm.com \
--cc=antonb@au1.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@au1.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox