Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
From: Jason Gunthorpe <jgg@mellanox.com>
To: Michal Hocko <mhocko@suse.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Andrea Arcangeli" <aarcange@redhat.com>,
	"Christoph Hellwig" <hch@lst.de>
Subject: Re: [PATCH] mm/mmn: prevent unpaired invalidate_start and invalidate_end with non-blocking
Date: Thu, 24 Oct 2019 14:15:12 +0000
Message-ID: <20191024141507.GF22766@mellanox.com> (raw)
In-Reply-To: <20190808121309.GD18351@dhcp22.suse.cz>

On Thu, Aug 08, 2019 at 02:13:09PM +0200, Michal Hocko wrote:
> On Thu 08-08-19 12:04:07, Jason Gunthorpe wrote:
> > On Thu, Aug 08, 2019 at 10:18:27AM +0200, Michal Hocko wrote:
> > > On Wed 07-08-19 19:16:32, Jason Gunthorpe wrote:
> > > > Many users of the mmu_notifier invalidate_range callbacks maintain
> > > > locking/counters/etc on a paired basis and have long expected that
> > > > invalidate_range start/end are always paired.
> > > > 
> > > > The recent change to add non-blocking notifiers breaks this assumption
> > > > when multiple notifiers are present in the list as an EAGAIN return from a
> > > > later notifier causes all earlier notifiers to get their
> > > > invalidate_range_end() skipped.
> > > > 
> > > > During the development of non-blocking each user was audited to be sure
> > > > they can skip their invalidate_range_end() if their start returns -EAGAIN,
> > > > so the only place that has a problem is when there are multiple
> > > > subscriptions.
> > > > 
> > > > Due to the RCU locking we can't reliably generate a subset of the linked
> > > > list representing the notifiers already called, and generate an
> > > > invalidate_range_end() pairing.
> > > > 
> > > > Rather than design an elaborate fix, for now, just block non-blocking
> > > > requests early on if there are multiple subscriptions.
> > > 
> > > Which means that the oom path cannot really release any memory for
> > > ranges covered by these notifiers which is really unfortunate because
> > > that might cover a lot of memory. Especially when the particular range
> > > might not be tracked at all, right?
> > 
> > Yes, it is a very big hammer to avoid a bug where the locking schemes
> > get corrupted and the impacted drivers deadlock.
> > 
> > If you really don't like it then we have to push ahead on either an
> > rcu-safe undo algorithm or some locking thing. I've been looking at
> > the locking thing, so we can wait a bit more and see. 
> 
> Well, I do not like it but I understand that an over reaction for OOM is
> much less of a pain than a deadlock or similar misbehavior. So go ahead
> with this as a stop gap with Cc: stable but please let's do not stop
> there and let's come up with something of a less hamery kind.
> 
> That being said, feel free to add
> Acked-by: Michal Hocko <mhocko@suse.com>
> with a printk_once to explain what is going on and a TODO note that this
> is just a stop gap.

I didn't resend this pending how the mmu notifiers rework would look.

With this patch:

https://patchwork.kernel.org/patch/11191423/

Users of the new mmu_range_notifiers can safely share and handling
!blocking failures. They also reliably limit their influence for OOM
to a specific VA range without taking blocking locks, as desired.

I intend to resend this patch, with the warning, with the thinking
that all the cases involving sharing notifiers are likely to have been
moved to the mmu_range scheme.

Does this seem reasonable? Would you look through the above?

Thanks,
Jason


      reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 19:16 Jason Gunthorpe
2019-08-08  7:00 ` Christoph Hellwig
2019-08-08  8:18 ` Michal Hocko
2019-08-08 12:04   ` Jason Gunthorpe
2019-08-08 12:13     ` Michal Hocko
2019-10-24 14:15       ` Jason Gunthorpe [this message]

Reply instructions:

You may reply publically 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=20191024141507.GF22766@mellanox.com \
    --to=jgg@mellanox.com \
    --cc=aarcange@redhat.com \
    --cc=hch@lst.de \
    --cc=jglisse@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.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

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git