Skip to content

Commit f3b39d4

Browse files
Miao Xietorvalds
authored andcommitted
cpusets: restructure the function cpuset_update_task_memory_state()
The kernel still allocates the page caches on old node after modifying its cpuset's mems when 'memory_spread_page' was set, or it didn't spread the page cache evenly over all the nodes that faulting task is allowed to usr after memory_spread_page was set. it is caused by the old mem_allowed and flags of the task, the current kernel doesn't updates them unless some function invokes cpuset_update_task_memory_state(), it is too late sometimes.We must update the mem_allowed and the flags of the tasks in time. Slab has the same problem. The following patches fix this bug by updating tasks' mem_allowed and spread flag after its cpuset's mems or spread flag is changed. This patch: Extract a function from cpuset_update_task_memory_state(). It will be used later for update tasks' page/slab spread flags after its cpuset's flag is set Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Paul Menage <menage@google.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Yasunori Goto <y-goto@jp.fujitsu.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent dcf975d commit f3b39d4

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

‎kernel/cpuset.c‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,24 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
331331
BUG_ON(!nodes_intersects(*pmask, node_states[N_HIGH_MEMORY]));
332332
}
333333

334+
/*
335+
* update task's spread flag if cpuset's page/slab spread flag is set
336+
*
337+
* Called with callback_mutex/cgroup_mutex held
338+
*/
339+
static void cpuset_update_task_spread_flag(struct cpuset *cs,
340+
struct task_struct *tsk)
341+
{
342+
if (is_spread_page(cs))
343+
tsk->flags |= PF_SPREAD_PAGE;
344+
else
345+
tsk->flags &= ~PF_SPREAD_PAGE;
346+
if (is_spread_slab(cs))
347+
tsk->flags |= PF_SPREAD_SLAB;
348+
else
349+
tsk->flags &= ~PF_SPREAD_SLAB;
350+
}
351+
334352
/**
335353
* cpuset_update_task_memory_state - update task memory placement
336354
*
@@ -388,14 +406,7 @@ void cpuset_update_task_memory_state(void)
388406
cs = task_cs(tsk); /* Maybe changed when task not locked */
389407
guarantee_online_mems(cs, &tsk->mems_allowed);
390408
tsk->cpuset_mems_generation = cs->mems_generation;
391-
if (is_spread_page(cs))
392-
tsk->flags |= PF_SPREAD_PAGE;
393-
else
394-
tsk->flags &= ~PF_SPREAD_PAGE;
395-
if (is_spread_slab(cs))
396-
tsk->flags |= PF_SPREAD_SLAB;
397-
else
398-
tsk->flags &= ~PF_SPREAD_SLAB;
409+
cpuset_update_task_spread_flag(cs, tsk);
399410
task_unlock(tsk);
400411
mutex_unlock(&callback_mutex);
401412
mpol_rebind_task(tsk, &tsk->mems_allowed);

0 commit comments

Comments
 (0)