2012-10-18 17:02:10

by Peter Zijlstra

[permalink] [raw]
Subject: [tip:numa/core] sched/numa: Simplify task_numa_fault()

Commit-ID: f3bd8842a897685269b3fa48ad6f9d5590be67ab
Gitweb: http://git.kernel.org/tip/f3bd8842a897685269b3fa48ad6f9d5590be67ab
Author: Peter Zijlstra <[email protected]>
AuthorDate: Wed, 10 Oct 2012 14:13:15 +0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 15 Oct 2012 12:30:16 +0200

sched/numa: Simplify task_numa_fault()

Also fix numa_scan_seq off by one.

Signed-off-by: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
include/linux/sched.h | 11 +----------
kernel/sched/core.c | 2 +-
kernel/sched/fair.c | 9 ++++-----
3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 99a70eb..c7f8656 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1608,16 +1608,7 @@ static inline int tsk_home_node(struct task_struct *p)
}

extern void task_numa_placement(void);
-extern void __task_numa_fault(int node);
-static inline void task_numa_fault(int node)
-{
- struct task_struct *p = current;
-
- if (likely(p->numa_faults))
- p->numa_faults[node]++;
- else
- __task_numa_fault(node);
-}
+extern void task_numa_fault(int node);
#else
static inline int tsk_home_node(struct task_struct *p)
{
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ff4a3bd..b370f2f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1543,7 +1543,7 @@ static void __sched_fork(struct task_struct *p)
p->node = -1;
p->node_stamp = 0ULL;
p->numa_scan_seq = p->mm ? p->mm->numa_scan_seq : 0;
- p->numa_migrate_seq = p->mm ? p->mm->numa_scan_seq : 0;
+ p->numa_migrate_seq = p->mm ? p->mm->numa_scan_seq - 1 : 0;
p->numa_faults = NULL;
#endif /* CONFIG_SCHED_NUMA */
}
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 592291b..1a32930 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -823,18 +823,17 @@ unsigned int sysctl_sched_numa_settle_count = 2;
/*
* Got a PROT_NONE fault for a page on @node.
*/
-void __task_numa_fault(int node)
+void task_numa_fault(int node)
{
struct task_struct *p = current;

- if (!p->numa_faults) {
+ if (unlikely(!p->numa_faults)) {
p->numa_faults = kzalloc(sizeof(unsigned long) * nr_node_ids,
GFP_KERNEL);
+ if (!p->numa_faults)
+ return;
}

- if (!p->numa_faults)
- return;
-
p->numa_faults[node]++;
}