Re: [RFC PATCH] Add CRC checksum for RCU lists

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Steven Rostedt <rostedt@...>
Cc: LKML <linux-kernel@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, Peter Zijlstra <a.p.zijlstra@...>, Andrew Morton <akpm@...>
Date: Friday, September 21, 2007 - 1:12 pm

On Thu, Sep 20, 2007 at 02:34:11PM -0400, Steven Rostedt wrote:

Very cool!!!


Good point, having the caller could give a good clue as to which piece
of code was mishandling callbacks.


Good approach!


We can only be thankful that it is not possible to cancel outstanding
RCU callbacks...


Looks good -- a few suggestions for better fault coverage interspersed
below.  But would be useful as is.  (And it would be good to apply after
the preempt/boost patches, which are currently undergoing integration
with the CPU hotplug patches -- the good news is that this integration
eliminates the need for patch #4!)

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


Looks good, but one question -- why not include the caller in the CRC?
Not a big deal either way, but would catch a few more cases of corruption.
Also, as things stand, the caller pointer can be silently corrupted,
which might causes confusion if someone had to examine the RCU callback
lists from a crash dump.

Interchanging the order of "crc" and "caller" would change the strategy,
if I understand correctly.


Very magic indeed -- Google doesn't find it, other than in your
patch.  ;-)


Why initialize "p" twice?  (Once in the declaration, and once in the
"for" loop, but with different casts.)


Do we want exactly one (give or take concurrent checks), or do we want
the first ten or so?  Sometimes having a modest sample rather than
exactly one is helpful.

And I know that it doesn't matter in this case, but I cannot stop myself
from pointing out the possibility of making "once" be an atomic_t
that is initialized to (say) -10, then making the !once check be an
atomic_add_return().  (Whew!  Good to get that off my chest!!!)

Now back to real problems.  ;-)

(Note to self...)  The way this is coded could possibly result in false
positives.  Suppose that the last element in a given callback list has
its CRC correctly calculated.  Now suppose that a new callback is being
added to the end of the list.  This addition is non-atomic, so the of
the old last element will be momentarily incorrect.  So, need to check
that all list checks are protected by some lock.  (And all the cases
I saw below are in fact OK.)


I suggest also printing head->crc^rcu_crc_calc(head) to make cases
where a single bit is being corrupted more obvious.


If you do decide to move the caller into the CRC calculation, it
will be necessary to reverse the above pair of lines.


Would need to initialize caller here if you add it to the CRC.


And here as well.

But this has the effect of causing the CRC to be born correct.  Do we
really want that?  Suppose someone incorrectly re-initialized a callback
that was still on a list.  Wouldn't it be better to get a CRC warning than
a NULL pointer exception?  So suggest something like RCU_CRC_MAGIC+1 --
perhaps with a RCU_CRC_BAD_MAGIC symbol.


The CRC of the tail element is incorrect at this point, but that is OK
because we have interrupts disabled and no other CPU can access our list
in the meantime.


This check is OK -- no other CPU should be able to manipulate our
rdp, and we have interrupts disabled.  Same situation for call_rcu_bh()
below.


OK, interrupts disabled here.


Why not invalidate the CRC of the element that we just removed?  This
would catch some cases of list mangling.


Momentarily wrong CRC OK, interrupts disabled here.  Ditto for
__rcu_process_callbacks() below.

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH] Add CRC checksum for RCU lists, Steven Rostedt, (Thu Sep 20, 2:34 pm)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Paul E. McKenney, (Fri Sep 21, 1:12 pm)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Steven Rostedt, (Fri Sep 21, 5:32 pm)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Paul E. McKenney, (Sat Sep 22, 1:59 pm)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Kyle Moffett, (Sat Sep 22, 3:04 am)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Paul E. McKenney, (Sat Sep 22, 1:20 pm)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Peter Zijlstra, (Fri Sep 21, 8:02 am)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Jan Engelhardt, (Fri Sep 21, 9:16 am)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Steven Rostedt, (Fri Sep 21, 9:27 am)
Re: [RFC PATCH] Add CRC checksum for RCU lists, Steven Rostedt, (Fri Sep 21, 9:01 am)