Skip to content

Commit

Permalink
slab: skip calling cache_free_alien() when the platform is not numa c…
Browse files Browse the repository at this point in the history
…apable

Skip calling cache_free_alien() when the platform is not numa capable.
This will avoid cache misses that happen while accessing slabp (which is
per page memory reference) to get nodeid.  Instead use a global variable to
skip the call, which is mostly likely to be present in the cache.

This gives a 0.8% performance boost with the database oltp workload on a
quad-core SMP platform and by any means the number is not small :)

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Siddha, Suresh B authored and Linus Torvalds committed Aug 23, 2007
1 parent 32d2198 commit 1807a1a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ static void __slab_error(const char *function, struct kmem_cache *cachep,
*/

static int use_alien_caches __read_mostly = 1;
static int numa_platform __read_mostly = 1;
static int __init noaliencache_setup(char *s)
{
use_alien_caches = 0;
Expand Down Expand Up @@ -1399,8 +1400,10 @@ void __init kmem_cache_init(void)
int order;
int node;

if (num_possible_nodes() == 1)
if (num_possible_nodes() == 1) {
use_alien_caches = 0;
numa_platform = 0;
}

for (i = 0; i < NUM_INIT_LISTS; i++) {
kmem_list3_init(&initkmem_list3[i]);
Expand Down Expand Up @@ -3558,7 +3561,14 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp)
check_irq_off();
objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));

if (cache_free_alien(cachep, objp))
/*
* Skip calling cache_free_alien() when the platform is not numa.
* This will avoid cache misses that happen while accessing slabp (which
* is per page memory reference) to get nodeid. Instead use a global
* variable to skip the call, which is mostly likely to be present in
* the cache.
*/
if (numa_platform && cache_free_alien(cachep, objp))
return;

if (likely(ac->avail < ac->limit)) {
Expand Down

0 comments on commit 1807a1a

Please sign in to comment.