From patchwork Wed Feb 26 13:22:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13992393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 889FAC18E7C for ; Wed, 26 Feb 2025 13:23:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 280B1280044; Wed, 26 Feb 2025 08:23:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 22E6528000C; Wed, 26 Feb 2025 08:23:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F27E1280044; Wed, 26 Feb 2025 08:23:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D007E28000C for ; Wed, 26 Feb 2025 08:23:12 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 91F0452DDC for ; Wed, 26 Feb 2025 13:23:12 +0000 (UTC) X-FDA: 83162161824.11.1FD9013 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 3A76A1C0021 for ; Wed, 26 Feb 2025 13:23:10 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hhKOPxJG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740576190; a=rsa-sha256; cv=none; b=T5gKIZo5YaxD+YFiulAn7pYxwb/nxAxxw8Z7Z1j27apY0f3J+SB35hEzYRHO8Qvx2lPeiS AYdz1A4bFLlrg4nGolu921krkjm5uZHS927UGR4otoleeF2qF9baXbXHXWhBkrT77a/XCl 7ARhBtMiWxB7ycdllMe9fDINwFhtPHY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hhKOPxJG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740576190; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3ayxqWdfZtpuuFLEW5/IWnRh3wjbr3t43oqj3ksvw18=; b=49yQTbDv9oYPh1vvmAlDRinEppY2JZaGCssNhh7ulnSH0adUCB2VsP6LNNtkhEBXOzY1EY /Z9HSffc+cELinaq7ca8AHllxTmrWdfxjGMpzIMwAVFjkwwG4JO8MlduRv9ZWqNSWz0FxE C80vOtABfpUVBmfPtzHvuM5ggoWt2/A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740576189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3ayxqWdfZtpuuFLEW5/IWnRh3wjbr3t43oqj3ksvw18=; b=hhKOPxJGdL0GIhIzwxv18RnrHddJ8xaDj4k0TJ88SQ68pXL/b8xFIeMA2zi2F2HNQPS7eG 1Z2duhmG6YSfXTZcN6sECuzVp6TbQwzk0XRZcuSC7RMHai/gUiv8i9ZdZcw+q8UddjqE9b 40WgQI1OgS0h40WQ2Ktq9HdB1ZnJkYc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-442-3TPIHrwhPw2kdb4gyPjKBg-1; Wed, 26 Feb 2025 08:23:08 -0500 X-MC-Unique: 3TPIHrwhPw2kdb4gyPjKBg-1 X-Mimecast-MFC-AGG-ID: 3TPIHrwhPw2kdb4gyPjKBg_1740576187 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43945f32e2dso62331255e9.2 for ; Wed, 26 Feb 2025 05:23:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740576187; x=1741180987; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3ayxqWdfZtpuuFLEW5/IWnRh3wjbr3t43oqj3ksvw18=; b=NEvK/T++u8GM7pXoFHfKZZfNet4VrWSTbtmpSVNTDwyOhsCvfxB6+MWmQ1SX7tVitW eJneL5qnL+tqV2zCQM/tG0SPpqxfEi8cu+TXoO6pw9gKl7eZFtA1QuSXAZQBrd8C7i0l 7V3CqvmTdbMvxlQgaGVB3RYEI3ESXOOKRDQkIKh0gS5p9yEpvYcTMqorWcDNGYwd4GKa JHvtpuiEIjR5F+1k+1GfGcJHNezNYhDZiwkEbbrx0rhHd94jcXoguc1IjyTaiTU8xqTp Vbsubfy48mVzl11jjI70zbMySaTw4DVKRirowe085O7Q+ZFvBG3YIMj/Xl12bl6u6H4s AIqw== X-Gm-Message-State: AOJu0YyPq97UJB4qw0yVorWfE8BqIe/oOV5eYZc75VmJ4BTFubGAj+jO TKsQ6pVwSeWC6SphlXa9Y4VXxeMkQqYfQ0XL6ZIDYOOTQnFS46IfoUDFYWhCgLYlrT94vZkjuoU NxNe4UPEsKJpaLs1iG1/upMG2wp0ur1+H7WNFsiekGta4stXX X-Gm-Gg: ASbGncs+3NjdbcbmxFIlwQts0puH5VvB8uafy+kJ0U+oUaOv6Dpb/9SpC+qSaeGheuT KPoZVylqrp5I8gM/K6K86e4kLlH0SbDvH/9Cgm1N9tiAp2o6xC3uPqzbdxw5FByDX8tkJ0Gvqcs K8PJCSX9ofzTGP35vswNJQ1HyEBPI92CTZXbdTwUUN+KbXY51sgwcVZGmMEoLijZhXbumB+ENZ0 gRosZqglSzGSm62dNemAYy5gnoZe4lRGvVtOED9SRwSE6v+zrXqBFvLGqh6kN5kiAJfKzZMzBr/ Q2Ir0Kc7W0kwyvO/pEdk/XdBQW8cLXKUkkkZpNs77C99CAcmSdp5rsONbXBEsWS30IbWN3lepbL 9 X-Received: by 2002:a05:600c:1d1a:b0:439:916a:b3db with SMTP id 5b1f17b1804b1-43ab0f28872mr74312535e9.6.1740576187157; Wed, 26 Feb 2025 05:23:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZecayt4WE/OXHMqhCrGeiiVFvJ2H3x+MAoGPf+DIopmjwISLHjYgRgetExDyOwLcEx7l8uw== X-Received: by 2002:a05:600c:1d1a:b0:439:916a:b3db with SMTP id 5b1f17b1804b1-43ab0f28872mr74312325e9.6.1740576186833; Wed, 26 Feb 2025 05:23:06 -0800 (PST) Received: from localhost (p200300cbc747ff009d854afba7df6c45.dip0.t-ipconnect.de. [2003:cb:c747:ff00:9d85:4afb:a7df:6c45]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-43aba544029sm21379795e9.29.2025.02.26.05.23.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Feb 2025 05:23:06 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Simona Vetter , Alistair Popple , Jason Gunthorpe Subject: [PATCH v2 5/5] mm/mmu_notifier: use MMU_NOTIFY_CLEAR in remove_device_exclusive_entry() Date: Wed, 26 Feb 2025 14:22:57 +0100 Message-ID: <20250226132257.2826043-6-david@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250226132257.2826043-1-david@redhat.com> References: <20250226132257.2826043-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mK27Cq-F2uc3oFHvODPrBoOpKyvZfkDU932s7HtscDY_1740576187 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspam-User: X-Rspamd-Queue-Id: 3A76A1C0021 X-Rspamd-Server: rspam12 X-Stat-Signature: gsjpthf7e9i8weyhj7ome8uehcpno1i9 X-HE-Tag: 1740576190-989901 X-HE-Meta: U2FsdGVkX183Rfc28X536KJ5/cPftSGcb8Cv+QP2KV7r66A4VDRNwBzXL06hv0vihiLPR4CrcK5QrDBQPlML7SI0BERlEea0BCzAsE7QSJV4tMgKN1ogqgf35vebgn6QIrbTdpenZr0rxVKrJRhFjeCKpO8buCgHaroyF/j+wk/o7oNyZZHH0DRzmBXnX3SgjQdPJGsvb81r3VU2Y1sw+It5ZU3WExW1bVz4VYyFEKTRFQi0tAj+prUlOfvqxlhZegO8AJG2NC+I7l/4Eku8DUGrBebBlaX/ZwVcmIy2kUhY4WwIAvWfAa9ZMCN60m0MHtDB5y3wgX17JxQJVxS0ZHZ1HDFAhXtOe0RoEQZfrWoztdDdqqKhJPQMCEIzdmxgpgzhCiU+aZTeYi3Fo8/PpeRmIo0aT5Z+qoM3njjalEFH3rS+FPJxOFwTa8F4hb2R3aEorKd2uS9E3I6AlBhCS8UUrhQqA1D+nwIKk826/IjmU4RWRJgiukf2S1Uw7ZElo4T7o8tTUlveVLK8UhqPCF+8dqOjfHXcUeTtxRJdN0gvvtdc1qQelbImmN6SI25zaY12uMcKKPoVGan1qj2BMecUyu1DY0yayPYblO/tjGEVEp/rG6NXYaMAexNOPfq1yUsV7ZVeigB4icoH6MIT0TTbmCGYKAZMi9ujFbQUDVfyAuoMP7SWv9T1FJrK5HjxdnVwbINO6sfDI1QYLUgRqH7KZTgY676QYLIMmDGQ9T8EXg8tKwbfta4ax8Zf6TKYJdfPJuQOIAfkDuNh/BpF0147Dkm8dKvhMMj4cY9DPu906ikztHzYFEMs3sXLEI51CQUcGz8nlVrpAEg6/72srUK8hYHZnmk7gMDtpPfGLqFa11+fb4e/h6qfclIN00Z64ak+MJ6WKa7yKmg5SXtJ8UpsdXO2HEGeeYJnPpe2DRlWKlKrDogtZDtvlWPGAgjAwcDyG82+ZrGW/Sj3wh9 QqwwUaT3 402oQjGkUPoFkafbavBuQ+ZkTS/0ho8EsthB4B/QElwuVYgbEopWlGMtn6AHiWtEN2ewdzL83Ki5vDN2OqLRMfk+TqFkbFdHk/RwsLcTKxalPiE/q1/jqCpjw5dG0XauUne+2Qg+9ufBVPI+7HabpwEtSNArbolpUkY4796sxiTB4BKIBKPqW20a/iKaFVFU3xkcI+4xmjcIc9muyLE2Wk8We2ZmWtcxDXY1risbWSj0lOzgpPiluHkUAfXnZRRV2l9DU3rpUFSAAsCEPgNkRq6+br+nVYfCMlo1A3KK+0a5TJ423gwl+yekN5+LdbO/YgsM0XY6PCm4+/W9oLqeTQwpdqqnCHQ0l1d+Sz9TTENdNbBmFx214+lWO7fFmCGVhCyOA0roylnsc+KhUUFTcEGeIEcW31Iz5A3F7S++RmMKBAtY5pURq3zXLwpTkZU6ABUbJawt4v27DMDf8P7uKyfAdyJa0JuGKGiIV0z1a4mSF05DtCVWn5kwAS6isiZa3+Zt+ehnL++2mC4kW0rtPPKkLoQ== 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: List-Subscribe: List-Unsubscribe: Let's limit the use of MMU_NOTIFY_EXCLUSIVE to the case where we convert a present PTE to device-exclusive. For the other case, we can simply use MMU_NOTIFY_CLEAR, because it really is clearing the device-exclusive entry first, to then install the present entry. Update the documentation of MMU_NOTIFY_EXCLUSIVE, to document the single use case more thoroughly. If ever required, we could add a separate MMU_NOTIFY_CLEAR_EXCLUSIVE; for now using MMU_NOTIFY_CLEAR seems to be sufficient. Signed-off-by: David Hildenbrand --- include/linux/mmu_notifier.h | 8 ++++---- mm/memory.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index d4e7146618262..bc2402a45741d 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -43,10 +43,10 @@ struct mmu_interval_notifier; * a device driver to possibly ignore the invalidation if the * owner field matches the driver's device private pgmap owner. * - * @MMU_NOTIFY_EXCLUSIVE: to signal a device driver that the device will no - * longer have exclusive access to the page. When sent during creation of an - * exclusive range the owner will be initialised to the value provided by the - * caller of make_device_exclusive(), otherwise the owner will be NULL. + * @MMU_NOTIFY_EXCLUSIVE: conversion of a page table entry to device-exclusive. + * The owner is initialized to the value provided by the caller of + * make_device_exclusive(), such that this caller can filter out these + * events. */ enum mmu_notifier_event { MMU_NOTIFY_UNMAP = 0, diff --git a/mm/memory.c b/mm/memory.c index 50a305d7efcb9..79acd2d95dcff 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4046,7 +4046,7 @@ static vm_fault_t remove_device_exclusive_entry(struct vm_fault *vmf) folio_put(folio); return ret; } - mmu_notifier_range_init_owner(&range, MMU_NOTIFY_EXCLUSIVE, 0, + mmu_notifier_range_init_owner(&range, MMU_NOTIFY_CLEAR, 0, vma->vm_mm, vmf->address & PAGE_MASK, (vmf->address & PAGE_MASK) + PAGE_SIZE, NULL); mmu_notifier_invalidate_range_start(&range);