From patchwork Thu Dec 13 17:13:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10729229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5723414E2 for ; Thu, 13 Dec 2018 17:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C127285B9 for ; Thu, 13 Dec 2018 17:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 304E52C347; Thu, 13 Dec 2018 17:14:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17476285B9 for ; Thu, 13 Dec 2018 17:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729285AbeLMRNo (ORCPT ); Thu, 13 Dec 2018 12:13:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727511AbeLMRNo (ORCPT ); Thu, 13 Dec 2018 12:13:44 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44D5181DE5; Thu, 13 Dec 2018 17:13:43 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-121-185.rdu2.redhat.com [10.10.121.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBBDD60141; Thu, 13 Dec 2018 17:13:36 +0000 (UTC) From: jglisse@redhat.com To: linux-kernel@vger.kernel.org Cc: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , =?utf-8?q?Christi?= =?utf-8?q?an_K=C3=B6nig?= , Jan Kara , Felix Kuehling , Jason Gunthorpe , Andrew Morton , Matthew Wilcox , Ross Zwisler , Dan Williams , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Michal Hocko , Ralph Campbell , John Hubbard , kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-fsdevel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v3 0/3] mmu notifier contextual informations Date: Thu, 13 Dec 2018 12:13:27 -0500 Message-Id: <20181213171330.8489-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 13 Dec 2018 17:13:43 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse Changes since v2: - fix build warning with CONFIG_MMU_NOTIFIER=n - fix make htmldocs warning Changes since v1: - fix build with CONFIG_MMU_NOTIFIER=n - kernel docs Original cover letter: This patchset add contextual information, why an invalidation is happening, to mmu notifier callback. This is necessary for user of mmu notifier that wish to maintains their own data structure without having to add new fields to struct vm_area_struct (vma). For instance device can have they own page table that mirror the process address space. When a vma is unmap (munmap() syscall) the device driver can free the device page table for the range. Today we do not have any information on why a mmu notifier call back is happening and thus device driver have to assume that it is always an munmap(). This is inefficient at it means that it needs to re-allocate device page table on next page fault and rebuild the whole device driver data structure for the range. Other use case beside munmap() also exist, for instance it is pointless for device driver to invalidate the device page table when the invalidation is for the soft dirtyness tracking. Or device driver can optimize away mprotect() that change the page table permission access for the range. This patchset enable all this optimizations for device driver. I do not include any of those in this serie but other patchset i am posting will leverage this. From code point of view the patchset is pretty simple, the first two patches consolidate all mmu notifier arguments into a struct so that it is easier to add/change arguments. The last patch adds the contextual information (munmap, protection, soft dirty, clear, ...). Cheers, Jérôme Cc: Christian König 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čmář Cc: Michal Hocko Cc: Christian Koenig 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érôme Glisse (3): mm/mmu_notifier: use structure for invalidate_range_start/end callback v2 mm/mmu_notifier: use structure for invalidate_range_start/end calls v3 mm/mmu_notifier: contextual information for event triggering invalidation v2 drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 47 ++++----- drivers/gpu/drm/i915/i915_gem_userptr.c | 14 ++- drivers/gpu/drm/radeon/radeon_mn.c | 16 ++- drivers/infiniband/core/umem_odp.c | 20 ++-- drivers/infiniband/hw/hfi1/mmu_rb.c | 13 +-- drivers/misc/mic/scif/scif_dma.c | 11 +- drivers/misc/sgi-gru/grutlbpurge.c | 14 ++- drivers/xen/gntdev.c | 12 +-- fs/dax.c | 15 ++- fs/proc/task_mmu.c | 8 +- include/linux/mm.h | 4 +- include/linux/mmu_notifier.h | 132 ++++++++++++++++++------ kernel/events/uprobes.c | 11 +- mm/hmm.c | 23 ++--- mm/huge_memory.c | 58 +++++------ mm/hugetlb.c | 54 +++++----- mm/khugepaged.c | 11 +- mm/ksm.c | 23 ++--- mm/madvise.c | 22 ++-- mm/memory.c | 103 +++++++++--------- mm/migrate.c | 29 +++--- mm/mmu_notifier.c | 22 ++-- mm/mprotect.c | 16 +-- mm/mremap.c | 11 +- mm/oom_kill.c | 17 +-- mm/rmap.c | 32 +++--- virt/kvm/kvm_main.c | 14 +-- 27 files changed, 406 insertions(+), 346 deletions(-)