From: Andrea Arcangeli <aarcange@redhat.com>
To: Christoph Lameter <cl@linux.com>
Cc: Rik van Riel <riel@redhat.com>, Mel Gorman <mel@csn.ul.ie>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <pzijlstr@redhat.com>, Ingo Molnar <mingo@elte.hu>,
Hugh Dickins <hughd@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Hillf Danton <dhillf@gmail.com>,
Andrew Jones <drjones@redhat.com>, Dan Smith <danms@us.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Paul Turner <pjt@google.com>,
Suresh Siddha <suresh.b.siddha@intel.com>,
Mike Galbraith <efault@gmx.de>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH 07/33] autonuma: mm_autonuma and task_autonuma data structures
Date: Fri, 12 Oct 2012 02:52:00 +0200 [thread overview]
Message-ID: <20121012005200.GA1818@redhat.com> (raw)
In-Reply-To: <0000013a525a8739-2b4049fa-1cb3-4b8f-b3a7-1fa77b181590-000000@email.amazonses.com>
Hi Christoph,
On Fri, Oct 12, 2012 at 12:23:17AM +0000, Christoph Lameter wrote:
> On Thu, 11 Oct 2012, Rik van Riel wrote:
>
> > These statistics are updated at page fault time, I
> > believe while holding the page table lock.
> >
> > In other words, they are in code paths where updating
> > the stats should not cause issues.
>
> The per cpu counters in the VM were introduced because of
> counter contention caused at page fault time. This is the same code path
> where you think that there cannot be contention.
There's no contention at all in autonuma27.
I changed it in autonuma28, to get real time updates in mm_autonuma
from migration events.
There is no lock taken though (the spinlock below is taken once every
pass, very rarely). It's a few liner change shown in detail below. The
only contention point is this:
+ ACCESS_ONCE(mm_numa_fault[access_nid]) += numpages;
+ ACCESS_ONCE(mm_autonuma->mm_numa_fault_tot) += numpages;
autonuma28 is much more experimental than autonuma27 :)
I wouldn't focus on >1024 CPU systems for this though. The bigger the
system the more costly any automatic placement logic will become, no
matter which algorithm and which computation complexity the algorithm
has, and chances are those will use NUMA hard bindings anyway
considering how much they're expensive to setup and maintain.
The diff looks like this, I can consider undoing it. Comments
welcome. (but real time stats updates, converge faster in autonuma28)
--- a/mm/autonuma.c
+++ b/mm/autonuma.c
static struct knuma_scand_data {
struct list_head mm_head; /* entry: mm->mm_autonuma->mm_node */
struct mm_struct *mm;
unsigned long address;
- unsigned long *mm_numa_fault_tmp;
} knuma_scand_data = {
.mm_head = LIST_HEAD_INIT(knuma_scand_data.mm_head),
};
+ unsigned long tot;
+
+ /*
+ * Set the task's fault_pass equal to the new
+ * mm's fault_pass, so new_pass will be false
+ * on the next fault by this thread in this
+ * same pass.
+ */
+ p->task_autonuma->task_numa_fault_pass = mm_numa_fault_pass;
+
/* If a new pass started, degrade the stats by a factor of 2 */
for_each_node(nid)
task_numa_fault[nid] >>= 1;
task_autonuma->task_numa_fault_tot >>= 1;
+
+ if (mm_numa_fault_pass ==
+ ACCESS_ONCE(mm_autonuma->mm_numa_fault_last_pass))
+ return;
+
+ spin_lock(&mm_autonuma->mm_numa_fault_lock);
+ if (unlikely(mm_numa_fault_pass ==
+ mm_autonuma->mm_numa_fault_last_pass)) {
+ spin_unlock(&mm_autonuma->mm_numa_fault_lock);
+ return;
+ }
+ mm_autonuma->mm_numa_fault_last_pass = mm_numa_fault_pass;
+
+ tot = 0;
+ for_each_node(nid) {
+ unsigned long fault = ACCESS_ONCE(mm_numa_fault[nid]);
+ fault >>= 1;
+ ACCESS_ONCE(mm_numa_fault[nid]) = fault;
+ tot += fault;
+ }
+ mm_autonuma->mm_numa_fault_tot = tot;
+ spin_unlock(&mm_autonuma->mm_numa_fault_lock);
}
task_numa_fault[access_nid] += numpages;
task_autonuma->task_numa_fault_tot += numpages;
+ ACCESS_ONCE(mm_numa_fault[access_nid]) += numpages;
+ ACCESS_ONCE(mm_autonuma->mm_numa_fault_tot) += numpages;
+
local_bh_enable();
}
@@ -310,28 +355,35 @@ static void numa_hinting_fault_cpu_follow_memory(struct task_struct *p,
@@ -593,35 +628,26 @@ static int knuma_scand_pmd(struct mm_struct *mm,
goto out;
if (pmd_trans_huge_lock(pmd, vma) == 1) {
- int page_nid;
- unsigned long *fault_tmp;
ret = HPAGE_PMD_NR;
VM_BUG_ON(address & ~HPAGE_PMD_MASK);
- if (autonuma_mm_working_set() && pmd_numa(*pmd)) {
+ if (pmd_numa(*pmd)) {
spin_unlock(&mm->page_table_lock);
goto out;
}
-
page = pmd_page(*pmd);
-
/* only check non-shared pages */
if (page_mapcount(page) != 1) {
spin_unlock(&mm->page_table_lock);
goto out;
}
-
- page_nid = page_to_nid(page);
- fault_tmp = knuma_scand_data.mm_numa_fault_tmp;
- fault_tmp[page_nid] += ret;
-
if (pmd_numa(*pmd)) {
spin_unlock(&mm->page_table_lock);
goto out;
}
-
set_pmd_at(mm, address, pmd, pmd_mknuma(*pmd));
+
/* defer TLB flush to lower the overhead */
spin_unlock(&mm->page_table_lock);
goto out;
@@ -636,10 +662,9 @@ static int knuma_scand_pmd(struct mm_struct *mm,
for (_address = address, _pte = pte; _address < end;
_pte++, _address += PAGE_SIZE) {
pte_t pteval = *_pte;
- unsigned long *fault_tmp;
if (!pte_present(pteval))
continue;
- if (autonuma_mm_working_set() && pte_numa(pteval))
+ if (pte_numa(pteval))
continue;
page = vm_normal_page(vma, _address, pteval);
if (unlikely(!page))
@@ -647,13 +672,8 @@ static int knuma_scand_pmd(struct mm_struct *mm,
/* only check non-shared pages */
if (page_mapcount(page) != 1)
continue;
-
- fault_tmp = knuma_scand_data.mm_numa_fault_tmp;
- fault_tmp[page_to_nid(page)]++;
-
if (pte_numa(pteval))
continue;
-
if (!autonuma_scan_pmd())
set_pte_at(mm, _address, _pte, pte_mknuma(pteval));
@@ -677,56 +697,6 @@ out:
return ret;
}
-static void mm_numa_fault_tmp_flush(struct mm_struct *mm)
-{
- int nid;
- struct mm_autonuma *mma = mm->mm_autonuma;
- unsigned long tot;
- unsigned long *fault_tmp = knuma_scand_data.mm_numa_fault_tmp;
-
- if (autonuma_mm_working_set()) {
- for_each_node(nid) {
- tot = fault_tmp[nid];
- if (tot)
- break;
- }
- if (!tot)
- /* process was idle, keep the old data */
- return;
- }
-
- /* FIXME: would be better protected with write_seqlock_bh() */
- local_bh_disable();
-
- tot = 0;
- for_each_node(nid) {
- unsigned long faults = fault_tmp[nid];
- fault_tmp[nid] = 0;
- mma->mm_numa_fault[nid] = faults;
- tot += faults;
- }
- mma->mm_numa_fault_tot = tot;
-
- local_bh_enable();
-}
-
-static void mm_numa_fault_tmp_reset(void)
-{
- memset(knuma_scand_data.mm_numa_fault_tmp, 0,
- mm_autonuma_fault_size());
-}
-
-static inline void validate_mm_numa_fault_tmp(unsigned long address)
-{
-#ifdef CONFIG_DEBUG_VM
- int nid;
- if (address)
- return;
- for_each_node(nid)
- BUG_ON(knuma_scand_data.mm_numa_fault_tmp[nid]);
-#endif
-}
-
/*
* Scan the next part of the mm. Keep track of the progress made and
* return it.
@@ -758,8 +728,6 @@ static int knumad_do_scan(void)
}
address = knuma_scand_data.address;
- validate_mm_numa_fault_tmp(address);
-
mutex_unlock(&knumad_mm_mutex);
down_read(&mm->mmap_sem);
@@ -855,9 +824,7 @@ static int knumad_do_scan(void)
/* tell autonuma_exit not to list_del */
VM_BUG_ON(mm->mm_autonuma->mm != mm);
mm->mm_autonuma->mm = NULL;
- mm_numa_fault_tmp_reset();
- } else
- mm_numa_fault_tmp_flush(mm);
+ }
mmdrop(mm);
}
@@ -942,7 +916,6 @@ static int knuma_scand(void *none)
if (mm)
mmdrop(mm);
- mm_numa_fault_tmp_reset();
return 0;
}
@@ -987,11 +960,6 @@ static int start_knuma_scand(void)
int err = 0;
struct task_struct *knumad_thread;
- knuma_scand_data.mm_numa_fault_tmp = kzalloc(mm_autonuma_fault_size(),
- GFP_KERNEL);
- if (!knuma_scand_data.mm_numa_fault_tmp)
- return -ENOMEM;
-
knumad_thread = kthread_run(knuma_scand, NULL, "knuma_scand");
if (unlikely(IS_ERR(knumad_thread))) {
autonuma_printk(KERN_ERR
Thanks!
next prev parent reply other threads:[~2012-10-12 0:52 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1349308275-2174-1-git-send-email-aarcange@redhat.com>
[not found] ` <20121004113943.be7f92a0.akpm@linux-foundation.org>
2012-10-05 23:14 ` [PATCH 00/33] AutoNUMA27 Andi Kleen
2012-10-05 23:57 ` Tim Chen
2012-10-06 0:11 ` Andi Kleen
2012-10-08 13:44 ` Don Morris
2012-10-08 20:34 ` Rik van Riel
[not found] ` <20121011101930.GM3317@csn.ul.ie>
2012-10-11 14:56 ` Andrea Arcangeli
2012-10-11 15:35 ` Mel Gorman
2012-10-12 0:41 ` Andrea Arcangeli
2012-10-12 14:54 ` Mel Gorman
[not found] ` <1349308275-2174-2-git-send-email-aarcange@redhat.com>
[not found] ` <20121011105036.GN3317@csn.ul.ie>
2012-10-11 16:07 ` [PATCH 01/33] autonuma: add Documentation/vm/autonuma.txt Andrea Arcangeli
2012-10-11 19:37 ` Mel Gorman
[not found] ` <1349308275-2174-5-git-send-email-aarcange@redhat.com>
[not found] ` <20121011110137.GQ3317@csn.ul.ie>
2012-10-11 16:43 ` [PATCH 04/33] autonuma: define _PAGE_NUMA Andrea Arcangeli
2012-10-11 19:48 ` Mel Gorman
[not found] ` <1349308275-2174-6-git-send-email-aarcange@redhat.com>
[not found] ` <20121011111545.GR3317@csn.ul.ie>
2012-10-11 16:58 ` [PATCH 05/33] autonuma: pte_numa() and pmd_numa() Andrea Arcangeli
2012-10-11 19:54 ` Mel Gorman
[not found] ` <1349308275-2174-7-git-send-email-aarcange@redhat.com>
[not found] ` <20121011122255.GS3317@csn.ul.ie>
2012-10-11 17:05 ` [PATCH 06/33] autonuma: teach gup_fast about pmd_numa Andrea Arcangeli
2012-10-11 20:01 ` Mel Gorman
[not found] ` <1349308275-2174-8-git-send-email-aarcange@redhat.com>
[not found] ` <20121011122827.GT3317@csn.ul.ie>
2012-10-11 17:15 ` [PATCH 07/33] autonuma: mm_autonuma and task_autonuma data structures Andrea Arcangeli
2012-10-11 20:06 ` Mel Gorman
[not found] ` <5076E4B2.2040301@redhat.com>
[not found] ` <0000013a525a8739-2b4049fa-1cb3-4b8f-b3a7-1fa77b181590-000000@email.amazonses.com>
2012-10-12 0:52 ` Andrea Arcangeli [this message]
[not found] ` <1349308275-2174-9-git-send-email-aarcange@redhat.com>
[not found] ` <20121011134643.GU3317@csn.ul.ie>
2012-10-11 17:34 ` [PATCH 08/33] autonuma: define the autonuma flags Andrea Arcangeli
2012-10-11 20:17 ` Mel Gorman
[not found] ` <1349308275-2174-11-git-send-email-aarcange@redhat.com>
[not found] ` <20121011145805.GW3317@csn.ul.ie>
2012-10-12 0:25 ` [PATCH 10/33] autonuma: CPU follows memory algorithm Andrea Arcangeli
2012-10-12 8:29 ` Mel Gorman
[not found] ` <20121011213432.GQ3317@csn.ul.ie>
2012-10-12 1:45 ` [PATCH 00/33] AutoNUMA27 Andrea Arcangeli
2012-10-12 8:46 ` Mel Gorman
[not found] ` <1349308275-2174-16-git-send-email-aarcange@redhat.com>
[not found] ` <20121011155302.GA3317@csn.ul.ie>
[not found] ` <50770314.7060800@redhat.com>
[not found] ` <20121011175953.GT1818@redhat.com>
2012-10-12 14:03 ` [PATCH 15/33] autonuma: alloc/free/init task_autonuma Rik van Riel
2012-10-13 18:40 ` [PATCH 00/33] AutoNUMA27 Srikar Dronamraju
2012-10-14 4:57 ` Andrea Arcangeli
2012-10-15 8:16 ` Srikar Dronamraju
2012-10-23 16:32 ` Srikar Dronamraju
[not found] ` <1349308275-2174-20-git-send-email-aarcange@redhat.com>
[not found] ` <20121013180618.GC31442@linux.vnet.ibm.com>
2012-10-15 8:24 ` [PATCH 19/33] autonuma: memory follows CPU algorithm and task/mm_autonuma stats collection Srikar Dronamraju
2012-10-15 9:20 ` Mel Gorman
2012-10-15 10:00 ` Srikar Dronamraju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121012005200.GA1818@redhat.com \
--to=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=danms@us.ibm.com \
--cc=dhillf@gmail.com \
--cc=drjones@redhat.com \
--cc=efault@gmx.de \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pjt@google.com \
--cc=pzijlstr@redhat.com \
--cc=riel@redhat.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox