[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120312175220.GE2471@linux.vnet.ibm.com>
Date: Mon, 12 Mar 2012 10:52:21 -0700
From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Lai Jiangshan <eag0628@...il.com>,
Lai Jiangshan <laijs@...fujitsu.com>,
linux-kernel@...r.kernel.org, mingo@...e.hu, dipankar@...ibm.com,
akpm@...ux-foundation.org, mathieu.desnoyers@...ymtl.ca,
josh@...htriplett.org, niv@...ibm.com, tglx@...utronix.de,
rostedt@...dmis.org, Valdis.Kletnieks@...edu, dhowells@...hat.com,
eric.dumazet@...il.com, darren@...art.com, fweisbec@...il.com,
patches@...aro.org
Subject: Re: [RFC PATCH 5/6] implement per-cpu&per-domain state machine
call_srcu()
On Sat, Mar 10, 2012 at 11:12:29AM +0100, Peter Zijlstra wrote:
> On Thu, 2012-03-08 at 11:49 -0800, Paul E. McKenney wrote:
> >
> > I too have used (long)(a - b) for a long time, but I saw with my own eyes
> > the glee in the compiler-writers' eyes when they discussed signed overflow
> > being undefined in the C standard. I believe that the reasons for signed
> > overflow being undefined are long obsolete, but better safe than sorry.
>
> Thing is, if they break that the whole kernel comes falling down, I
> really wouldn't worry about RCU at that point. But to each their
> pet-paranoia I guess ;-)
But just because I am paranoid doesn't mean that no one is after me! ;-)
I agree that the compiler guys would need to provide a chicken switch
due to the huge amount of code that relies on (long)(a - b) handling
overflow reasonably. But avoiding signed integer overflow is pretty
straightforward. For example, I use the following in RCU:
#define UINT_CMP_GE(a, b) (UINT_MAX / 2 >= (a) - (b))
#define UINT_CMP_LT(a, b) (UINT_MAX / 2 < (a) - (b))
#define ULONG_CMP_GE(a, b) (ULONG_MAX / 2 >= (a) - (b))
#define ULONG_CMP_LT(a, b) (ULONG_MAX / 2 < (a) - (b))
But yes, part of the reason for my doing this was to make conversations
with the usual standards-committee suspects go more smoothly.
Thanx, Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists