Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1320460imu; Wed, 23 Jan 2019 14:55:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN42H5u3uv3HcHlsAPWX5tQcx92b52XjfP1OJfRz4zykevVragdipd9OvnBBZnAixK2JDipZ X-Received: by 2002:a62:dbc2:: with SMTP id f185mr3879658pfg.235.1548284118230; Wed, 23 Jan 2019 14:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548284118; cv=none; d=google.com; s=arc-20160816; b=oXVKAH4Pj/J8cUcDbX2HSfzKY4Pafw+sRW4Snq7YAktg8IbonSF6LEmYonCFCGRE1u 9qGfbi/Z6LynTSmyTg7XQovmmnQISB71jrp1b8XQAR3ZeO0MF5KyfuNvsIN+f3DNeoln OUfmRoSAiAZpDhmHbYb0bsci+L6mPc0QJa6SGYAPlGjc1nxJrxVBR5cHDtBYTDAWM2qh LlwpBhkjwtersIgB0F92pP2cBc2UuzA8Tews0TBDCb/UwTZskF8EH2u+DytBxkWLSIuD SXielrS8/+PEiEC1n7fmvgTABNQwYvy/mqRnRlEO5VfKUvumD1eHlHvnAYzmzHrjJqg5 OYkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KXJGakeSaX7kv9eetlGNGm5mHRuC6WsYW0U7AeHhhy8=; b=s5WuqJRMfOxdQKZe5HPQvgB16WLQ4KGAttKyilJ8FQaj99oV6b91p8wEpmNik78Mks BG/rrPzhiqhjJk8ymD12O/3RcTZmD6KU8LeAw+C1F+zFosM4rAvZjbKjeiJp0lgaEQLo ZhtH5ZrwzvwMhqu31xI6pmsS//xnKSHn2xDbKQJAvolhBerx1NDeHiO6UMdvWmv+pf0H YX5DJDxIXxngfTeljGxo43o37NeAQxDtYRCfSyDxUSrlynZm+qBXpWyL0DE9EYKPmJ0L va5Bh9BF3J6gtoJLHFDl9KjnxIHpQoJsKeRxTlYsNV3tAZAS4jJxtm1lYD5NlCyuKlcK aO2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="SP/GG+v/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si19997783plm.431.2019.01.23.14.55.03; Wed, 23 Jan 2019 14:55:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="SP/GG+v/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727098AbfAWWyx (ORCPT + 99 others); Wed, 23 Jan 2019 17:54:53 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:40079 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbfAWWyx (ORCPT ); Wed, 23 Jan 2019 17:54:53 -0500 Received: by mail-oi1-f193.google.com with SMTP id t204so3278339oie.7 for ; Wed, 23 Jan 2019 14:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=KXJGakeSaX7kv9eetlGNGm5mHRuC6WsYW0U7AeHhhy8=; b=SP/GG+v/QxoIGNZ8VbX34PLfJJIZoF8sFWJ1gQIuxuTQbyTgJv9C6WJEv4vo/m4bSq dDJbcbUdhOw6NsE7c92E8Zq8/gOJXfjNSdfdmk8X6aATPKS1vGxGhh6eOt+Y6zBmDkIY NX1WAZLF8bkimY4e3g6XyXU1h23kOMk36V95AK17AS61C5BiondT3dW9S4zdYo3aZUhz eQdysotsv1aCWm85RP8ni3CQvWbj5G/E9Y2TN7IRYQRgBWa3jSg8QQZ4PZZewPK+K15B H0AuGW8ryNazURsm4VX3TVtwVjmD+ZoGvV7CdP5O5Q/55adJpq5u8ydSh99Ni0USR3DF ri1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=KXJGakeSaX7kv9eetlGNGm5mHRuC6WsYW0U7AeHhhy8=; b=U+baV2Wp2SmRw9Z68upt41dIaMWWHs4TIpfrv/iAfZO377C9KqCVl2lGu/mSy8QX2H p3GtTqnpd/c0BXn77i2ZJBH3MjqhNr6hSLSEbfLJGNgzZqCktHsD3QxKh53KPqw2ZLYZ tw646erS6CDnQ3sQeDxmcFCumcDefKzzH54s/jFCNcbk8Q7vi7uyzKBRjxE9ss1meAo7 QDwF0cvdiLXpa4Q+WUxUH6Z9mQBIOpVs4A2nZcELxOvnqX2XXGVFD0JurjrEOJfv8haS koq+aitFmjXqSRWPxWDFr1wDea0kY+bvLmIWTRnKvQOICjxVxNg8ybULNVGP4Ld+F7z9 nHvQ== X-Gm-Message-State: AJcUukcP5ATY6ZdGnSyVKMf0hOjRdojSn4bBkJEcHmlcvKMa3pU4UPe9 n5rv/8tfMfskdKTHS27gFEI2k3QvEexe562oLKb3aA== X-Received: by 2002:aca:d78b:: with SMTP id o133mr2466766oig.232.1548284091829; Wed, 23 Jan 2019 14:54:51 -0800 (PST) MIME-Version: 1.0 References: <20190123222315.1122-1-jglisse@redhat.com> In-Reply-To: <20190123222315.1122-1-jglisse@redhat.com> From: Dan Williams Date: Wed, 23 Jan 2019 14:54:40 -0800 Message-ID: Subject: Re: [PATCH v4 0/9] mmu notifier provide context informations To: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= Cc: Linux MM , Andrew Morton , Linux Kernel Mailing List , =?UTF-8?Q?Christian_K=C3=B6nig?= , Jan Kara , Felix Kuehling , Jason Gunthorpe , Matthew Wilcox , Ross Zwisler , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Michal Hocko , Ralph Campbell , John Hubbard , KVM list , Maling list - DRI developers , linux-rdma , linux-fsdevel , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 23, 2019 at 2:23 PM wrote: > > From: J=C3=A9r=C3=B4me Glisse > > Hi Andrew, i see that you still have my event patch in you queue [1]. > This patchset replace that single patch and is broken down in further > step so that it is easier to review and ascertain that no mistake were > made during mechanical changes. Here are the step: > > Patch 1 - add the enum values > Patch 2 - coccinelle semantic patch to convert all call site of > mmu_notifier_range_init to default enum value and also > to passing down the vma when it is available > Patch 3 - update many call site to more accurate enum values > Patch 4 - add the information to the mmu_notifier_range struct > Patch 5 - helper to test if a range is updated to read only > > All the remaining patches are update to various driver to demonstrate > how this new information get use by device driver. I build tested > with make all and make all minus everything that enable mmu notifier > ie building with MMU_NOTIFIER=3Dno. Also tested with some radeon,amd > gpu and intel gpu. > > If they are no objections i believe best plan would be to merge the > the first 5 patches (all mm changes) through your queue for 5.1 and > then to delay driver update to each individual driver tree for 5.2. > This will allow each individual device driver maintainer time to more > thouroughly test this more then my own testing. > > Note that i also intend to use this feature further in nouveau and > HMM down the road. I also expect that other user like KVM might be > interested into leveraging this new information to optimize some of > there secondary page table invalidation. "Down the road" users should introduce the functionality they want to consume. The common concern with preemptively including forward-looking infrastructure is realizing later that the infrastructure is not needed, or needs changing. If it has no current consumer, leave it out. > > Here is an explaination on the rational for this patchset: > > > CPU page table update can happens for many reasons, not only as a result > of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also > as a result of kernel activities (memory compression, reclaim, migration, > ...). > > This patch introduce a set of enums that can be associated with each of > the events triggering a mmu notifier. Latter patches take advantages of > those enum values. > > - UNMAP: munmap() or mremap() > - CLEAR: page table is cleared (migration, compaction, reclaim, ...) > - PROTECTION_VMA: change in access protections for the range > - PROTECTION_PAGE: change in access protections for page in the range > - SOFT_DIRTY: soft dirtyness tracking > > Being able to identify munmap() and mremap() from other reasons why the > page table is cleared is important to allow user of mmu notifier to > update their own internal tracking structure accordingly (on munmap or > mremap it is not longer needed to track range of virtual address as it > becomes invalid). The only context information consumed in this patch set is MMU_NOTIFY_PROTECTION_VMA. What is the practical benefit of these "optimize out the case when a range is updated to read only" optimizations? Any numbers to show this is worth the code thrash? > > [1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-mmu_notifier-context= ual-information-for-event-triggering-invalidation-v2.patch > > Cc: Christian K=C3=B6nig > Cc: Jan Kara > Cc: Felix Kuehling > Cc: Jason Gunthorpe > Cc: Andrew Morton > Cc: Matthew Wilcox > Cc: Ross Zwisler > Cc: Dan Williams > Cc: Paolo Bonzini > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > Cc: Michal Hocko > Cc: Ralph Campbell > Cc: John Hubbard > Cc: kvm@vger.kernel.org > Cc: dri-devel@lists.freedesktop.org > Cc: linux-rdma@vger.kernel.org > Cc: linux-fsdevel@vger.kernel.org > Cc: Arnd Bergmann > > J=C3=A9r=C3=B4me Glisse (9): > mm/mmu_notifier: contextual information for event enums > mm/mmu_notifier: contextual information for event triggering > invalidation > mm/mmu_notifier: use correct mmu_notifier events for each invalidation > mm/mmu_notifier: pass down vma and reasons why mmu notifier is > happening > mm/mmu_notifier: mmu_notifier_range_update_to_read_only() helper > gpu/drm/radeon: optimize out the case when a range is updated to read > only > gpu/drm/amdgpu: optimize out the case when a range is updated to read > only > gpu/drm/i915: optimize out the case when a range is updated to read > only > RDMA/umem_odp: optimize out the case when a range is updated to read > only > > drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 13 ++++++++ > drivers/gpu/drm/i915/i915_gem_userptr.c | 16 ++++++++++ > drivers/gpu/drm/radeon/radeon_mn.c | 13 ++++++++ > drivers/infiniband/core/umem_odp.c | 22 +++++++++++-- > fs/proc/task_mmu.c | 3 +- > include/linux/mmu_notifier.h | 42 ++++++++++++++++++++++++- > include/rdma/ib_umem_odp.h | 1 + > kernel/events/uprobes.c | 3 +- > mm/huge_memory.c | 14 +++++---- > mm/hugetlb.c | 11 ++++--- > mm/khugepaged.c | 3 +- > mm/ksm.c | 6 ++-- > mm/madvise.c | 3 +- > mm/memory.c | 25 +++++++++------ > mm/migrate.c | 5 ++- > mm/mmu_notifier.c | 10 ++++++ > mm/mprotect.c | 4 ++- > mm/mremap.c | 3 +- > mm/oom_kill.c | 3 +- > mm/rmap.c | 6 ++-- > 20 files changed, 171 insertions(+), 35 deletions(-) > > -- > 2.17.2 >