Prev: Keyboard Jammed error patch 2.4.35-pre4
Next: init: DEBUG_BLOCK_EXT_DEVT requires explicit root= param
From: Josh Triplett on 26 Aug 2008 20:40 On Tue, 2008-08-26 at 09:05 -0700, Paul E. McKenney wrote: > On Mon, Aug 25, 2008 at 03:02:30PM -0700, Josh Triplett wrote: > > On Fri, 2008-08-22 at 18:53 -0700, Paul E. McKenney wrote: > > > On Fri, Aug 22, 2008 at 04:29:32PM -0700, Josh Triplett wrote: > > > > On Thu, 2008-08-21 at 16:43 -0700, Paul E. McKenney wrote: > > > > > @@ -658,14 +806,19 @@ int rcu_needs_cpu(int cpu) > > > > > struct rcu_data *rdp = &per_cpu(rcu_data, cpu); > > > > > struct rcu_data *rdp_bh = &per_cpu(rcu_bh_data, cpu); > > > > > > > > > > - return !!rdp->nxtlist || !!rdp_bh->nxtlist || rcu_pending(cpu); > > > > > + return !!*rdp->nxttail[RCU_DONE_TAIL] || > > > > > + !!*rdp_bh->nxttail[RCU_DONE_TAIL] || > > > > > + rcu_pending(cpu); > > > > > > > > !! seems unnecessary here. > > > > > > Someone once told me why this was necessary, but I forget. It was in the > > > original, and I didn't put it there. Some weirdness about conversion > > > to 32-bit integer when the lower 32 bits of the pointer was zero or > > > some such. So if your pointer value was 0x100000000, for example, > > > so that conversion to int gives zero. > > > > Good point! That doesn't apply if you use ||, though. If you just did > > "return somepointer" that could potentially cause the problem you > > describe. In any case, it can't *hurt* to have it; GCC should do the > > sane thing. > > OK. I will review this towards the end, leaving it there to remind me > in the meantime. > > So, would I need the !! on the left-hand operand of the first || due > to short-circuiting? No. || will always return 1 or 0. You only need the !! if you want to directly return the boolean value of a potentially 64-bit pointer. - Josh Triplett -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Paul E. McKenney on 27 Aug 2008 14:30 On Mon, Aug 25, 2008 at 05:26:43PM +0200, Peter Zijlstra wrote: > On Mon, 2008-08-25 at 08:16 -0700, Paul E. McKenney wrote: > > On Mon, Aug 25, 2008 at 12:34:56PM +0200, Peter Zijlstra wrote: > > > On Fri, 2008-08-22 at 16:29 -0700, Josh Triplett wrote: > > > > > > > > @@ -26,8 +27,10 @@ > > > > > * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001) > > > > > * > > > > > * For detailed explanation of Read-Copy Update mechanism see - > > > > > - * Documentation/RCU > > > > > - * > > > > > + * Documentation/RCU > > > > > + * http://lwn.net/Articles/262464/ (What is RCU, Fundamentally?) > > > > > + * http://lwn.net/Articles/263130/ (What is RCU's Usage?) > > > > > + * http://lwn.net/Articles/264090/ (What is RCU's API? + references) > > > > > */ > > > > > > > > Why put these references here rather than in Documentation/RCU? It > > > > seems easier to keep documentation up to date in one place. If you > > > > think these represent a good "getting started" set of documents, how > > > > about a Documentation/RCU/ReadTheseFirst with links to them, or how > > > > about linking to them from whatisRCU.txt? > > > > > > I actually like in code comments and 'documentation' more than > > > Documentation/ stuff. Mostly because Documentation/ is: > > > - far away from the code > > > - therefore, more easily bitrotted > > > - and easily forgotten > > > > I know!!! > > > > #ifdef JOSH_TRIPLETT > > * Documentation/RCU > > * http://lwn.net/Articles/262464/ (What is RCU, Fundamentally?) > > * http://lwn.net/Articles/263130/ (What is RCU's Usage?) > > * http://lwn.net/Articles/264090/ (What is RCU's API? + references) > > #elif PETER_ZIJLSTRA > > * Documentation/RCU > > #endif > > > > (Sorry, couldn't resist!!!) > > But but but, you got the cases the wrong way around.. ;-) Good point... #ifdef READER_LIKES_DOCUMENTATION_URLS_IN_COMMENTS * Documentation/RCU * http://lwn.net/Articles/262464/ (What is RCU, Fundamentally?) * http://lwn.net/Articles/263130/ (What is RCU's Usage?) * http://lwn.net/Articles/264090/ (What is RCU's API? + references) #else * Documentation/RCU #endif Of course, the C preprocessor would just remove the whole comment anyway, but hopefully it is the thought that counts. ;-) > > Seriously, I know where all the documentation is, as I wrote most of it. > > These comments are for you guys. So, any thoughts on how I should > > resolve this? My default is, as always, a coin flip. ;-) > > I guess we could do the 'this is how the concept works and can be used > like so and so' documentation in Documentation/ Documentation/RCU/whatisRCU.txt does in fact contain the three URLs listed above. And there is always Documentation/RCU/RTFP.txt for people wanting the full effect. > And the stuff that says 'this code does like so and so, because blah' > should stay near the code. > > And in any case of doubt - stay near the code :-) > > I always view Documentation/ as end user stuff (be that a kernel > programmer that needs to learn a new API, or userland folks or people > wanting to know what a certain feature is about). I confess to erring on the side of spamming all channels. Then again, I am a serial junk-mailer, so perhaps this is just me. Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Paul E. McKenney on 27 Aug 2008 14:40 On Tue, Aug 26, 2008 at 05:38:36PM -0700, Josh Triplett wrote: > On Tue, 2008-08-26 at 09:05 -0700, Paul E. McKenney wrote: > > On Mon, Aug 25, 2008 at 03:02:30PM -0700, Josh Triplett wrote: > > > On Fri, 2008-08-22 at 18:53 -0700, Paul E. McKenney wrote: > > > > On Fri, Aug 22, 2008 at 04:29:32PM -0700, Josh Triplett wrote: > > > > > On Thu, 2008-08-21 at 16:43 -0700, Paul E. McKenney wrote: > > > > > > @@ -658,14 +806,19 @@ int rcu_needs_cpu(int cpu) > > > > > > struct rcu_data *rdp = &per_cpu(rcu_data, cpu); > > > > > > struct rcu_data *rdp_bh = &per_cpu(rcu_bh_data, cpu); > > > > > > > > > > > > - return !!rdp->nxtlist || !!rdp_bh->nxtlist || rcu_pending(cpu); > > > > > > + return !!*rdp->nxttail[RCU_DONE_TAIL] || > > > > > > + !!*rdp_bh->nxttail[RCU_DONE_TAIL] || > > > > > > + rcu_pending(cpu); > > > > > > > > > > !! seems unnecessary here. > > > > > > > > Someone once told me why this was necessary, but I forget. It was in the > > > > original, and I didn't put it there. Some weirdness about conversion > > > > to 32-bit integer when the lower 32 bits of the pointer was zero or > > > > some such. So if your pointer value was 0x100000000, for example, > > > > so that conversion to int gives zero. > > > > > > Good point! That doesn't apply if you use ||, though. If you just did > > > "return somepointer" that could potentially cause the problem you > > > describe. In any case, it can't *hurt* to have it; GCC should do the > > > sane thing. > > > > OK. I will review this towards the end, leaving it there to remind me > > in the meantime. > > > > So, would I need the !! on the left-hand operand of the first || due > > to short-circuiting? > > No. || will always return 1 or 0. You only need the !! if you want to > directly return the boolean value of a potentially 64-bit pointer. Even if one argument of || is long and the other int or some fool thing like that? (What, me paranoid???) Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Josh Triplett on 27 Aug 2008 16:30 On Wed, 2008-08-27 at 11:34 -0700, Paul E. McKenney wrote: > On Tue, Aug 26, 2008 at 05:38:36PM -0700, Josh Triplett wrote: > > On Tue, 2008-08-26 at 09:05 -0700, Paul E. McKenney wrote: > > > On Mon, Aug 25, 2008 at 03:02:30PM -0700, Josh Triplett wrote: > > > > On Fri, 2008-08-22 at 18:53 -0700, Paul E. McKenney wrote: > > > > > On Fri, Aug 22, 2008 at 04:29:32PM -0700, Josh Triplett wrote: > > > > > > On Thu, 2008-08-21 at 16:43 -0700, Paul E. McKenney wrote: > > > > > > > @@ -658,14 +806,19 @@ int rcu_needs_cpu(int cpu) > > > > > > > struct rcu_data *rdp = &per_cpu(rcu_data, cpu); > > > > > > > struct rcu_data *rdp_bh = &per_cpu(rcu_bh_data, cpu); > > > > > > > > > > > > > > - return !!rdp->nxtlist || !!rdp_bh->nxtlist || rcu_pending(cpu); > > > > > > > + return !!*rdp->nxttail[RCU_DONE_TAIL] || > > > > > > > + !!*rdp_bh->nxttail[RCU_DONE_TAIL] || > > > > > > > + rcu_pending(cpu); > > > > > > > > > > > > !! seems unnecessary here. > > > > > > > > > > Someone once told me why this was necessary, but I forget. It was in the > > > > > original, and I didn't put it there. Some weirdness about conversion > > > > > to 32-bit integer when the lower 32 bits of the pointer was zero or > > > > > some such. So if your pointer value was 0x100000000, for example, > > > > > so that conversion to int gives zero. > > > > > > > > Good point! That doesn't apply if you use ||, though. If you just did > > > > "return somepointer" that could potentially cause the problem you > > > > describe. In any case, it can't *hurt* to have it; GCC should do the > > > > sane thing. > > > > > > OK. I will review this towards the end, leaving it there to remind me > > > in the meantime. > > > > > > So, would I need the !! on the left-hand operand of the first || due > > > to short-circuiting? > > > > No. || will always return 1 or 0. You only need the !! if you want to > > directly return the boolean value of a potentially 64-bit pointer. > > Even if one argument of || is long and the other int or some fool thing > like that? (What, me paranoid???) What, you don't know exactly how C behaves in every strange corner case? ;) || always produces a result of type int, and it compares each of its two arguments to 0 independently; to the best of my knowledge the size of those arguments never matters. - Josh Triplett -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Paul E. McKenney on 27 Aug 2008 16:50 On Wed, Aug 27, 2008 at 01:23:28PM -0700, Josh Triplett wrote: > On Wed, 2008-08-27 at 11:34 -0700, Paul E. McKenney wrote: > > On Tue, Aug 26, 2008 at 05:38:36PM -0700, Josh Triplett wrote: > > > On Tue, 2008-08-26 at 09:05 -0700, Paul E. McKenney wrote: > > > > On Mon, Aug 25, 2008 at 03:02:30PM -0700, Josh Triplett wrote: > > > > > On Fri, 2008-08-22 at 18:53 -0700, Paul E. McKenney wrote: > > > > > > On Fri, Aug 22, 2008 at 04:29:32PM -0700, Josh Triplett wrote: > > > > > > > On Thu, 2008-08-21 at 16:43 -0700, Paul E. McKenney wrote: > > > > > > > > @@ -658,14 +806,19 @@ int rcu_needs_cpu(int cpu) > > > > > > > > struct rcu_data *rdp = &per_cpu(rcu_data, cpu); > > > > > > > > struct rcu_data *rdp_bh = &per_cpu(rcu_bh_data, cpu); > > > > > > > > > > > > > > > > - return !!rdp->nxtlist || !!rdp_bh->nxtlist || rcu_pending(cpu); > > > > > > > > + return !!*rdp->nxttail[RCU_DONE_TAIL] || > > > > > > > > + !!*rdp_bh->nxttail[RCU_DONE_TAIL] || > > > > > > > > + rcu_pending(cpu); > > > > > > > > > > > > > > !! seems unnecessary here. > > > > > > > > > > > > Someone once told me why this was necessary, but I forget. It was in the > > > > > > original, and I didn't put it there. Some weirdness about conversion > > > > > > to 32-bit integer when the lower 32 bits of the pointer was zero or > > > > > > some such. So if your pointer value was 0x100000000, for example, > > > > > > so that conversion to int gives zero. > > > > > > > > > > Good point! That doesn't apply if you use ||, though. If you just did > > > > > "return somepointer" that could potentially cause the problem you > > > > > describe. In any case, it can't *hurt* to have it; GCC should do the > > > > > sane thing. > > > > > > > > OK. I will review this towards the end, leaving it there to remind me > > > > in the meantime. > > > > > > > > So, would I need the !! on the left-hand operand of the first || due > > > > to short-circuiting? > > > > > > No. || will always return 1 or 0. You only need the !! if you want to > > > directly return the boolean value of a potentially 64-bit pointer. > > > > Even if one argument of || is long and the other int or some fool thing > > like that? (What, me paranoid???) > > What, you don't know exactly how C behaves in every strange corner > case? ;) I used to, back when identifiers were only guaranteed to be differentiated by their first 8 characters (6 or 7 if extern). ;-) > || always produces a result of type int, and it compares each of its two > arguments to 0 independently; to the best of my knowledge the size of > those arguments never matters. I suppose I should read the spec. Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
First
|
Prev
|
Pages: 1 2 3 4 Prev: Keyboard Jammed error patch 2.4.35-pre4 Next: init: DEBUG_BLOCK_EXT_DEVT requires explicit root= param |