Skip to contentSkip to conversation

lib/rwsem.c: un-inline rwsem_down_failed_common()

PATCH In review Andreas Mohr 3 participants 3 messages Aug 28, 2006 – Aug 29, 2006 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/rwsem.c: un-inline rwsem_down_failed_common()

Un-inlining rwsem_down_failed_common() (two callsites) reduced lib/rwsem.o on my Athlon, gcc 4.1.2 from 5935 to 5480 Bytes (455 Bytes saved).

I thus guess that reduced icache footprint (and better function caching) is worth more than any function call overhead.

Compile-tested and run-tested on 2.6.18-rc4-mm3.

lib/rwsem.c +1 -1
@@ -146,7 +146,7 @@
 /*
  * wait for a lock to be granted
  */
-static inline struct rw_semaphore *
+static struct rw_semaphore *
 rwsem_down_failed_common(struct rw_semaphore *sem,
 			struct rwsem_waiter *waiter, signed long adjustment)
 {
#1 lore raw
Quoted 2 lines · Andreas Mohr

Un-inlining rwsem_down_failed_common() (two callsites) reduced lib/rwsem.o on my Athlon, gcc 4.1.2 from 5935 to 5480 Bytes (455 Bytes saved).

Maybe this should be judged according to CONFIG_CC_OPTIMIZE_FOR_SIZE.

David

#2 lore raw
Quoted 6 lines · David Howells
Quoted 2 lines · Andreas Mohr

Un-inlining rwsem_down_failed_common() (two callsites) reduced lib/rwsem.o on my Athlon, gcc 4.1.2 from 5935 to 5480 Bytes (455 Bytes saved).

Maybe this should be judged according to CONFIG_CC_OPTIMIZE_FOR_SIZE.

gcc already does this if you don't manually specify the inline keyword ;)

static functions get inlined if they're small enough in relation to the nr of call sites, where "small enough" is a function of -O2 vs -Os. So leaving away inline makes gcc do its smarts.

Signature · 1 line
if you want to mail me at work (you don't), use arjan (at) linux.intel.com