Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp1900345imc; Fri, 22 Feb 2019 13:25:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IaBQADwHvC9IlUaoZN+yJCrujuDhKbQ4K1VkLo4kHo4Mlz+wuaua/cLzSCNGIYqLpGGXrmQ X-Received: by 2002:a63:81c7:: with SMTP id t190mr5979880pgd.166.1550870742902; Fri, 22 Feb 2019 13:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550870742; cv=none; d=google.com; s=arc-20160816; b=fIp7PaNTvG3kSpcDNT+6nLx82myH3/Ri6GzFFYUHXzwqKobsA13aMsG7A04meAb7HU zyYUblfQh8EzVczmz2PT6dNA5th5iWfILm7UEVHwTGUd31Uuzh9pj3kZZtSWR2MTqvjP aQZfIuBMj+4fFD5HUs749BM0MQ7182yaDls4q4SADrkIPbKKHuHILnQgdeFHVBy+WZQh a5g6tEQEFwirnXfwRpZbwZ3XbhHZEIO06NLTu01tC9gnoKNX4lhwP6nLSyAngEiH5Em4 sxz0baNbsizu78Rj8MmWGWtR+ehGLaEkOMB0T0U3yJU26lEr6K6o5ifZqimDY6WRP+11 vA3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=9karIuIHg1vtBYYf1M4HNuL4qkqDIYWqZ2VdtX6a7DQ=; b=bK4xs2QOHF/zU2Z5yqrJzl6NQ/rr99nrNt7Zmv82UtwO7p9ISK4QNRUXM5S/YUwBOK rKvjM61UDsGGWwQvi6MBo1o2b5ggDIN7FRulgYz7Lr/GFG4/n6F5g4iwIzMP+ZTbkNaB gW91pv3y52cWglPq0G21P73WqmwKJatXzYJoxproX1K7Li4aZzkzHV6+qUI9vnqRc+uT o8pd2nKB7+Ii+OiPRt2INfZ6MCk8CRcjf7eCdOl6hJo9OQveYCNKlZWIfTmyGAtZiOEu VTx8TNcyzaoHmDLn6nfwMO8LlCo/2bSmLHXGK8ArwBaRpIxxYrIO6VoPERcroS0CBcUf GOUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=NHGD06wb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h8si1787717pgq.35.2019.02.22.13.25.26; Fri, 22 Feb 2019 13:25:42 -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=@nvidia.com header.s=n1 header.b=NHGD06wb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726035AbfBVVZH (ORCPT + 99 others); Fri, 22 Feb 2019 16:25:07 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:13110 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfBVVZG (ORCPT ); Fri, 22 Feb 2019 16:25:06 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 22 Feb 2019 13:25:10 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Fri, 22 Feb 2019 13:25:04 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 22 Feb 2019 13:25:04 -0800 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 22 Feb 2019 21:25:04 +0000 Subject: Re: [PATCH v5 5/9] mm/mmu_notifier: contextual information for event triggering invalidation v2 To: , , Andrew Morton CC: , =?UTF-8?Q?Christian_K=c3=b6nig?= , Joonas Lahtinen , Jani Nikula , Rodrigo Vivi , Jan Kara , Andrea Arcangeli , Peter Xu , Felix Kuehling , Jason Gunthorpe , Ross Zwisler , Dan Williams , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Michal Hocko , John Hubbard , , , , Arnd Bergmann References: <20190219200430.11130-1-jglisse@redhat.com> <20190219200430.11130-6-jglisse@redhat.com> From: Ralph Campbell Message-ID: Date: Fri, 22 Feb 2019 13:25:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20190219200430.11130-6-jglisse@redhat.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1550870710; bh=9karIuIHg1vtBYYf1M4HNuL4qkqDIYWqZ2VdtX6a7DQ=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=NHGD06wbFMzk6wx9UJ7KfOSbOHtmisry4usVAC/d5jMIwrQINwkIMVLDHUje0FHQ/ tm8t1YP0WB13tAdYQAClqrzZsDpUQH7ViUlKqfVD3GiJGu6gNyDHR/mBFkuKAymwko 0wk/aC9Q12UAb7EjawB0lZ/OuNzYbsSbRUUgdshlbsMxrVC8hfWX4vkMsVF1MxOowJ ZoVAOL2P377kVPt6u8k9wu7bV8oI/w2n7e/xQ0WDTaTNna9581oyDRx3agYAWAJDeS lR+6lndK1PDhrfsVuhsuunw/ngZGJSEdrpBVsCzTmA7q2LG6G37DBIg+EyIs7XjAoR P6x4OHlTH5aoA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/19/19 12:04 PM, jglisse@redhat.com wrote: > From: J=C3=A9r=C3=B4me Glisse >=20 > 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, > ...). >=20 > Users of mmu notifier API track changes to the CPU page table and take > specific action for them. While current API only provide range of virtual > address affected by the change, not why the changes is happening. >=20 > This patchset do the initial mechanical convertion of all the places that > calls mmu_notifier_range_init to also provide the default MMU_NOTIFY_UNMA= P > event as well as the vma if it is know (most invalidation happens against > a given vma). Passing down the vma allows the users of mmu notifier to > inspect the new vma page protection. >=20 > The MMU_NOTIFY_UNMAP is always the safe default as users of mmu notifier > should assume that every for the range is going away when that event > happens. A latter patch do convert mm call path to use a more appropriate > events for each call. >=20 > Changes since v1: > - add the flags parameter to init range flags >=20 > This is done as 2 patches so that no call site is forgotten especialy > as it uses this following coccinelle patch: >=20 > %<---------------------------------------------------------------------- > @@ > identifier I1, I2, I3, I4; > @@ > static inline void mmu_notifier_range_init(struct mmu_notifier_range *I1, > +enum mmu_notifier_event event, > +unsigned flags, > +struct vm_area_struct *vma, > struct mm_struct *I2, unsigned long I3, unsigned long I4) { ... } >=20 > @@ > @@ > -#define mmu_notifier_range_init(range, mm, start, end) > +#define mmu_notifier_range_init(range, event, flags, vma, mm, start, end= ) >=20 > @@ > expression E1, E3, E4; > identifier I1; > @@ > <... > mmu_notifier_range_init(E1, > +MMU_NOTIFY_UNMAP, 0, I1, > I1->vm_mm, E3, E4) > ...> >=20 > @@ > expression E1, E2, E3, E4; > identifier FN, VMA; > @@ > FN(..., struct vm_area_struct *VMA, ...) { > <... > mmu_notifier_range_init(E1, > +MMU_NOTIFY_UNMAP, 0, VMA, > E2, E3, E4) > ...> } >=20 > @@ > expression E1, E2, E3, E4; > identifier FN, VMA; > @@ > FN(...) { > struct vm_area_struct *VMA; > <... > mmu_notifier_range_init(E1, > +MMU_NOTIFY_UNMAP, 0, VMA, > E2, E3, E4) > ...> } >=20 > @@ > expression E1, E2, E3, E4; > identifier FN; > @@ > FN(...) { > <... > mmu_notifier_range_init(E1, > +MMU_NOTIFY_UNMAP, 0, NULL, > E2, E3, E4) > ...> } > ---------------------------------------------------------------------->% >=20 > Applied with: > spatch --all-includes --sp-file mmu-notifier.spatch fs/proc/task_mmu.c --= in-place > spatch --sp-file mmu-notifier.spatch --dir kernel/events/ --in-place > spatch --sp-file mmu-notifier.spatch --dir mm --in-place >=20 > Signed-off-by: J=C3=A9r=C3=B4me Glisse > Cc: Christian K=C3=B6nig > Cc: Joonas Lahtinen > Cc: Jani Nikula > Cc: Rodrigo Vivi > Cc: Jan Kara > Cc: Andrea Arcangeli > Cc: Peter Xu > Cc: Felix Kuehling > Cc: Jason Gunthorpe > Cc: Ross Zwisler > Cc: Dan Williams > Cc: Paolo Bonzini > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > 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: Arnd Bergmann > --- Reviewed-by: Ralph Campbell