Messages in this thread | | | Date | Mon, 3 Mar 2008 11:48:59 +0200 | From | Adrian Bunk <> | Subject | Re: [2.6 patch] acpi/battery.c: make 2 functions static |
| |
On Mon, Mar 03, 2008 at 10:31:03AM +0100, Sam Ravnborg wrote: > On Mon, Mar 03, 2008 at 10:17:14AM +0100, Ingo Molnar wrote: > > > > * Adrian Bunk <bunk@kernel.org> wrote: > > > > > On Mon, Mar 03, 2008 at 09:57:20AM +0100, Ingo Molnar wrote: > > > > > > > > * Adrian Bunk <bunk@kernel.org> wrote: > > > > > > > > > On Sat, Mar 01, 2008 at 09:26:41PM +0300, Alexey Starikovskiy wrote: > > > > > > May I keep them inline? > > > > > > > > > > The problem with such manual inlines is that we force gcc to always > > > > > inline them - and history has shown that functions grow without the > > > > > "inline" being removed. > > > > > > > > what do you mean by "we force gcc to always inline them"? > > > > > > #define inline inline __attribute__((always_inline)) > > > > > > > gcc is free to decide whether to inline or to not inline. > > > > > > Not with __attribute__((always_inline)). > > > > but that wasnt used in the code you patched: > > > > -inline int acpi_battery_present(struct acpi_battery *battery) > > +static int acpi_battery_present(struct acpi_battery *battery) > > >From compiler-gcc.h: > > #define inline inline __attribute__((always_inline)) > > So unless I am missing something obvious then each time we > say inline to a function we require gcc to inline the function.
Exactly.
> It is my impression that today we only say inline if really needed > and otherwise let gcc decide. So in almost all cases inlise should > just be nuked?
The rule is: - all static functions in headers should be marked inline - no functions in .c files should be marked inline
For the latter there are a _few_ exceptions in hotpaths where doing so brings measurable advantages.
But generally (and especially long-term) it's best to let gcc decide which static functions in .c files should be inlined.
> Sam
cu Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out of the darkness. There had been need of rain for many days. "Only a promise," Lao Er said. Pearl S. Buck - Dragon Seed
| |