From mboxrd@z Thu Jan 1 00:00:00 1970 From: jglisse@redhat.com Subject: [PATCH 0/3] mmu notifier contextual informations Date: Mon, 3 Dec 2018 15:18:14 -0500 Message-ID: <20181203201817.10759-1-jglisse@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Sender: linux-kernel-owner@vger.kernel.org To: linux-mm@kvack.org Cc: Andrew Morton , linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Matthew Wilcox , Ross Zwisler , Jan Kara , Dan Williams , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Michal Hocko , Christian Koenig , Felix Kuehling , Ralph Campbell , John Hubbard , kvm@vger.kernel.org, linux-rdma@vger.kernel.org, linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org List-Id: linux-rdma@vger.kernel.org From: Jérôme Glisse 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: Andrew Morton Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Jan Kara Cc: Dan Williams Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Michal Hocko Cc: Christian Koenig Cc: Felix Kuehling Cc: Ralph Campbell Cc: John Hubbard Cc: kvm@vger.kernel.org Cc: linux-rdma@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Jérôme Glisse (3): mm/mmu_notifier: use structure for invalidate_range_start/end callback mm/mmu_notifier: use structure for invalidate_range_start/end calls mm/mmu_notifier: contextual information for event triggering invalidation drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 43 ++++----- 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 | 11 ++- fs/proc/task_mmu.c | 10 ++- include/linux/mm.h | 4 +- include/linux/mmu_notifier.h | 106 +++++++++++++++------- kernel/events/uprobes.c | 13 +-- mm/hmm.c | 23 ++--- mm/huge_memory.c | 58 ++++++------ mm/hugetlb.c | 63 +++++++------ mm/khugepaged.c | 13 +-- mm/ksm.c | 26 +++--- mm/madvise.c | 22 ++--- mm/memory.c | 112 ++++++++++++++---------- mm/migrate.c | 30 ++++--- mm/mmu_notifier.c | 22 +++-- mm/mprotect.c | 17 ++-- mm/mremap.c | 14 +-- mm/oom_kill.c | 20 +++-- mm/rmap.c | 34 ++++--- virt/kvm/kvm_main.c | 14 ++- 27 files changed, 421 insertions(+), 334 deletions(-) -- 2.17.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 916B4C04EB9 for ; Mon, 3 Dec 2018 20:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F77120672 for ; Mon, 3 Dec 2018 20:18:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F77120672 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726007AbeLCUSd (ORCPT ); Mon, 3 Dec 2018 15:18:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36822 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbeLCUSd (ORCPT ); Mon, 3 Dec 2018 15:18:33 -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 EE49B811C0; Mon, 3 Dec 2018 20:18:31 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-122-44.rdu2.redhat.com [10.10.122.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D5876013F; Mon, 3 Dec 2018 20:18:29 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: Andrew Morton , linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Matthew Wilcox , Ross Zwisler , Jan Kara , Dan Williams , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Michal Hocko , Christian Koenig , Felix Kuehling , Ralph Campbell , John Hubbard , kvm@vger.kernel.org, linux-rdma@vger.kernel.org, linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 0/3] mmu notifier contextual informations Date: Mon, 3 Dec 2018 15:18:14 -0500 Message-Id: <20181203201817.10759-1-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.27]); Mon, 03 Dec 2018 20:18:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jérôme Glisse 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: Andrew Morton Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Jan Kara Cc: Dan Williams Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Michal Hocko Cc: Christian Koenig Cc: Felix Kuehling Cc: Ralph Campbell Cc: John Hubbard Cc: kvm@vger.kernel.org Cc: linux-rdma@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Jérôme Glisse (3): mm/mmu_notifier: use structure for invalidate_range_start/end callback mm/mmu_notifier: use structure for invalidate_range_start/end calls mm/mmu_notifier: contextual information for event triggering invalidation drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 43 ++++----- 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 | 11 ++- fs/proc/task_mmu.c | 10 ++- include/linux/mm.h | 4 +- include/linux/mmu_notifier.h | 106 +++++++++++++++------- kernel/events/uprobes.c | 13 +-- mm/hmm.c | 23 ++--- mm/huge_memory.c | 58 ++++++------ mm/hugetlb.c | 63 +++++++------ mm/khugepaged.c | 13 +-- mm/ksm.c | 26 +++--- mm/madvise.c | 22 ++--- mm/memory.c | 112 ++++++++++++++---------- mm/migrate.c | 30 ++++--- mm/mmu_notifier.c | 22 +++-- mm/mprotect.c | 17 ++-- mm/mremap.c | 14 +-- mm/oom_kill.c | 20 +++-- mm/rmap.c | 34 ++++--- virt/kvm/kvm_main.c | 14 ++- 27 files changed, 421 insertions(+), 334 deletions(-) -- 2.17.2