Linux-kselftest Archive on
 help / color / Atom feed
From: Ralph Campbell <>
To: Jason Gunthorpe <>
Cc: "" <>,
	"" <>,
	"" <>,
	Jerome Glisse <>,
	"John Hubbard" <>,
	Christoph Hellwig <>,
	Andrew Morton <>,
	Shuah Khan <>
Subject: Re: [PATCH v5 1/2] mm/mmu_notifier: make interval notifier updates safe
Date: Wed, 15 Jan 2020 14:04:47 -0800
Message-ID: <> (raw)
In-Reply-To: <>

On 1/14/20 4:45 AM, Jason Gunthorpe wrote:
> On Mon, Jan 13, 2020 at 02:44:52PM -0800, Ralph Campbell wrote:
>> I'm using the device driver lock to serialize find/insert/update/remove
>> changes to the interval tree.
> The device driver lock can't really fully serialize this as it doesn't
> effect how the intersection lookup runs.
> Jason

Single updates to the interval notifier are atomic due to the
struct mmu_notifier_mm spinlock so the issue is with "punching a hole"
in the interval. In that case, the existing interval is updated to cover
one side of the hole and a new interval is inserted for the other side
while holding the driver lock.

Since this sequence is done from the invalidate() callback, those two
operations will be deferred until the callback returns and any other
parallel invalidates complete (which would be serialized on
the driver lock). So none of these changes will be visible to the
interval tree walks until the last invalidate task calls
mn_itree_inv_end() and all the deferred changes are applied atomically
while holding the spinlock. I'll make sure to add comments explaining

But I see your point if this sequence is done outside of the invalidate
callback. In that case, if the driver shrank the interval, an invalidate
callback for the right hand side could be missed before the insertion of
the new interval for the right hand side.
I'll explain this in the comments for nouveau_svmm_do_unmap() and

  reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 19:57 [PATCH v5 0/2] mm/hmm/test: add self tests for HMM Ralph Campbell
2019-12-16 19:57 ` [PATCH v5 1/2] mm/mmu_notifier: make interval notifier updates safe Ralph Campbell
2019-12-17 20:51   ` Jason Gunthorpe
2019-12-17 21:50     ` Ralph Campbell
2020-01-09 19:48   ` Jason Gunthorpe
2020-01-09 22:01     ` Ralph Campbell
2020-01-09 23:25       ` Jason Gunthorpe
2020-01-13 22:44         ` Ralph Campbell
2020-01-14 12:45           ` Jason Gunthorpe
2020-01-15 22:04             ` Ralph Campbell [this message]
2020-01-16 14:13               ` Jason Gunthorpe
2019-12-16 19:57 ` [PATCH v5 2/2] mm/hmm/test: add self tests for HMM Ralph Campbell

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-kselftest Archive on

Archives are clonable:
	git clone --mirror linux-kselftest/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-kselftest linux-kselftest/ \
	public-inbox-index linux-kselftest

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone