rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com,
	dipankar@in.ibm.com, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
	rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
	fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
	viro@zeniv.linux.org.uk, Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH RFC tip/core/rcu] Add shrinker to shift to fast/inefficient GP mode
Date: Thu, 7 May 2020 10:09:03 -0700	[thread overview]
Message-ID: <20200507170903.GR2869@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <20200507170006.GA155220@cmpxchg.org>

On Thu, May 07, 2020 at 01:00:06PM -0400, Johannes Weiner wrote:
> On Wed, May 06, 2020 at 05:55:35PM -0700, Andrew Morton wrote:
> > On Wed, 6 May 2020 17:42:40 -0700 "Paul E. McKenney" <paulmck@kernel.org> wrote:
> > 
> > > This commit adds a shrinker so as to inform RCU when memory is scarce.
> > > RCU responds by shifting into the same fast and inefficient mode that is
> > > used in the presence of excessive numbers of RCU callbacks.  RCU remains
> > > in this state for one-tenth of a second, though this time window can be
> > > extended by another call to the shrinker.
> 
> We may be able to use shrinkers here, but merely being invoked does
> not carry a reliable distress signal.
> 
> Shrinkers get invoked whenever vmscan runs. It's a useful indicator
> for when to age an auxiliary LRU list - test references, clear and
> rotate or reclaim stale entries. The urgency, and what can and cannot
> be considered "stale", is encoded in the callback frequency and scan
> counts, and meant to be relative to the VM's own rate of aging: "I've
> tested X percent of mine for recent use, now you go and test the same
> share of your pool." It doesn't translate well to other
> interpretations of the callbacks, although people have tried.

Would it make sense for RCU to interpret two invocations within (say)
100ms of each other as indicating urgency?  (Hey, I had to ask!)

> > > If it proves feasible, a later commit might add a function call directly
> > > indicating the end of the period of scarce memory.
> > 
> > (Cc David Chinner, who often has opinions on shrinkers ;))
> > 
> > It's a bit abusive of the intent of the slab shrinkers, but I don't
> > immediately see a problem with it.  Always returning 0 from
> > ->scan_objects might cause a problem in some situations(?).
> > 
> > Perhaps we should have a formal "system getting low on memory, please
> > do something" notification API.
> 
> It's tricky to find a useful definition of what low on memory
> means. In the past we've used sc->priority cutoffs, the vmpressure
> interface (reclaimed/scanned - reclaim efficiency cutoffs), oom
> notifiers (another reclaim efficiency cutoff). But none of these
> reliably capture "distress", and they vary highly between different
> hardware setups. It can be hard to trigger OOM itself on fast IO
> devices, even when the machine is way past useful (where useful is
> somewhat subjective to the user). Userspace OOM implementations that
> consider userspace health (also subjective) are getting more common.
> 
> > How significant is this?  How much memory can RCU consume?
> 
> I think if rcu can end up consuming a significant share of memory, one
> way that may work would be to do proper shrinker integration and track
> the age of its objects relative to the age of other allocations in the
> system. I.e. toss them all on a clock list with "new" bits and shrink
> them at VM velocity. If the shrinker sees objects with new bit set,
> clear and rotate. If it sees objects without them, we know rcu_heads
> outlive cache pages etc. and should probably cycle faster too.

It would be easy for RCU to pass back (or otherwise use) the age of the
current grace period, if that would help.

Tracking the age of individual callbacks is out of the question due to
memory overhead, but RCU could approximate this via statistical sampling.
Comparing this to grace-period durations could give information as to
whether making grace periods go faster would be helpful.

But, yes, it would be better to have an elusive unambiguous indication
of distress.  ;-)

							Thanx, Paul

  reply	other threads:[~2020-05-07 17:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07  0:42 [PATCH RFC tip/core/rcu] Add shrinker to shift to fast/inefficient GP mode Paul E. McKenney
2020-05-07  0:55 ` Andrew Morton
2020-05-07  2:45   ` Paul E. McKenney
2020-05-07 17:00   ` Johannes Weiner
2020-05-07 17:09     ` Paul E. McKenney [this message]
2020-05-07 17:29       ` Paul E. McKenney
2020-05-07 18:31       ` Johannes Weiner
2020-05-07 19:09         ` Paul E. McKenney
2020-05-08  9:00           ` Konstantin Khlebnikov
2020-05-08 14:46             ` Paul E. McKenney
2020-05-09  8:54               ` Konstantin Khlebnikov
2020-05-09 16:09                 ` Paul E. McKenney
2020-05-13  1:32                   ` Dave Chinner
2020-05-13  3:18                     ` Paul E. McKenney
2020-05-13  4:35                       ` Konstantin Khlebnikov
2020-05-13 12:52                         ` Paul E. McKenney
2020-05-13  5:07                       ` Dave Chinner
2020-05-13 13:03                         ` Paul E. McKenney
     [not found] ` <20200507093647.11932-1-hdanton@sina.com>
2020-05-07 15:49   ` Paul E. McKenney
     [not found]   ` <20200508133743.9356-1-hdanton@sina.com>
2020-05-08 14:47     ` Paul E. McKenney

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=20200507170903.GR2869@paulmck-ThinkPad-P72 \
    --to=paulmck@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@fromorbit.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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).