Skip to content

Commit 2a38961

Browse files
rientjestorvalds
authored andcommitted
mm, mempolicy: rename slab_node for clarity
slab_node() is actually a mempolicy function, so rename it to mempolicy_slab_node() to make it clearer that it used for processes with mempolicies. At the same time, cleanup its code by saving numa_mem_id() in a local variable (since we require a node with memory, not just any node) and remove an obsolete comment that assumes the mempolicy is actually passed into the function. Signed-off-by: David Rientjes <[email protected]> Acked-by: Christoph Lameter <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Jianguo Wu <[email protected]> Cc: Tim Hockin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 514ddb4 commit 2a38961

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

include/linux/mempolicy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ extern struct zonelist *huge_zonelist(struct vm_area_struct *vma,
151151
extern bool init_nodemask_of_mempolicy(nodemask_t *mask);
152152
extern bool mempolicy_nodemask_intersects(struct task_struct *tsk,
153153
const nodemask_t *mask);
154-
extern unsigned slab_node(void);
154+
extern unsigned int mempolicy_slab_node(void);
155155

156156
extern enum zone_type policy_zone;
157157

mm/mempolicy.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -1782,21 +1782,18 @@ static unsigned interleave_nodes(struct mempolicy *policy)
17821782
/*
17831783
* Depending on the memory policy provide a node from which to allocate the
17841784
* next slab entry.
1785-
* @policy must be protected by freeing by the caller. If @policy is
1786-
* the current task's mempolicy, this protection is implicit, as only the
1787-
* task can change it's policy. The system default policy requires no
1788-
* such protection.
17891785
*/
1790-
unsigned slab_node(void)
1786+
unsigned int mempolicy_slab_node(void)
17911787
{
17921788
struct mempolicy *policy;
1789+
int node = numa_mem_id();
17931790

17941791
if (in_interrupt())
1795-
return numa_node_id();
1792+
return node;
17961793

17971794
policy = current->mempolicy;
17981795
if (!policy || policy->flags & MPOL_F_LOCAL)
1799-
return numa_node_id();
1796+
return node;
18001797

18011798
switch (policy->mode) {
18021799
case MPOL_PREFERRED:
@@ -1816,11 +1813,11 @@ unsigned slab_node(void)
18161813
struct zonelist *zonelist;
18171814
struct zone *zone;
18181815
enum zone_type highest_zoneidx = gfp_zone(GFP_KERNEL);
1819-
zonelist = &NODE_DATA(numa_node_id())->node_zonelists[0];
1816+
zonelist = &NODE_DATA(node)->node_zonelists[0];
18201817
(void)first_zones_zonelist(zonelist, highest_zoneidx,
18211818
&policy->v.nodes,
18221819
&zone);
1823-
return zone ? zone->node : numa_node_id();
1820+
return zone ? zone->node : node;
18241821
}
18251822

18261823
default:

mm/slab.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3042,7 +3042,7 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
30423042
if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD))
30433043
nid_alloc = cpuset_slab_spread_node();
30443044
else if (current->mempolicy)
3045-
nid_alloc = slab_node();
3045+
nid_alloc = mempolicy_slab_node();
30463046
if (nid_alloc != nid_here)
30473047
return ____cache_alloc_node(cachep, flags, nid_alloc);
30483048
return NULL;
@@ -3074,7 +3074,7 @@ static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
30743074

30753075
retry_cpuset:
30763076
cpuset_mems_cookie = read_mems_allowed_begin();
3077-
zonelist = node_zonelist(slab_node(), flags);
3077+
zonelist = node_zonelist(mempolicy_slab_node(), flags);
30783078

30793079
retry:
30803080
/*

mm/slub.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
16851685

16861686
do {
16871687
cpuset_mems_cookie = read_mems_allowed_begin();
1688-
zonelist = node_zonelist(slab_node(), flags);
1688+
zonelist = node_zonelist(mempolicy_slab_node(), flags);
16891689
for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) {
16901690
struct kmem_cache_node *n;
16911691

0 commit comments

Comments
 (0)