From: Daniel Colascione <dancol@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Minchan Kim <minchan@kernel.org>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>, Michal Hocko <mhocko@suse.com>
Subject: Re: [PATCH] Synchronize task mm counters on context switch
Date: Thu, 22 Feb 2018 08:23:40 -0800 [thread overview]
Message-ID: <CAKOZueuPh5OA_sBTNgHdx5+UYCGcUm_n3fwwVuYGXhi2C0jjqg@mail.gmail.com> (raw)
In-Reply-To: <20180222094009.GO25201@hirez.programming.kicks-ass.net>
[-- Attachment #1: Type: text/plain, Size: 2221 bytes --]
On Feb 22, 2018 1:40 AM, "Peter Zijlstra" <peterz@infradead.org> wrote:
On Thu, Feb 22, 2018 at 11:06:33AM +0900, Minchan Kim wrote:
> On Wed, Feb 21, 2018 at 04:23:43PM -0800, Daniel Colascione wrote:
> > kernel/sched/core.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index a7bf32aabfda..7f197a7698ee 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -3429,6 +3429,9 @@ asmlinkage __visible void __sched schedule(void)
> > struct task_struct *tsk = current;
> >
> > sched_submit_work(tsk);
> > + if (tsk->mm)
> > + sync_mm_rss(tsk->mm);
> > +
> > do {
> > preempt_disable();
> > __schedule(false);
> >
Obviously I completely hate that; and you really _should_ have Cc'ed me
earlier ;-)
I thought I might get a reaction like that. :-)
That it still well over 100 cycles in the case when all counters did
change. Far _far_ more if the mm counters are contended (up to 150 times
more is quite possible).
I suppose it doesn't help to sync the counters only when dirty, detecting
this situation with a task status flag or something?
> > > > Ping? Is this approach just a bad idea? We could instead just
manually sync
> > > > all mm-attached tasks at counter-retrieval time.
> > >
> > > IMHO, yes, it should be done when user want to see which would be
really
> > > cold path while this shecule function is hot.
> > >
> >
> > The problem with doing it that way is that we need to look at each task
> > attached to a particular mm. AFAIK (and please tell me if I'm wrong),
the
> > only way to do that is to iterate over all processes, and for each
process
> > attached to the mm we want, iterate over all its tasks (since each one
has
> > to have the same mm, I think). Does that sound right?
You could just iterate the thread group and call it a day. Yes strictly
speaking its possible to have mm's shared outside the thread group,
practically that 'never' happens.
CLONE_VM without CLONE_THREAD just isn't a popular thing afaik.
So while its not perfect, it might well be good enough.
Take a look at the other patch I posted. Seems to work.
[-- Attachment #2: Type: text/html, Size: 3868 bytes --]
prev parent reply other threads:[~2018-02-22 16:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-05 22:03 Daniel Colascione
2018-02-21 19:05 ` Daniel Colascione
2018-02-22 0:16 ` Minchan Kim
2018-02-22 0:23 ` Daniel Colascione
2018-02-22 2:06 ` Minchan Kim
2018-02-22 2:46 ` [PATCH] Synchronize task mm counters on demand Daniel Colascione
2018-02-23 2:01 ` Minchan Kim
2018-02-23 2:09 ` Daniel Colascione
2018-02-23 2:24 ` Daniel Colascione
2018-02-23 2:28 ` Minchan Kim
2018-02-23 2:43 ` Daniel Colascione
2018-02-23 3:12 ` Minchan Kim
2018-02-23 9:50 ` f66871fb4c: WARNING:inconsistent_lock_state kernel test robot
2018-02-22 2:49 ` [PATCH] Synchronize task mm counters on context switch Daniel Colascione
2018-02-23 8:11 ` Michal Hocko
2018-02-23 16:34 ` Daniel Colascione
2018-02-23 17:50 ` Michal Hocko
2018-02-23 18:47 ` Daniel Colascione
2018-02-27 10:02 ` Michal Hocko
2018-02-22 9:40 ` Peter Zijlstra
2018-02-22 13:06 ` Minchan Kim
2018-02-22 16:23 ` Daniel Colascione [this message]
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=CAKOZueuPh5OA_sBTNgHdx5+UYCGcUm_n3fwwVuYGXhi2C0jjqg@mail.gmail.com \
--to=dancol@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.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