From patchwork Wed Jan 29 11:58:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13953690 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 C4BB0C02190 for ; Wed, 29 Jan 2025 11:58:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54FAA2801BC; Wed, 29 Jan 2025 06:58:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FF8928005A; Wed, 29 Jan 2025 06:58:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A0982801BC; Wed, 29 Jan 2025 06:58:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 19CA128005A for ; Wed, 29 Jan 2025 06:58:37 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2B03BC0E0A for ; Wed, 29 Jan 2025 11:58:18 +0000 (UTC) X-FDA: 83060341518.01.F60FBFF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id DC8C114000B for ; Wed, 29 Jan 2025 11:58:15 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gyDacMND; spf=pass (imf09.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738151895; 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=b7tz66Q1mh6b9biGlGMq1Dqed0aye0/ijzbhQ2yLKo0=; b=4f6BvCYA9dwO+qwtlxJV6J3aGi0fFCd7SBLqapqCOzlz0Du8A1Olw0+gP+nCf8SM/uo5E6 bygTdShcMoJ05kfs7DYVP5cotKvL/AhWGBEa5/VMtSXTE5pTt7xlVXMvOJiQfPLbw5Odcv xRoa2fN6Ugwri9HVuskGl0QpUQlPF90= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738151895; a=rsa-sha256; cv=none; b=tb98/oG0pNhFF7JOESlIoo3mQ1H6Y5xoCCOU550IdXEwU9urUwt96lddkimjEFWHQ5X47l S6NtR2J6M3texwhUKTboHSZ0Ghj0+OU67M9ruShRSugiN5f8uY7yTO3qLb5eAkyMyJz9ym 0wFc8jU6E3/ZW+GNT7FGTwCMJLkezQQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gyDacMND; spf=pass (imf09.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151895; 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=b7tz66Q1mh6b9biGlGMq1Dqed0aye0/ijzbhQ2yLKo0=; b=gyDacMND/LhZRFD7mSoTy71Jwlz0dNSoMnvaa/EL86MuK5chqkPYGpwIXNdXKbjCvuCovx Gkxy8DbQWMGeiLIeyZKNJv8UDEqBQnaJXh6QFMPoDG9RDuaek4AoOl3TqwGFsUzyQGXPVZ PLwp9lFZ8AGepAVyHKfDdJ7U0WR4fV0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-RzLv_t0zMrqPctIY-vXh2A-1; Wed, 29 Jan 2025 06:58:14 -0500 X-MC-Unique: RzLv_t0zMrqPctIY-vXh2A-1 X-Mimecast-MFC-AGG-ID: RzLv_t0zMrqPctIY-vXh2A Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-385d6ee042eso4940009f8f.0 for ; Wed, 29 Jan 2025 03:58:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151892; x=1738756692; 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=b7tz66Q1mh6b9biGlGMq1Dqed0aye0/ijzbhQ2yLKo0=; b=llgLdyMEQXAYxtYC2FSvSojo5MqEO5+BfBqcgE6IxZrYCzOsn7CQJdHjeedaxqoS7Y PGR80HW/ygeSuhGS083URE2897A87umUxMQlagL75tRu6XDxf7X39Df/BaxEGFUIEVPC mZ17v/7xXB/1ooM7OIdG1Nky6TnIta6ufiPKJolpV8DmqUfCkbgfwQNPWZAzP5WFS1H4 Sw86pfF36hFBpHdrQamN0VHZkReuVDXAZZ+WoY9YsXIJ1ih4n1qYoA8TgZLlS7HnNpPU q/6xpcaLjSiABOLJV9MR/QIbyqmzCIzPdMMv/y6vZIDLW+aiJ7Pl9hR9yy3gK/cLu6RR xHHQ== X-Forwarded-Encrypted: i=1; AJvYcCWHVJ/6WoGTLj3wcoR9sigwu4y6LLyAfyUoEQqSqWnAwtd35rB4uVKjQq+0soiKRfj9YVcibg8Mzg==@kvack.org X-Gm-Message-State: AOJu0YyiWXT5YTT6vyANE1xm7/1JlFPhbIMDNmbDo7ghsH4JqpdUqc2Y 8kdI/95PqCZy+o7NapRbyiL302wwDJVbqoQaINU8b+F6lbRo9PI5SgUczjDZaMOpE6eMaXYLHTm wS0U/fB9a05D1k/nupewyVG9ad2GYJXzjki1f1hh7pLIiDjUV X-Gm-Gg: ASbGncvIs49ZC7/vGgHF/3DdcMilwFqEhzP0jCmXuDNMaWGobCRQpHj7/R/7vo/+BZL esphv66lqcuQ1LPuKkK/j7yLno4JWgbfDBaYkVATum1ynfyhACqUozqA6+jaCTXotAD1SNzzkK4 5kAAZSfgPxnOeH9sshgNAl5JNWO/o50ozi5mXHQ/cninMj2EpbUknuzYdzK7sHONH9tY+jmONNs KsbXMPzsJ+723CZ04kHNs+eC3OxS0ycvV80iAYF4mwCEDaHZ5l5cW31vqK51ANfEbacEpe32pPD QJsr9zop0HaLoB2eRC719DK/XA6HKwvyEHc89hZ47b7wGeK7uKSxThDjZmNZ/F/oDg== X-Received: by 2002:a5d:5986:0:b0:38b:e1b3:16dc with SMTP id ffacd0b85a97d-38c520b0b02mr2139369f8f.50.1738151892499; Wed, 29 Jan 2025 03:58:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkkUWuvL/Qi4Q+ZXMjYaW+MERJXy55kjeOBJGiA5aHVhI3t0Ux4qagc7L275aZnwYNWB5ItA== X-Received: by 2002:a5d:5986:0:b0:38b:e1b3:16dc with SMTP id ffacd0b85a97d-38c520b0b02mr2139337f8f.50.1738151892123; Wed, 29 Jan 2025 03:58:12 -0800 (PST) Received: from localhost (p200300cbc7053b0064b867195794bf13.dip0.t-ipconnect.de. [2003:cb:c705:3b00:64b8:6719:5794:bf13]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-38c2a1bb057sm17068560f8f.62.2025.01.29.03.58.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:58:11 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, nouveau@lists.freedesktop.org, David Hildenbrand , Andrew Morton , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jonathan Corbet , Alex Shi , Yanteng Si , Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Simona Vetter , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pasha Tatashin , Peter Xu , Alistair Popple , Jason Gunthorpe Subject: [PATCH v1 2/4] mm/mmu_notifier: drop owner from MMU_NOTIFY_EXCLUSIVE Date: Wed, 29 Jan 2025 12:58:00 +0100 Message-ID: <20250129115803.2084769-3-david@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250129115803.2084769-1-david@redhat.com> References: <20250129115803.2084769-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: yYan0ZxLJPW5NbuViI8F5zrdFOO2iCQ0FDVe8ZE4em0_1738151892 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Stat-Signature: 68t88bgwr8m83op6bgan9ap99p8ssfdx X-Rspam-User: X-Rspamd-Queue-Id: DC8C114000B X-Rspamd-Server: rspam03 X-HE-Tag: 1738151895-555467 X-HE-Meta: U2FsdGVkX18GTY0+WeY0XVjYpyPwpbndbxo5RN3GTqIR9aVE+HhVvRzWYQX442TEN+JGhAEbgdiaJafg8Ee3SHxXKi7R7LHXa/pBanH3SgZl3e+1HDraYmcGxnCUcm4/B1r1eAAO0xATUmbGC4XFHPLeo6RzL9JpnAl0u+nXLzF2XI9W33t/OyseMNnzjSm7kqz5LYXD9Kz2Fu4aGq+++rJ/vrNNvkjzaXoAaRMdOCZ4K5ASNr/nnReGxxnBYT2OLfJ/i0NvK84ByV4NdAWwlzjZBTDW/qxEHON+Uhz8IlcP5xSuwv9pToWnYAoQwcH4vb4I1EL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o+u5Bad0YAomu5NWGde+I3Dp+WaAqSAGD5aKMaZjMg8AeaSixKV7D0pwd4hlKqaLC4lTZI3r+cVGesa2XqLWkjo+oDEpn+9gWCUdl3/37GakHAbxmOPv0WeXfg== 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: We no longer get a MMU_NOTIFY_EXCLUSIVE on conversion with the owner set that one has to filter out: if there already *is* a device-exclusive entry (e.g., other device, we don't have that information), GUP will convert it back to an ordinary PTE and notify via remove_device_exclusive_entry(). Signed-off-by: David Hildenbrand --- drivers/gpu/drm/nouveau/nouveau_svm.c | 6 +----- include/linux/mmu_notifier.h | 4 +--- include/linux/rmap.h | 2 +- lib/test_hmm.c | 2 +- mm/rmap.c | 3 +-- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 39e3740980bb..4758fee182b4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -510,10 +510,6 @@ static bool nouveau_svm_range_invalidate(struct mmu_interval_notifier *mni, struct svm_notifier *sn = container_of(mni, struct svm_notifier, notifier); - if (range->event == MMU_NOTIFY_EXCLUSIVE && - range->owner == sn->svmm->vmm->cli->drm->dev) - return true; - /* * serializes the update to mni->invalidate_seq done by caller and * prevents invalidation of the PTE from progressing while HW is being @@ -609,7 +605,7 @@ static int nouveau_atomic_range_fault(struct nouveau_svmm *svmm, notifier_seq = mmu_interval_read_begin(¬ifier->notifier); mmap_read_lock(mm); - page = make_device_exclusive(mm, start, drm->dev, &folio); + page = make_device_exclusive(mm, start, &folio); mmap_read_unlock(mm); if (IS_ERR(page)) { ret = -EINVAL; diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index d4e714661826..bac2385099dd 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -44,9 +44,7 @@ struct mmu_interval_notifier; * 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. + * longer have exclusive access to the page. */ enum mmu_notifier_event { MMU_NOTIFY_UNMAP = 0, diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 86425d42c1a9..3b216b91d2e5 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -664,7 +664,7 @@ void try_to_migrate(struct folio *folio, enum ttu_flags flags); void try_to_unmap(struct folio *, enum ttu_flags flags); struct page *make_device_exclusive(struct mm_struct *mm, unsigned long addr, - void *owner, struct folio **foliop); + struct folio **foliop); /* Avoid racy checks */ #define PVMW_SYNC (1 << 0) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 1c0a58279db9..8520c1d1b21b 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -786,7 +786,7 @@ static int dmirror_exclusive(struct dmirror *dmirror, struct folio *folio; struct page *page; - page = make_device_exclusive(mm, addr, &folio, NULL); + page = make_device_exclusive(mm, addr, &folio); if (IS_ERR(page)) { ret = PTR_ERR(page); break; diff --git a/mm/rmap.c b/mm/rmap.c index 4acc9f6d743a..d99dbf59adc6 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2397,7 +2397,6 @@ void try_to_migrate(struct folio *folio, enum ttu_flags flags) * make_device_exclusive() - Mark an address for exclusive use by a device * @mm: mm_struct of associated target process * @addr: the virtual address to mark for exclusive device access - * @owner: passed to MMU_NOTIFY_EXCLUSIVE range notifier to allow filtering * @foliop: folio pointer will be stored here on success. * * This function looks up the page mapped at the given address, grabs a @@ -2421,7 +2420,7 @@ void try_to_migrate(struct folio *folio, enum ttu_flags flags) * Returns: pointer to mapped page on success, otherwise a negative error. */ struct page *make_device_exclusive(struct mm_struct *mm, unsigned long addr, - void *owner, struct folio **foliop) + struct folio **foliop) { struct folio *folio, *fw_folio; struct vm_area_struct *vma;