[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <alpine.LFD.2.00.0811092304300.13034@xanadu.home>
Date: Sun, 09 Nov 2008 23:20:00 -0500 (EST)
From: Nicolas Pitre <nico@....org>
To: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Russell King <rmk+lkml@....linux.org.uk>,
David Howells <dhowells@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
lkml <linux-kernel@...r.kernel.org>,
Ralf Baechle <ralf@...ux-mips.org>, benh@...nel.crashing.org,
paulus@...ba.org, David Miller <davem@...emloft.net>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Steven Rostedt <rostedt@...dmis.org>,
linux-arch@...r.kernel.org
Subject: Re: [PATCH v2] clarify usage expectations for cnt32_to_63()
On Sun, 9 Nov 2008, Mathieu Desnoyers wrote:
> * Nicolas Pitre (nico@....org) wrote:
> > Do you really have such instances where multiple call sites are needed?
> > That sounds even more confusing to me than the current model. Better
> > encapsulate the usage of this macro within some function which has a
> > stronger meaning, such as sched_clock(), and call _that_ from multiple
> > sites instead.
>
> I see a few reasons for it :
>
> - If we want to inline the whole read function so we don't pay the extra
> runtime cost of a function call, this would become required.
You can inline it as you want as long as it remains in the same .c file.
The static variable is still shared amongst all call sites in that case.
> - If we want to create a per cpu timer which updates the value
> periodically without calling the function. We may want to add some
> WARN_ON or some sanity tests in this periodic update that would not be
> part of the standard read code. If we don't have access to this
> variable outside of the macro, this becomes impossible.
I don't see how you could update the variable without calling the
function somehow or duplicating it. As to the sanity check argument:
you can perform such checks on the result rather than the internal
variable which IMHO would be more logical.
And if you want a per CPU version, then it's better to create a
per_cpu_cnt32_to_63() variant which could use a relaxed barrier in that
case.
Nicolas
--
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