Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755511AbdLOMUS (ORCPT ); Fri, 15 Dec 2017 07:20:18 -0500 Received: from mail-sn1nam01on0081.outbound.protection.outlook.com ([104.47.32.81]:44160 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755477AbdLOMUE (ORCPT ); Fri, 15 Dec 2017 07:20:04 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christian.Koenig@amd.com; Subject: Re: [patch v2 1/2] mm, mmu_notifier: annotate mmu notifiers with blockable invalidate callbacks To: David Rientjes , Andrew Morton Cc: Michal Hocko , Andrea Arcangeli , Benjamin Herrenschmidt , Paul Mackerras , Oded Gabbay , Alex Deucher , David Airlie , Joerg Roedel , Doug Ledford , Jani Nikula , Mike Marciniszyn , Sean Hefty , Dimitri Sivanich , Boris Ostrovsky , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <570af22a-80dd-817f-9e83-b45a6ae3162e@amd.com> Date: Fri, 15 Dec 2017 13:19:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [2a02:908:1251:7981:38f9:6824:e094:2a6] X-ClientProxiedBy: AM5PR0602CA0008.eurprd06.prod.outlook.com (10.175.46.146) To BN6PR12MB1297.namprd12.prod.outlook.com (10.168.227.147) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbf4faa4-568b-421c-11f2-08d543b62b17 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307);SRVR:BN6PR12MB1297; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1297;3:rLmb7BpKeaakuqJed3V+22dUELtSXlIsw/ABp87IE/8JMwZ6Nioa8pONyJKvSaAYNcwDuoct69N/OG6IgxFDDR5xFq/gUolo7p5wVDH+k82Pg2ZNlV23Lnfjkd28ypuNi4QyFn14zgK7cV7V6ttBcNYYRdnh3A2E0j0w1bCvwL39bB2V5hxyVgENyDdha8TH/KnCbyI6b4yfmgyntpgdOjHBdjr0KaqsdY/iHF1db0BBkmYzXEHzkzQ9MizxQKox;25:lHP1Aq6Gau7mhiGJiHPIJNvJuLSKwZKf6L0a9yWOAcg1W10Qe0LbogJOSnvgtxEUu7OKe9aAKnBmg5Vsy0JPO3xiTbpJ6e8zVltNMygnqlegkwu8zHBqwxPweknsZlObmCAQm15T8Xkbxfkwibi7Y/G2Schwj1SEoxS2vLrT7z8cQ5G27qeNLTUSnpo4WhdpgLdvV0QQU0xVRTV5CR0EIx93DSuTxVHa/THL18bn8A0PhTHRRsrOi3kQ6ZjdpilsRq+ujGPxxXpUOBPXNMKuiuiEBMGRAj0NATRlvvSfm8tCs9zDQ6hsppVQoPXJ1AWCxJvA6Nt5pUZ4DKLJqdL55abvNLrra5DvewOJgDGKbhs=;31:GPqYmIJK3sB3yiniFzAH3vjVAZsWjyUIxIjD4a+fYVm3MgQSIaRO/gtYeP5q9V0f+ZIJ2VF8ddO6f0xqB7wfIcRjBG7/gEw55y6kbPlibxXyeT/BdN+f7XZ2lyZfY8L6NjOX3NjpKwm/gSorc+3dmS/YgT3L3GqbinxAEJrAtKebJac3D0ZL2yHbEFf7kblqL62INBe7i1h71HxFdFIfyptLzb2eg64cEUsRMmtSSk0= X-MS-TrafficTypeDiagnostic: BN6PR12MB1297: X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1297;20:jOgofUUapIE2AlPx8zTuW0nP+cTU691QYwLm3z4fVtgKd67nh7a/Sx0g15Kd7yHOstlC3v1drZN7iY7RemOtji7/jNtlTzv4yD4JN5/W0UTxQfJj+uKpActBgRLPkDs9Jms7rHP9HNqDrEWwjrRAUoHjXsInmxyY3l4/ws8WwFUnsNBnmZyddxUK2cyp/aO5CyD1bacP92roPw1gbdxWFisiJ7gvoPUux5i3jZkfwpglNCBXmvkygkE6af2agH5+I6P0gPzo5NVB03KNTvhiy/xVWpd5D5ohe/FxbErVe6gNaEE2ngbqQg1EFMtZY9KMOObgh3YnFgtpDW0EozlzwurJxxGVpM5Z5XQmu9w9Vy0+ixWxBQrHZvL9LY9S4goxy3U/Sr5NHSoZD7NyE2C1VFDp62InzdXl8DXoVJtnFDAW6pbJKNpZsMQVP3ToJjTADkymUOLrBu7E03o6r/bawmFioc7Lo19WiWmnNxKAMIyHt923JdBRtR6thR8w7aQt;4:YQTa+YKE+2EwOYhpOj9TJXYCVWTHaKlGS607eeoOF87TgFxIyaE9WM/jivDizM+f6mRfok0fAI7emjTOchgjhdGtp1W2wfhFAbb9ZfDvCuzPDgmDeGniT1H0u0y1PNVTv7/dZAPO03j4TdCht41ONdQVUgSzPzWC3799SyDA49ycNT2fViTUQIGiDxKs7F22Q6JwyXFCBkRmsUsadPnOnpWPbGMUvsYZ9Kmyx4QCsY7/nEE+ekwY/620B0CeKAEL/uoF5q02Ji2px2Rs945L6nSCHtWXeSkubk+mt7cyH/CW0GsgiUDRW7Feh8drBKYe1uKYugmgf3LD8eGBPO7Nu0FKbwrpfAJxy5kWBRhAQlpOHZ656FbNuBPPUh8itfI6 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(211936372134217)(153496737603132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231023)(920507027)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(6072148)(201708071742011);SRVR:BN6PR12MB1297;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BN6PR12MB1297; X-Forefront-PRVS: 05220145DE X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(366004)(346002)(396003)(39860400002)(199004)(189003)(305945005)(7736002)(52116002)(76176011)(59450400001)(34040400001)(106356001)(2950100002)(65806001)(65956001)(1706002)(25786009)(110136005)(65826007)(81156014)(58126008)(81166006)(8676002)(83506002)(36756003)(2486003)(52146003)(386003)(105586002)(54906003)(6666003)(97736004)(67846002)(23676004)(47776003)(7416002)(52396003)(86362001)(316002)(478600001)(6116002)(6486002)(31686004)(31696002)(229853002)(2870700001)(64126003)(2906002)(4326008)(53936002)(5660300001)(39060400002)(8936002)(72206003)(50466002)(68736007)(6246003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1297;H:[IPv6:2a02:908:1251:7981:38f9:6824:e094:2a6];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMjk3OzIzOjdRL3Z1RXB0Wm10UWFvdG9IZmVSWTYwTHB5?= =?utf-8?B?YU9tRFBBL1FaNDB2cEwrNXdhb2JWVXhPSTY1RlNwMG0ybVFJNE56VjdaZTFi?= =?utf-8?B?K1hBTzN5eEVtWk9sdnl5Y0FoZzBiZWI1MmkydGdVdk9vQWk2ZHh2WXUzdURl?= =?utf-8?B?UHlGNWVpSHlXcW4zMlZkV2FHRzRzUVMvOFpiS3IydExwMTQ5YldIY3B6Qjk3?= =?utf-8?B?ZnN0bDNyRE0xWGJQMElxNzVrYTF5aVhaMDIwM0dYNm4rRE1UZExoUS9TNFlo?= =?utf-8?B?Nit1UkZKc1hodkYxMWM0OTBvN2lseG5zdnVtYVZpbWpjZytsaXFBVWRiSUVL?= =?utf-8?B?d0F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adn9o+uMXUl6bcvP1iQAvMHO9Wejk7TTb8wD/QECl9SP3X0ik9ADvKDdPkhe1cFVQcKBgOzKqg29CP9jtmOtbfpAO+sIHFQ=;5:ytGaQTrBQV4OKV5GxseGKMvKlTsHOpnMWE9P+huwLDExXUju5jwQbzlUBw2c3vZ/7Sr+iciHHZaOUWlcVgy+VS+zFjeobnsPc7XtyzwzYc4ekm4lWzAcJmqNsXDj33KSe0BKwb6nndgXOevMU7HXS8MEYbC5Si0yrCZtPb5pAGM=;24:rpTvLeo/uSps2zjGjanhtSD4sZXUeJlNJEEwUJjR1s+yMjkZTuR4/SQTHQqCmQFWYx34eoRxYBYy1VLp5UJV4Grxt6RCIFsKAegc+WxSxRc=;7:AWxUCGOiR+usYqCJbcnIKTN0lIdaMvEnuxNqQDlufbhkqLIzuRjsNj/RXV60d+Qbe1tCygcqOztdPhE6VQmgRPb3gzlh19/ZE+tm5JW8dFtQyTeRWCoJOcS5BEYp3K4Ya6bd3O3gfgShtG/9v1L9tTufiJehAaAGNRUeNbyuUBXw+3PV6jVDzM6bLHBJyzfQuhOWMqLkKnEhpWLAP92VdcHb1CsxXdQb/gpC66nKlxmbj9Ow2TKl3qkqKKFlZjqX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1297;20:o0vJfW/K2dAfFtQ0lr8r89z5rBnQA91hZttp4uqrYqzj7KHxMbGVJ/c0yYcz3h+fFSOYTOyyyHpKGTxhBeIxTUnGNZtrLd5dHOmzYx8NSOOor1baGjG8e069fjH1X3o8ynTWvmnTiCmYIS5wxii4Y4M8CVbZxexwLj2ejQ1Lm6YZUAjdwqv21mwiU9EPEhh8l0iP6TYSLvL6NK7y9DyQP2A922FF9O3TWkF28kythJB+uEboaaF9lmCOkaE6T1Ax X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2017 12:19:59.1490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbf4faa4-568b-421c-11f2-08d543b62b17 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1297 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7312 Lines: 192 Am 14.12.2017 um 22:30 schrieb David Rientjes: > Commit 4d4bbd8526a8 ("mm, oom_reaper: skip mm structs with mmu notifiers") > prevented the oom reaper from unmapping private anonymous memory with the > oom reaper when the oom victim mm had mmu notifiers registered. > > The rationale is that doing mmu_notifier_invalidate_range_{start,end}() > around the unmap_page_range(), which is needed, can block and the oom > killer will stall forever waiting for the victim to exit, which may not > be possible without reaping. > > That concern is real, but only true for mmu notifiers that have blockable > invalidate_range_{start,end}() callbacks. This patch adds a "flags" field > to mmu notifier ops that can set a bit to indicate that these callbacks do > not block. > > The implementation is steered toward an expensive slowpath, such as after > the oom reaper has grabbed mm->mmap_sem of a still alive oom victim. > > Signed-off-by: David Rientjes Acked-by: Christian König > --- > v2: > - specifically exclude mmu_notifiers without invalidate callbacks > - move flags to mmu_notifier_ops per Paolo > - reverse flag from blockable -> not blockable per Christian > > drivers/infiniband/hw/hfi1/mmu_rb.c | 1 + > drivers/iommu/amd_iommu_v2.c | 1 + > drivers/iommu/intel-svm.c | 1 + > drivers/misc/sgi-gru/grutlbpurge.c | 1 + > include/linux/mmu_notifier.h | 21 +++++++++++++++++++++ > mm/mmu_notifier.c | 31 +++++++++++++++++++++++++++++++ > virt/kvm/kvm_main.c | 1 + > 7 files changed, 57 insertions(+) > > diff --git a/drivers/infiniband/hw/hfi1/mmu_rb.c b/drivers/infiniband/hw/hfi1/mmu_rb.c > --- a/drivers/infiniband/hw/hfi1/mmu_rb.c > +++ b/drivers/infiniband/hw/hfi1/mmu_rb.c > @@ -77,6 +77,7 @@ static void do_remove(struct mmu_rb_handler *handler, > static void handle_remove(struct work_struct *work); > > static const struct mmu_notifier_ops mn_opts = { > + .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, > .invalidate_range_start = mmu_notifier_range_start, > }; > > diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c > --- a/drivers/iommu/amd_iommu_v2.c > +++ b/drivers/iommu/amd_iommu_v2.c > @@ -427,6 +427,7 @@ static void mn_release(struct mmu_notifier *mn, struct mm_struct *mm) > } > > static const struct mmu_notifier_ops iommu_mn = { > + .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, > .release = mn_release, > .clear_flush_young = mn_clear_flush_young, > .invalidate_range = mn_invalidate_range, > diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c > --- a/drivers/iommu/intel-svm.c > +++ b/drivers/iommu/intel-svm.c > @@ -276,6 +276,7 @@ static void intel_mm_release(struct mmu_notifier *mn, struct mm_struct *mm) > } > > static const struct mmu_notifier_ops intel_mmuops = { > + .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, > .release = intel_mm_release, > .change_pte = intel_change_pte, > .invalidate_range = intel_invalidate_range, > diff --git a/drivers/misc/sgi-gru/grutlbpurge.c b/drivers/misc/sgi-gru/grutlbpurge.c > --- a/drivers/misc/sgi-gru/grutlbpurge.c > +++ b/drivers/misc/sgi-gru/grutlbpurge.c > @@ -258,6 +258,7 @@ static void gru_release(struct mmu_notifier *mn, struct mm_struct *mm) > > > static const struct mmu_notifier_ops gru_mmuops = { > + .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, > .invalidate_range_start = gru_invalidate_range_start, > .invalidate_range_end = gru_invalidate_range_end, > .release = gru_release, > diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h > --- a/include/linux/mmu_notifier.h > +++ b/include/linux/mmu_notifier.h > @@ -10,6 +10,9 @@ > struct mmu_notifier; > struct mmu_notifier_ops; > > +/* mmu_notifier_ops flags */ > +#define MMU_INVALIDATE_DOES_NOT_BLOCK (0x01) > + > #ifdef CONFIG_MMU_NOTIFIER > > /* > @@ -26,6 +29,15 @@ struct mmu_notifier_mm { > }; > > struct mmu_notifier_ops { > + /* > + * Flags to specify behavior of callbacks for this MMU notifier. > + * Used to determine which context an operation may be called. > + * > + * MMU_INVALIDATE_DOES_NOT_BLOCK: invalidate_{start,end} does not > + * block > + */ > + int flags; > + > /* > * Called either by mmu_notifier_unregister or when the mm is > * being destroyed by exit_mmap, always before all pages are > @@ -137,6 +149,9 @@ struct mmu_notifier_ops { > * page. Pages will no longer be referenced by the linux > * address space but may still be referenced by sptes until > * the last refcount is dropped. > + * > + * If both of these callbacks cannot block, mmu_notifier_ops.flags > + * should have MMU_INVALIDATE_DOES_NOT_BLOCK set. > */ > void (*invalidate_range_start)(struct mmu_notifier *mn, > struct mm_struct *mm, > @@ -218,6 +233,7 @@ extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm, > bool only_end); > extern void __mmu_notifier_invalidate_range(struct mm_struct *mm, > unsigned long start, unsigned long end); > +extern int mm_has_blockable_invalidate_notifiers(struct mm_struct *mm); > > static inline void mmu_notifier_release(struct mm_struct *mm) > { > @@ -457,6 +473,11 @@ static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, > { > } > > +static inline int mm_has_blockable_invalidate_notifiers(struct mm_struct *mm) > +{ > + return 0; > +} > + > static inline void mmu_notifier_mm_init(struct mm_struct *mm) > { > } > diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c > --- a/mm/mmu_notifier.c > +++ b/mm/mmu_notifier.c > @@ -236,6 +236,37 @@ void __mmu_notifier_invalidate_range(struct mm_struct *mm, > } > EXPORT_SYMBOL_GPL(__mmu_notifier_invalidate_range); > > +/* > + * Must be called while holding mm->mmap_sem for either read or write. > + * The result is guaranteed to be valid until mm->mmap_sem is dropped. > + */ > +int mm_has_blockable_invalidate_notifiers(struct mm_struct *mm) > +{ > + struct mmu_notifier *mn; > + int id; > + int ret = 0; > + > + WARN_ON_ONCE(down_write_trylock(&mm->mmap_sem)); > + > + if (!mm_has_notifiers(mm)) > + return ret; > + > + id = srcu_read_lock(&srcu); > + hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) { > + if (!mn->ops->invalidate_range && > + !mn->ops->invalidate_range_start && > + !mn->ops->invalidate_range_end) > + continue; > + > + if (!(mn->ops->flags & MMU_INVALIDATE_DOES_NOT_BLOCK)) { > + ret = 1; > + break; > + } > + } > + srcu_read_unlock(&srcu, id); > + return ret; > +} > + > static int do_mmu_notifier_register(struct mmu_notifier *mn, > struct mm_struct *mm, > int take_mmap_sem) > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -476,6 +476,7 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn, > } > > static const struct mmu_notifier_ops kvm_mmu_notifier_ops = { > + .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, > .invalidate_range_start = kvm_mmu_notifier_invalidate_range_start, > .invalidate_range_end = kvm_mmu_notifier_invalidate_range_end, > .clear_flush_young = kvm_mmu_notifier_clear_flush_young,