From: Andrea Arcangeli <aarcange@redhat.com>
To: Nai Xia <nai.xia@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
dlaor@redhat.com, Ingo Molnar <mingo@kernel.org>,
Hillf Danton <dhillf@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Dan Smith <danms@us.ibm.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
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>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
Bharata B Rao <bharata.rao@gmail.com>,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
Rik van Riel <riel@redhat.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
Christoph Lameter <cl@linux.com>, Alex Shi <alex.shi@intel.com>,
Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Don Morris <don.morris@hp.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH 13/40] autonuma: CPU follow memory algorithm
Date: Sat, 30 Jun 2012 03:23:38 +0200 [thread overview]
Message-ID: <20120630012338.GY6676@redhat.com> (raw)
In-Reply-To: <CAPQyPG4R34bi0fXHBspSpR1+gDLj2PGYpPXNLPTTTBmrRL=m4g@mail.gmail.com>
On Sat, Jun 30, 2012 at 04:01:50AM +0800, Nai Xia wrote:
> On Sat, Jun 30, 2012 at 2:53 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > On Fri, 2012-06-29 at 12:51 -0400, Dor Laor wrote:
> >> The previous comments were not shouts but the mother of all NAKs.
> >
> > I never said any such thing. I just said why should I bother reading
> > your stuff if you're ignoring most my feedback anyway.
> >
> > If you want to read that as a NAK, not my problem.
>
> Hey guys, Can I say NAK to these patches ?
>
> Now I aware that this sampling algorithm is completely broken, if we take
> a few seconds to see what it is trying to solve:
>
> We all know that LRU is try to solve the question of "what are the
> pages recently accessed?",
> so its engouth to use pte bits to approximate.
I made an example about the active list to try to explain it why your
example is still going to work fine.
After it becomes active (from inactive) and it's being a referenced
active page, it won't become _very_active_ or _very_very_active_ or
more no matter how many more times you look up the pagecache.
The LRU order wasn't relevant here.
> However, the numa balancing problem is fundamentally like this:
>
> In some time unit,
>
> W = pages_accessed * average_page_access_frequence
>
> We are trying to move process to the node having max W, right?
First of all, the mm_autonuma statistics are not in function of time
and there is no page access frequency there.
mm_autonuma is static information collected by knuma_scand from the
pagetables. That's static and 100% accurate on the whole process and
definitely not generated by the numa hinting page faults. I could shut
off all numa hinting page faults permanently and still generate the
mm_autonuma information identically.
There's a knob in /sys/kernel/mm/autonuma/knuma_scand/working_set that
you can enable if you want to use a "runtime" and not static
information for the mm_autonuma too, but that's not the default for
now (but I think it may be a better default, there wasn't enough time
to test this yet)
The task_autonuma (thread) statistics are the only thing that is
sampled by default in a 10sec interval (the interval tunable too with
sysfs, and 10sec is likely too aggressive, 30sec sounds better, we're
eventually going to make it dynamic anyway)
So even if you were right, the thread statistics only kicks in to
balance threads against threads of the same process, most of the time
what's more important are the mm_autonuma statistics.
But in reality the thread statistics also works perfectly for the job,
as an approximation of the NUMA memory footprint of the thread (vs the
other threads). And then the rest of the memory slowly follows
whatever node CPUs I placed the thread (even if that's not the
absolutely best one at all times).
> Andrea's patch can only approximate the pages_accessed number in a
> time unit(scan interval),
> I don't think it can catch even 1% of average_page_access_frequence
> on a busy workload.
> Blindly assuming that all the pages' average_page_access_frequence is
> the same is seemly
> broken to me.
All we need is an approximation to take a better than random decision,
even if you get it 1% right, it's still better than 0% right by going
blind. Your 1% is too pessimistic, in my tests the thread statistics
are more like >90% correct in average (I monitor them with the debug
mode constantly).
If this 1% right, happens one a million samples, who cares, it's not
going to run measurably slower anyway (and it will still be better
than picking a 0% right node).
What you're saying is that because the active list in the pagecache
won't differentiate between 10 cache hits and 20 cache hits, we should
drop the active list and stop activating pages and just threat them
all the same because in some unlucky access pattern, the active list
may only get right 1% of the working set. But there's a reason why the
active list exists despite it may get things wrong in some corner case
and possibly leave the large amount of pages accessed infrequently in
the inactive list forever (even if it gets things only 1% right in
those worst cases, it's still better than 0% right and no active list
at all).
To say it in another way, you may still crash with the car even if
you're careful, but do you think it's better to watch at the street or
to drive blindfolded?
numa/sched drives blindfolded, autonuma watches around every 10sec
very carefully for the best next turn to take with the car and to
avoid obstacles, you can imagine who wins.
Watching the street carefully every 10sec doesn't mean the next moment
a missile won't hit your car to make you crash, you're still having
better chances not to crash than by driving blindfolded.
numa/sched pretends to compete without collecting information for the
NUMA thread memory footprint (task_autonuma, sampled with a
exponential backoff at 10sec intervals), and without process
information (full static information from the pagetables, not
sampled). No matter how you compute stuff, if you've nothing
meaningful in input to your algorithm you lose. And it looks like you
believe that you can take better decisions with nothing in input to
your NUMA placement algorithm, because my thread info (task_autonuma)
isn't 100% perfect at all times and it can't predict the future. The
alternative is to get that information from syscalls, but even
ignoring the -ENOMEM from split_vma, that will lead to userland bugs
and overall the task_autonuma information may be more reliable in the
end, even if it's sampled using an exponential backoff.
Also note the exponential backoff thing, it's not really the last
interval, it's the last interval plus half the previous interval plus
1/4 the previous interval etc... and we can trivially control the
decay.
All we need is to get a direction and knowing _exactly_ what the task
did over the last 10 seconds (even if it can't predict the future of
what the thread will do in the next 1sec), is all we need to get a
direction. After we take the direction then the memory will follow so
we cannot care less what it does in the next second because that will
follow the CPU (after a while, last_nid anti-false-sharing logic
permitting), and at least we'll know for sure that the memory accessed
in the last 10sec is already local and that defines the best node to
schedule the thread.
I don't mean there's no room for improvement in the way the input data
can be computed, and even in the way the input data can be generated,
the exponential backoff decay can be tuned too, I just tried to do the
simplest computations on the data to make the workloads converge fast
and you're welcome to contribute.
But I believe the task_autonuma information is extremely valuable and
we can trust it very much knowing we'll get a great placement. The
concern you have isn't invalid, but it's a very minor one and the
sampling rate effects you are concerned about, while real, they're
lost in the noise in practice.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-06-30 1:24 UTC|newest]
Thread overview: 177+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-28 12:55 [PATCH 00/40] AutoNUMA19 Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 01/40] mm: add unlikely to the mm allocation failure check Andrea Arcangeli
2012-06-29 14:10 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 02/40] autonuma: make set_pmd_at always available Andrea Arcangeli
2012-06-29 14:10 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 03/40] autonuma: export is_vma_temporary_stack() even if CONFIG_TRANSPARENT_HUGEPAGE=n Andrea Arcangeli
2012-06-29 14:11 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 04/40] xen: document Xen is using an unused bit for the pagetables Andrea Arcangeli
2012-06-29 14:16 ` Rik van Riel
2012-07-04 23:05 ` Andrea Arcangeli
2012-06-30 4:47 ` Konrad Rzeszutek Wilk
2012-07-03 10:45 ` Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 05/40] autonuma: define _PAGE_NUMA_PTE and _PAGE_NUMA_PMD Andrea Arcangeli
2012-06-28 15:13 ` Don Morris
2012-06-28 15:00 ` Andrea Arcangeli
2012-06-29 14:26 ` Rik van Riel
2012-07-03 20:30 ` Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 06/40] autonuma: x86 pte_numa() and pmd_numa() Andrea Arcangeli
2012-06-29 15:02 ` Rik van Riel
2012-07-04 23:03 ` Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 07/40] autonuma: generic " Andrea Arcangeli
2012-06-29 15:13 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 08/40] autonuma: teach gup_fast about pte_numa Andrea Arcangeli
2012-06-29 15:27 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 09/40] autonuma: introduce kthread_bind_node() Andrea Arcangeli
2012-06-29 15:36 ` Rik van Riel
2012-06-29 16:04 ` Peter Zijlstra
2012-06-29 16:11 ` Rik van Riel
2012-06-29 16:38 ` Andrea Arcangeli
2012-06-29 16:58 ` Rik van Riel
2012-07-05 13:09 ` Johannes Weiner
2012-07-05 18:33 ` Glauber Costa
2012-07-05 20:07 ` Andrea Arcangeli
2012-06-30 4:50 ` Konrad Rzeszutek Wilk
2012-07-04 23:14 ` Andrea Arcangeli
2012-07-05 12:04 ` Konrad Rzeszutek Wilk
2012-07-05 12:28 ` Andrea Arcangeli
2012-07-05 12:18 ` Peter Zijlstra
2012-07-05 12:21 ` Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 10/40] autonuma: mm_autonuma and sched_autonuma data structures Andrea Arcangeli
2012-06-29 15:47 ` Rik van Riel
2012-06-29 17:45 ` Rik van Riel
2012-07-04 23:16 ` Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 11/40] autonuma: define the autonuma flags Andrea Arcangeli
2012-06-29 16:10 ` Rik van Riel
2012-06-30 4:58 ` Konrad Rzeszutek Wilk
2012-07-02 15:42 ` Konrad Rzeszutek Wilk
2012-06-30 5:01 ` Konrad Rzeszutek Wilk
2012-07-04 23:45 ` Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 12/40] autonuma: core autonuma.h header Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 13/40] autonuma: CPU follow memory algorithm Andrea Arcangeli
2012-06-28 14:46 ` Peter Zijlstra
2012-06-29 14:11 ` Nai Xia
2012-06-29 16:30 ` Andrea Arcangeli
2012-06-29 18:09 ` Nai Xia
2012-06-29 21:02 ` Nai Xia
2012-07-03 11:53 ` Peter Zijlstra
2012-06-28 14:53 ` Peter Zijlstra
2012-06-29 12:16 ` Hillf Danton
2012-06-29 12:55 ` Ingo Molnar
2012-06-29 16:51 ` Dor Laor
2012-06-29 18:41 ` Peter Zijlstra
2012-06-29 18:46 ` Rik van Riel
2012-06-29 18:51 ` Peter Zijlstra
2012-06-29 18:57 ` Peter Zijlstra
2012-06-29 19:03 ` Peter Zijlstra
2012-06-29 19:19 ` Rik van Riel
2012-07-02 16:57 ` Vaidyanathan Srinivasan
2012-07-05 16:56 ` Vaidyanathan Srinivasan
2012-07-06 13:04 ` Hillf Danton
2012-07-06 18:38 ` Vaidyanathan Srinivasan
2012-07-12 13:12 ` Andrea Arcangeli
2012-06-29 18:49 ` Peter Zijlstra
2012-06-29 18:53 ` Peter Zijlstra
2012-06-29 20:01 ` Nai Xia
2012-06-29 20:44 ` Nai Xia
2012-06-30 1:23 ` Andrea Arcangeli [this message]
2012-06-30 2:43 ` Nai Xia
2012-06-30 5:48 ` Dor Laor
2012-06-30 6:58 ` Nai Xia
2012-06-30 13:04 ` Andrea Arcangeli
2012-06-30 15:19 ` Nai Xia
2012-06-30 19:37 ` Dor Laor
2012-07-01 2:41 ` Nai Xia
2012-06-30 23:55 ` Benjamin Herrenschmidt
2012-07-01 3:10 ` Nai Xia
2012-06-30 8:23 ` Nai Xia
2012-07-02 7:29 ` Rik van Riel
2012-07-02 7:43 ` Nai Xia
2012-06-30 12:48 ` Andrea Arcangeli
2012-06-30 15:10 ` Nai Xia
2012-07-02 7:36 ` Rik van Riel
2012-07-02 7:56 ` Nai Xia
2012-07-02 8:17 ` Rik van Riel
2012-07-02 8:31 ` Nai Xia
2012-07-05 18:07 ` Rik van Riel
2012-07-05 22:59 ` Andrea Arcangeli
2012-07-06 1:00 ` Nai Xia
2012-06-29 19:04 ` Peter Zijlstra
2012-06-29 20:27 ` Nai Xia
2012-06-29 18:03 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 14/40] autonuma: add page structure fields Andrea Arcangeli
2012-06-29 18:06 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 15/40] autonuma: knuma_migrated per NUMA node queues Andrea Arcangeli
2012-06-29 18:31 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 16/40] autonuma: init knuma_migrated queues Andrea Arcangeli
2012-06-29 18:35 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 17/40] autonuma: autonuma_enter/exit Andrea Arcangeli
2012-06-29 18:37 ` Rik van Riel
2012-06-28 12:55 ` [PATCH 18/40] autonuma: call autonuma_setup_new_exec() Andrea Arcangeli
2012-06-29 18:39 ` Rik van Riel
2012-06-30 5:04 ` Konrad Rzeszutek Wilk
2012-07-12 17:50 ` Andrea Arcangeli
2012-06-28 12:55 ` [PATCH 19/40] autonuma: alloc/free/init sched_autonuma Andrea Arcangeli
2012-06-29 18:52 ` Rik van Riel
2012-06-30 5:10 ` Konrad Rzeszutek Wilk
2012-07-12 17:59 ` Andrea Arcangeli
2012-06-28 12:56 ` [PATCH 20/40] autonuma: alloc/free/init mm_autonuma Andrea Arcangeli
2012-06-29 18:54 ` Rik van Riel
2012-06-30 5:12 ` Konrad Rzeszutek Wilk
2012-07-12 18:08 ` Andrea Arcangeli
2012-07-12 18:17 ` Johannes Weiner
2012-07-13 14:19 ` Christoph Lameter
2012-07-14 17:01 ` Andrea Arcangeli
2012-07-01 15:33 ` Rik van Riel
2012-07-12 18:27 ` Andrea Arcangeli
2012-06-28 12:56 ` [PATCH 21/40] autonuma: avoid CFS select_task_rq_fair to return -1 Andrea Arcangeli
2012-06-29 18:57 ` Rik van Riel
2012-06-29 19:05 ` Peter Zijlstra
2012-06-29 19:07 ` Rik van Riel
2012-06-29 20:48 ` Ingo Molnar
2012-06-28 12:56 ` [PATCH 22/40] autonuma: teach CFS about autonuma affinity Andrea Arcangeli
2012-07-01 16:37 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 23/40] autonuma: sched_set_autonuma_need_balance Andrea Arcangeli
2012-07-01 16:57 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 24/40] autonuma: core Andrea Arcangeli
2012-07-02 4:07 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 25/40] autonuma: follow_page check for pte_numa/pmd_numa Andrea Arcangeli
2012-07-02 4:14 ` Rik van Riel
2012-07-14 16:43 ` Andrea Arcangeli
2012-06-28 12:56 ` [PATCH 26/40] autonuma: default mempolicy follow AutoNUMA Andrea Arcangeli
2012-07-02 4:19 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 27/40] autonuma: call autonuma_split_huge_page() Andrea Arcangeli
2012-07-02 4:22 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 28/40] autonuma: make khugepaged pte_numa aware Andrea Arcangeli
2012-07-02 4:24 ` Rik van Riel
2012-07-12 18:50 ` Andrea Arcangeli
2012-07-12 21:25 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 29/40] autonuma: retain page last_nid information in khugepaged Andrea Arcangeli
2012-07-02 4:33 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 30/40] autonuma: numa hinting page faults entry points Andrea Arcangeli
2012-07-02 4:47 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 31/40] autonuma: reset autonuma page data when pages are freed Andrea Arcangeli
2012-07-02 4:49 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 32/40] autonuma: initialize page structure fields Andrea Arcangeli
2012-07-02 4:50 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 33/40] autonuma: link mm/autonuma.o and kernel/sched/numa.o Andrea Arcangeli
2012-07-02 4:56 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 34/40] autonuma: add CONFIG_AUTONUMA and CONFIG_AUTONUMA_DEFAULT_ENABLED Andrea Arcangeli
2012-07-02 4:58 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 35/40] autonuma: boost khugepaged scanning rate Andrea Arcangeli
2012-07-02 5:12 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 36/40] autonuma: page_autonuma Andrea Arcangeli
2012-06-30 5:24 ` Konrad Rzeszutek Wilk
2012-07-12 19:43 ` Andrea Arcangeli
2012-07-02 6:37 ` Rik van Riel
2012-07-12 19:58 ` Andrea Arcangeli
2012-06-28 12:56 ` [PATCH 37/40] autonuma: page_autonuma change #include for sparse Andrea Arcangeli
2012-07-02 6:22 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 38/40] autonuma: autonuma_migrate_head[0] dynamic size Andrea Arcangeli
2012-07-02 5:15 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 39/40] autonuma: bugcheck page_autonuma fields on newly allocated pages Andrea Arcangeli
2012-07-02 6:40 ` Rik van Riel
2012-06-28 12:56 ` [PATCH 40/40] autonuma: shrink the per-page page_autonuma struct size Andrea Arcangeli
2012-07-02 7:18 ` Rik van Riel
2012-07-12 20:21 ` Andrea Arcangeli
2012-07-09 15:40 ` [PATCH 00/40] AutoNUMA19 Rik van Riel
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=20120630012338.GY6676@redhat.com \
--to=aarcange@redhat.com \
--cc=Lee.Schermerhorn@hp.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@intel.com \
--cc=benh@kernel.crashing.org \
--cc=bharata.rao@gmail.com \
--cc=cl@linux.com \
--cc=danms@us.ibm.com \
--cc=dhillf@gmail.com \
--cc=dlaor@redhat.com \
--cc=don.morris@hp.com \
--cc=efault@gmx.de \
--cc=hannes@cmpxchg.org \
--cc=konrad.wilk@oracle.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mauricfo@linux.vnet.ibm.com \
--cc=mingo@elte.hu \
--cc=mingo@kernel.org \
--cc=nai.xia@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pjt@google.com \
--cc=riel@redhat.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vatsa@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).