[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: UP/SMP difference in IRQ_STAT
Looks like you haven't got my point or I haven't made my point clear.
So I will try again.
Under UP,
#define __IRQ_STAT(cpu, member) ((void)(cpu), irq_stat[0].member)
I agree with your point about compiler optimization/performace improvement
here as irq_stat[0].member is used instead of irq_stat[cpu].member(this would
save the indirection overhead)
But, I am worried about the first argument '(void)(cpu)' in the definition.
Instead of doing #define x (y), why should we do #define x (z, y) where z
is not used.
As you can see, with this, the assignment won't work. Eg, If I wan't to do
local_irq_count = 0, it translates (under UP) to
(cpu, irq_stat[0].__local_irq_count) = 0, which is syntactically wrong.
I see no change in performace/optimization if this definition is changed to
#define __IRQ_STAT(cpu, member) (irq_stat[0].member), which will allow me
to do local_irq_count = 0, which translates to
(irq_stat[0].__local_irq_count = 0).
Hope I have made my point clear and have understood your point too :-)
Regards,
Bharata.
On Sun, Jan 06, 2002 at 02:17:27AM +0000, John Levon wrote:
> On Thu, Dec 20, 2001 at 05:22:12PM +0530, Bharata B Rao wrote:
>
> > On Thu, Dec 20, 2001 at 11:41:38AM +0000, John Levon wrote:
> > > On Wed, Dec 19, 2001 at 11:07:11AM +0530, Bharata B Rao wrote:
> > >
> > > > Please consider the following definitions from include/linux/irq_cpustat.h
> > > > --------------------------
> > > > #ifdef CONFIG_SMP
> > > > #define __IRQ_STAT(cpu, member) (irq_stat[cpu].member)
> > > > #else
> > > > #define __IRQ_STAT(cpu, member) ((void)(cpu), irq_stat[0].member)
> > > > #endif
> > >
> > > I can only assume this is for performance. cpu might not be constant to the compiler,
> > > so the first would still have an indirection overhead on UP. The second one, however,
> > > lets the compiler optimise as the value of cpu is discarded (assume its evaluation has
> > > not side effects that is ;)
> >
> > If that is so, why not just
> > #define __IRQ_STAT(cpu, member) (irq_stat[0].member)
> > for UP, so that the macros like local_irq_count(cpu) can be used as Lvalue.
> > (I am concerned about not being able to use this as Lvalue in UP)
>
> haven't I just answered this above ?
>
> whether it makes a difference or not performance-wise is a different matter. IF you want
> it to change, you should prove that it makes no real difference.
>
> john
>
> --
> "Unless everyone else on earth is attending meetings I haven't been told
> about."
> - /. paranoia at its finest
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive: http://mail.nl.linux.org/kernelnewbies/
> IRC Channel: irc.openprojects.net / #kernelnewbies
> Web Page: http://www.kernelnewbies.org/
--
Bharata B Rao,
IBM Linux Technology Center,
IBM Software Lab, Bangalore.
Ph: 91-80-5044962
Mail: bharata@in.ibm.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/