Skip to content

Commit

Permalink
slab common: add functions for kmem_cache_node access
Browse files Browse the repository at this point in the history
The patchset provides two new functions in mm/slab.h and modifies SLAB
and SLUB to use these.  The kmem_cache_node structure is shared between
both allocators and the use of common accessors will allow us to move
more code into slab_common.c in the future.

This patch (of 3):

These functions allow to eliminate repeatedly used code in both SLAB and
SLUB and also allow for the insertion of debugging code that may be
needed in the development process.

Signed-off-by: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Acked-by: David Rientjes <[email protected]>
Acked-by: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Lameter authored and torvalds committed Aug 7, 2014
1 parent 1536cb3 commit 44c5356
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
17 changes: 16 additions & 1 deletion mm/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
}
#endif


#ifndef CONFIG_SLOB
/*
* The slab lists for all objects.
*/
Expand Down Expand Up @@ -294,5 +294,20 @@ struct kmem_cache_node {

};

static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node)
{
return s->node[node];
}

/*
* Iterator over all nodes. The body will be executed for each node that has
* a kmem_cache_node structure allocated (which is true for all online nodes)
*/
#define for_each_kmem_cache_node(__s, __node, __n) \
for (__node = 0; __n = get_node(__s, __node), __node < nr_node_ids; __node++) \
if (__n)

#endif

void *slab_next(struct seq_file *m, void *p, loff_t *pos);
void slab_stop(struct seq_file *m, void *p);
5 changes: 0 additions & 5 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ static inline void stat(const struct kmem_cache *s, enum stat_item si)
* Core slab cache functions
*******************************************************************/

static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node)
{
return s->node[node];
}

/* Verify that a pointer has an address that is valid within a slab page */
static inline int check_valid_pointer(struct kmem_cache *s,
struct page *page, const void *object)
Expand Down

0 comments on commit 44c5356

Please sign in to comment.