From patchwork Mon Dec 3 20:18:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10710505 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 099E01057 for ; Mon, 3 Dec 2018 20:18:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9E832AED3 for ; Mon, 3 Dec 2018 20:18:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D71ED2AF01; Mon, 3 Dec 2018 20:18:35 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2824D2AED3 for ; Mon, 3 Dec 2018 20:18:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DB076B6AE2; Mon, 3 Dec 2018 15:18:34 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 394766B6AE3; Mon, 3 Dec 2018 15:18:34 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 279BE6B6AE4; Mon, 3 Dec 2018 15:18:34 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id F2EE96B6AE2 for ; Mon, 3 Dec 2018 15:18:33 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id k90so14711989qte.0 for ; Mon, 03 Dec 2018 12:18:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=0ic2t/uW5d6/OCCaTMa0OLeMx1o8j6nfCG6xwvIBXS4=; b=AjBZvkI7WRFM0shKpp2/MuurKRTDqAC7+5hwW4AA2UrVCRx9r6zVE95+yrMN2SFi9d PTth1ScGY8XZxvgPE3BmurTS4EsgNmk5SxOvSyXPdTPIShe4IlZzcNBOveadu/TeXgsE gNHYxRct4uOf844ez+ylKXzEhQHzRxvfHyTpgnzNN6daJBzWPHzDLjeX3kkmXH5uGQzi 0DRM8BE7JfA0ckL7WO1kLDxfi0Rip0We+BMDMU9Lenl2bTi+GbTX8Jwp66jvx12Mx6x2 mlXkZ9oYvQgW8rHKC+2HyzSV7hU0ZA0+QM79+KsciblrEOc8UKJ+hJ2B9VXeshL8M9xf 6utg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AA+aEWbF/TztXbOzRPsH0RIpC4B1S2WkxVcjPAiPddSbFVBUb0y+y1ZT oiJ1u0qaeNTP+UWknmj+7+4njIjBVHCa82xZImdc5Da6jFsMLOZmuo2j2wKDdMmZx5dYqJFguNv xIBj50xSqtH4k0FWMqfUb5NYduonmdJmVSOsoQd253R8k4FpAaLtnfIAsHViHFzjZWw== X-Received: by 2002:a0c:ad9a:: with SMTP id w26mr17036480qvc.39.1543868313700; Mon, 03 Dec 2018 12:18:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/WUxksFA7re5Tmo9Jlbcj6LrvgedLEsof7YviOX7BKso5Y16In8oiyLnhitm9Mx/zfbELxE X-Received: by 2002:a0c:ad9a:: with SMTP id w26mr17036450qvc.39.1543868313084; Mon, 03 Dec 2018 12:18:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543868313; cv=none; d=google.com; s=arc-20160816; b=RnrTor8rkMZpUKdXxLFIoqts900M/OZfRVeo9dK8ZBpK0CZmpRVrSl52cVXbvxFWcD 1VPYL8dQfRaZd8xNr3mlPtJ2kv6J85Ze1Lb9TZqUqMOfEVC07TZMfGcrZiLSwAqmdV4e caD4nEZViu/NmUGQiO2JuIuM7ZOYq/g0EJiCCfx9UY3SNtidW3AA62PV7pTyk93C5VqJ C3CQWk8ZVCDZrO1k4XkJKh6BcK8P2H8FrgprtBccGnMwC4im4nj0+typqL5JOVC7YWdk nogFNfwBXxJ0Cs9ksZGJIQYx5WGpnwKazFpg+RXrcsT+FuoYsJBopFg2gYuWn+zap5uP RZhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=0ic2t/uW5d6/OCCaTMa0OLeMx1o8j6nfCG6xwvIBXS4=; b=S71QXU5mJP9oUGHG3kTXwDtCnoQARRQEV61k9QIl/hTuftAsvTq9q0ulx8todQvbGc w83d9yqYmiXqWOXvOvJ3Yx2i/SkvSSomALWa+fJOFPeB0yFpyK4Pa6zpmOUTLbIk7GIP 7Cd3knZARjVqf7b9XBemAonWXP42bMplUJ596Pqr2hBvFDglB3rEbgZwO0VDC/muVTD1 UOnV4gNge1efts6zoZ7EssB3j0bqWx+zFmmq+QXkMP7Zfv+asu/G6Xa8Z+PoEDYEH01I hjlCaOTSGrkHeiffFFt/Z7MRigquiR24N3BhGivF0/+gVn9IITw5Dt3ta86nvvcJ9sQR u+Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id j25si2954361qtr.152.2018.12.03.12.18.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 12:18:33 -0800 (PST) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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?b?SsOpcsO0bWUgR2xpc3Nl?= , Matthew Wilcox , Ross Zwisler , Jan Kara , Dan Williams , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , 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 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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(-)