From nobody Fri Dec 19 02:50:40 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBD1E1DC994 for ; Wed, 29 Jan 2025 11:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151895; cv=none; b=tmyl9yuO5b8qmBAtFbLdZgNCu2aNMVNbRdo5iwrmsFuSu+PIwTLbq8XlspWoqaBEuj/zbjUkTlbRTL9jrXZIFZ5IjmVVBTa+0P2VNWysN9F5wn6hVZK6DfRKbaTK9MBO6zB0PhrqzbiqdU5ClUXYrCw105sSaN+3jB0g0J53oRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151895; c=relaxed/simple; bh=INxpcPFbFbOdxrLDGz72x2XA3kxfXFbHhUtixOst4xk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aOqbLUiaEoOnWOIg9HfB3oPTgAXlC98wL1jOMaBh3BvNcg3qQvERTgxyYyFDK1iQ9s6nI0lNQFIgCWkQl4mY+iUSU3ggW0gpidbqQLyHdP1Wdhwrl06yVjUaki2us6FO7ZhEDwiEFMJ0kXvKlhveNkjWwmY8rdvNg2vsRmjStZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Rnh9qJeB; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Rnh9qJeB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IvULs1yE7EOmGau/Ggivq4i0htACtoQXWVK4/nOi/M8=; b=Rnh9qJeBLexWX+dATynwRYGIFac4ft9+YYifI9DWVFd32Qi5bq0K9yRSVWQUkxcHZu07nG 5wDzd9EoPLgixcanSIUr6VzD8sI/3g1Kka7oPQbT75T132c14MlyARcPMASuJCLSDIVWZo cU/0MnlKqxwybkofh6jiJZFbBiSzzBw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-66-K3ghDnZ1Mj6XqCxtV9oQHQ-1; Wed, 29 Jan 2025 06:58:11 -0500 X-MC-Unique: K3ghDnZ1Mj6XqCxtV9oQHQ-1 X-Mimecast-MFC-AGG-ID: K3ghDnZ1Mj6XqCxtV9oQHQ Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4362b9c15d8so32535795e9.3 for ; Wed, 29 Jan 2025 03:58:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151890; x=1738756690; 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=IvULs1yE7EOmGau/Ggivq4i0htACtoQXWVK4/nOi/M8=; b=vm8MJWiIS27UGeJ2VxUwfHiF90BzB3zovJJOdaABPL59TbpkBXxcCPJJfrnPbMl1v2 HzMDCmc+sRvKmw1/6qoXNGR8TiX23BYO2s2AdHU6IewCm0PzMDMO0JvGWEvZ+QH8pbQO nYdEsnIu+jeLhgd3ife06n4alxpdQMeYr08b3TuGU8yMJlYnErDMzm3PjpMOmy0rwev3 oLhkx8/sK0I3MBgLC9XwOVWFUYuKWZMjlgOQtPJiU0N6VwszQIUmK0u16fGgjWxkOM3q R9hlUjZ8FfkRTJiDs94WrPVKl1DjXb82MyyUmKmKnmWk8U0DTO7Sr9yDUQLivkv3kZA7 EIBQ== X-Gm-Message-State: AOJu0Yzf7bhDRxWisBhWdRp6fOjlPMwaJsRrx3dFsw7o7CD4jXvewHqb seeMtVD4BvsCrI6xd8MmRxK6fwlcdcxLq7fRCT7ah/OWj3Wc8XAtzYfhFTpE9TMtG5YPy4ye1FI v5NQb36ufJkAf7O3/ndUGuu7/kQt9irWf6UnPYmZdIc5JAMq3gc6SqFqE8iT9+K/QKMeo7T2+Vx 15ics9GA6gdtPimQUaJGKWLcJ5hNHhFObX+1lm1mQQH/Id X-Gm-Gg: ASbGnctaxuH4qJH1QXSIemG3T7vAr8tiYgUmTj1JzvoCSxp00S6lGmTzmZZoqEUQB4V yOZ2/iBUVh8A65xr4DjTatsx3d6dlpbzA+i/tVpk7GeY0bdFrY04LtPFmFmHberxhesNwsIaf0U zgKHlQy9bmc9PlyJYTuun8YVQsNSNCZaFHFh+gG+wbDVZsB1u4pNa/7LA2GGO20XLYqXz82777l LQY43QJeE25IIKHaRjsyxyBr2Y+ooeDaAYdUUI2HpMOR2RWK/1qjWtPsn3SvdpIS7vvTkOGJaEm eV4zqeHS+fkkC3KRDMDLuyjU2xhNnb6W51sQzpRYakBxIQyEW5jdVeUQzE/pbkuytA== X-Received: by 2002:a05:600c:5252:b0:431:6153:a258 with SMTP id 5b1f17b1804b1-438dc3ca802mr23864315e9.13.1738151890529; Wed, 29 Jan 2025 03:58:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqM74m4ZV9IsBXW9SIKcsLoOPVNY/fxsU8Okkl94/EsEQHDya1iNUyBhUuUArF4/LgH5tlYg== X-Received: by 2002:a05:600c:5252:b0:431:6153:a258 with SMTP id 5b1f17b1804b1-438dc3ca802mr23863905e9.13.1738151890101; Wed, 29 Jan 2025 03:58:10 -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 5b1f17b1804b1-438dcc12f88sm20420515e9.2.2025.01.29.03.58.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:58:08 -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?q?J=C3=A9r=C3=B4me=20Glisse?= , 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 1/4] lib/test_hmm: make dmirror_atomic_map() consume a single page Date: Wed, 29 Jan 2025 12:57:59 +0100 Message-ID: <20250129115803.2084769-2-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The caller now always passes a single page; let's simplify, and return "0" on success. Signed-off-by: David Hildenbrand Reviewed-by: Alistair Popple --- lib/test_hmm.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 9e1b07a227a3..1c0a58279db9 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -706,34 +706,23 @@ static int dmirror_check_atomic(struct dmirror *dmirr= or, unsigned long start, return 0; } =20 -static int dmirror_atomic_map(unsigned long start, unsigned long end, - struct page **pages, struct dmirror *dmirror) +static int dmirror_atomic_map(unsigned long addr, struct page *page, + struct dmirror *dmirror) { - unsigned long pfn, mapped =3D 0; - int i; + void *entry; =20 /* Map the migrated pages into the device's page tables. */ mutex_lock(&dmirror->mutex); =20 - for (i =3D 0, pfn =3D start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn= ++, i++) { - void *entry; - - if (!pages[i]) - continue; - - entry =3D pages[i]; - entry =3D xa_tag_pointer(entry, DPT_XA_TAG_ATOMIC); - entry =3D xa_store(&dmirror->pt, pfn, entry, GFP_ATOMIC); - if (xa_is_err(entry)) { - mutex_unlock(&dmirror->mutex); - return xa_err(entry); - } - - mapped++; + entry =3D xa_tag_pointer(page, DPT_XA_TAG_ATOMIC); + entry =3D xa_store(&dmirror->pt, addr >> PAGE_SHIFT, entry, GFP_ATOMIC); + if (xa_is_err(entry)) { + mutex_unlock(&dmirror->mutex); + return xa_err(entry); } =20 mutex_unlock(&dmirror->mutex); - return mapped; + return 0; } =20 static int dmirror_migrate_finalize_and_map(struct migrate_vma *args, @@ -803,9 +792,7 @@ static int dmirror_exclusive(struct dmirror *dmirror, break; } =20 - ret =3D dmirror_atomic_map(addr, addr + PAGE_SIZE, &page, dmirror); - if (!ret) - ret =3D -EBUSY; + ret =3D dmirror_atomic_map(addr, page, dmirror); folio_unlock(folio); folio_put(folio); =20 --=20 2.48.1 From nobody Fri Dec 19 02:50:40 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1D961DE2B3 for ; Wed, 29 Jan 2025 11:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151897; cv=none; b=lJqV+0gc3Yk/8/LXgz6MSxkrHyT+kVded727wJkF9reZsa9/06gE0N/he8ik0w983iYQEudFVVMFmGvvcuPHDLthRcCO9Pfvy1VDLrhyljL7IDuJ7ZsmZ8ZW173O5hdSh1VJLkg6XWRVTPycC62HVWlEDmMG4iBnMUloT3SJpro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151897; c=relaxed/simple; bh=ctFwb9uMTBVm9UDo1nN2tyX9Jer31qwqNzGs00Hd6Pg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I9S+7zOVYgIlVK3JNWP+Ib+n/s3s1cL8GWWjvjto835G2VEWyrz+eXYA6+JqdRJcZ/tH3XGna/kmXYfqfc1khIc2wkHtxWzea0f0Hq/LvJvVo6Qpx3RXm9z5KWf5jo/gpMFV1zUBUHlGrOmnJRKZ7z68PnolqWvzbbCTRD1FJWE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=insHvV7D; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="insHvV7D" 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b7tz66Q1mh6b9biGlGMq1Dqed0aye0/ijzbhQ2yLKo0=; b=insHvV7DtDiDrZ42pwUfxeXg65hxU4pZitxguPUrDZkNNpAMl6Mmb+OqYSPBfjuBN0TZZI nR60auiSeJ9b6kuDeTjjxzbUmsZ+JpEyO+Qo3iFrbq6viJRkMvQu1UGuLijuUtu9Gfo+/T 7YFX1+jsAtnEPW9t/V1nDPfawhibA2A= 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-377-15_gHlQiOCiLTaZYaDV9Dw-1; Wed, 29 Jan 2025 06:58:13 -0500 X-MC-Unique: 15_gHlQiOCiLTaZYaDV9Dw-1 X-Mimecast-MFC-AGG-ID: 15_gHlQiOCiLTaZYaDV9Dw Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-38bee9ae3b7so4422974f8f.1 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=MuXsZ0uFbOIW70SLGESLrlROrt/vG7Py0aHDAn/rI6WTRc0PLN2RHIgOpwbmw9V5Ii VkkpZubKTwZZ9Rr+t14hYUb8aNpxgrpvVXc6HhcRwb7rUdjQxyAJxB4fw2IZYZX7Aozw XwHBVKrnb29LCFCzFd2Y21vmyyn57b9IYCf2Gl/C4dY9nXLd5i9qVA+BusggI64Gae4T LXHLVu+WQ2PTlGF7lfnUcvB+Zl3m+Z7112Te29jfA9S7zyqOJrOPCskGohUtXSaC1tV+ j4OOGmtp3SiefkGww3ug7ch2QgDExYhPbmrbkggBcOvp4D6cuFeI5Q4haix4mimB3PJi rAzg== X-Gm-Message-State: AOJu0Yym9onGqGQzu56duhHh95co34QgBo4313jhrR2IabRI3b3nZpoL MrxQi7aHnvrHaTg4enuoX281VVzoZIOYRB9xRtC3Eft+IMyTXWXyOu74HnKVAQgHZcul3ViqbWy ODbs6wla4w/oyTNZxfNqtAHkmaWsyOL2W8SoWbRqsZaj7kIu7UPd0GwozY2rpq6F8EcDEbHQRwW k5Mkj+OgmWZNe5sVWZLLS40oPCk8zWTM5C7T19u2olFyCb X-Gm-Gg: ASbGncvF+/rhKqvvGfj1N2yIVhM1GSzPWgMuIIOC5+YF//BLCub0l5ONIoQK5xY2d6v /JEPKIVelYXl0WTGkdz55PvsyzWhxaBWvnd8VX/UhHFgq9ACH47j+/GPDwMW99WEtsdMCVSougd HQbbyaXnpgVDOOfr/LySkwXjP7oIzS4ZSiENed3ZTa648FLXQn3px+f9vsjmNggzNdUH6endbh4 qbyYg8YEpSEZ+FecxEEUZLEb1Zh4dnvumgil1A7OwMHADCv1vSLqCBVtgP5VKpJqyCGSVaTLhDk kQNw62Yb+vHGzB+HjIuDO+f6d5RNfcIii9z5Eap+cqhK0hsu6G3PFptbADOc3IuSAw== X-Received: by 2002:a5d:5986:0:b0:38b:e1b3:16dc with SMTP id ffacd0b85a97d-38c520b0b02mr2139394f8f.50.1738151892613; 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?q?J=C3=A9r=C3=B4me=20Glisse?= , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/nouvea= u/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_in= terval_notifier *mni, struct svm_notifier *sn =3D container_of(mni, struct svm_notifier, notifier); =20 - if (range->event =3D=3D MMU_NOTIFY_EXCLUSIVE && - range->owner =3D=3D 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_sv= mm *svmm, =20 notifier_seq =3D mmu_interval_read_begin(¬ifier->notifier); mmap_read_lock(mm); - page =3D make_device_exclusive(mm, start, drm->dev, &folio); + page =3D make_device_exclusive(mm, start, &folio); mmap_read_unlock(mm); if (IS_ERR(page)) { ret =3D -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 =3D 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); =20 struct page *make_device_exclusive(struct mm_struct *mm, unsigned long add= r, - void *owner, struct folio **foliop); + struct folio **foliop); =20 /* 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; =20 - page =3D make_device_exclusive(mm, addr, &folio, NULL); + page =3D make_device_exclusive(mm, addr, &folio); if (IS_ERR(page)) { ret =3D 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_fla= gs 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_fla= gs flags) * Returns: pointer to mapped page on success, otherwise a negative error. */ struct page *make_device_exclusive(struct mm_struct *mm, unsigned long add= r, - void *owner, struct folio **foliop) + struct folio **foliop) { struct folio *folio, *fw_folio; struct vm_area_struct *vma; --=20 2.48.1 From nobody Fri Dec 19 02:50:40 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 062D51DE88E for ; Wed, 29 Jan 2025 11:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151902; cv=none; b=RZgyEkVczMn732LzQnQ7wZmyK20bsN88nqbVHAN/W6ca1VXHtaf41Eo+x1yszeVzxDoqoklaGOq3aznJuyc9xPaB+xMsjTGsdtZBKH2u2WpFOHqE5YYU29v1vVr3mHnp2PGB0tus/40/ZCL8xtAx4l3M7zxjs4xHj9SOXFJiE0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151902; c=relaxed/simple; bh=sOFTxxiTEpmnz84//zewC99r4PEneol5TOg9SJgosTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CEsrV2E8MhvU8gqO/YtWFYvaEo8938LjF1ci/zp3lPDfybq2f6Nk00okb6tZv0CUgQcvgwB29IpFI1aVigMxEiuy5x8DZ5oUAhYLBySxOSTJ3g29IciW5oAOqpu3gGvLbZ7JhLFT454qHn3JcP25Wa+NRLoOaJhiTvb1TyiWbiM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=g5wWcChF; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g5wWcChF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n2/u4hMaC1Y/nn2Uh1F1xHtHTh10RqLxBEMK6rVGx5s=; b=g5wWcChFzVjhYwUyUY42dz1gmoP03zan1wc7zJ+S8ea92QAOUhhPHoSJseZSnzzBsksfz3 ghksBdMbeCESoaJmT2kt1VuEX2SfOQx+fPMAyaOXCgHplnq02qOe7+IldWJhzLqjivxxb8 Tw+5Nw3Z2QvBs2C4h65mxHTQLmfSuCQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-jRDbW3MdMFylUf5QW9jf1g-1; Wed, 29 Jan 2025 06:58:17 -0500 X-MC-Unique: jRDbW3MdMFylUf5QW9jf1g-1 X-Mimecast-MFC-AGG-ID: jRDbW3MdMFylUf5QW9jf1g Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38a2140a400so5197994f8f.0 for ; Wed, 29 Jan 2025 03:58:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151896; x=1738756696; 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=n2/u4hMaC1Y/nn2Uh1F1xHtHTh10RqLxBEMK6rVGx5s=; b=xUds2mz4voBCmTrsxteASl8dscgEm+GgB3trMJPexsmzs9Ejng24ivKIpoKtIeDRQe tC0WlGM55BqFzd/95Bau2UTc89Mv3lDfc9ggQUDGlAkxxr1tu+0AXbgjmZM6+RZb9ca6 qATsHH7bUZZfq8AvwPyMHXJbjpsFgGUyyQbhg0ZMUoFYr3HRvhQPSxe7fG0X7x0gTByg er5juaHJ/A7niJpJaFidfCO4yO5t/8uEvSmmKvW+nENwDV9DqXFeL/tZ2MsvXYndzYL5 KWC4BFBqGejLOWuohEGkc5ZoLaDIeVh59TR3LlHVfq5Nal3ZZz17NphxLNzstDU2Lq9r sYCA== X-Gm-Message-State: AOJu0YzIqA8CKHV90oWriT1jdHYC3tt9lZ+Fg4cepmOADOsL7sSZsKiS OIv8tkpGwC+Ra0wi8C+2KHIHGWVAnJAmHw+JBHSoIDyVMciOyUeSZ4DZtCNDqa6FXTLPR7YgMHb 0SO/8+Fq7r7BBJIgeYK3z04Lc5soYHu2r0aSfUrAesS7stcwAGt/2P3ZzQTzR+gYiHz7qaQ8Wgq /nfYWx5Qg66LkQ8qfgtpsdIoLjgZzmOiyQSyMzxcRhzJmP X-Gm-Gg: ASbGncsTtjMl8xDql3foJRVg8ZebRexCNPSrwdrAS228DxFmnkG+myqn3TApKBIOoT7 MJudJZU60gsh+moMP4myz8QTTsros7h3ljlfikX5KnLqPxY4eK/8VeYEfSITouaayidSIe6D3zQ lHmkh+DAODfcbBazkqlootMj/XsekVWTBGn8xiuWsw36875eZwGCJxg56uKa9zNW69AEoPGHcGT iV0vzhCLREFw/KWaawH+uQQAdA7WmTC0rT7Aak4O2JQLR6n8s2Yow1FVEVz075CL2tnWjbtJWT+ Nh87SuwZyMiTceaccOcepnoNKo6vGtTSbYKxK/0t+Wm93vsDHbJ/RqGxIT6GjGXGGw== X-Received: by 2002:a05:6000:2c8:b0:38a:88f8:aac8 with SMTP id ffacd0b85a97d-38c52096289mr2025174f8f.54.1738151895938; Wed, 29 Jan 2025 03:58:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEON5WkoaxoRH3qtkNX0vn2oqksdlJtc4nZs+NotAXeIJk4vQvUCQu3rl+CihtRV9gH+gpH8w== X-Received: by 2002:a05:6000:2c8:b0:38a:88f8:aac8 with SMTP id ffacd0b85a97d-38c52096289mr2025126f8f.54.1738151895421; Wed, 29 Jan 2025 03:58:15 -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-38c2a1764e9sm17070487f8f.17.2025.01.29.03.58.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:58:14 -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?q?J=C3=A9r=C3=B4me=20Glisse?= , 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 3/4] mm/memory: pass folio and pte to restore_exclusive_pte() Date: Wed, 29 Jan 2025 12:58:01 +0100 Message-ID: <20250129115803.2084769-4-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's pass the folio and the pte to restore_exclusive_pte(), so we can avoid repeated page_folio() and ptep_get(). To do that, pass the pte to try_restore_exclusive_pte() and use a folio in there already. While at it, just avoid the "swp_entry_t entry" variable in try_restore_exclusive_pte() and add a folio-locked check to restore_exclusive_pte(). Signed-off-by: David Hildenbrand Reviewed-by: Alistair Popple --- mm/memory.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index cd689cd8a7c8..46956994aaff 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -719,14 +719,13 @@ struct folio *vm_normal_folio_pmd(struct vm_area_stru= ct *vma, #endif =20 static void restore_exclusive_pte(struct vm_area_struct *vma, - struct page *page, unsigned long address, - pte_t *ptep) + struct folio *folio, struct page *page, unsigned long address, + pte_t *ptep, pte_t orig_pte) { - struct folio *folio =3D page_folio(page); - pte_t orig_pte; pte_t pte; =20 - orig_pte =3D ptep_get(ptep); + VM_WARN_ON_FOLIO(!folio_test_locked(folio), folio); + pte =3D pte_mkold(mk_pte(page, READ_ONCE(vma->vm_page_prot))); if (pte_swp_soft_dirty(orig_pte)) pte =3D pte_mksoft_dirty(pte); @@ -756,16 +755,15 @@ static void restore_exclusive_pte(struct vm_area_stru= ct *vma, * Tries to restore an exclusive pte if the page lock can be acquired with= out * sleeping. */ -static int -try_restore_exclusive_pte(pte_t *src_pte, struct vm_area_struct *vma, - unsigned long addr) +static int try_restore_exclusive_pte(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep, pte_t orig_pte) { - swp_entry_t entry =3D pte_to_swp_entry(ptep_get(src_pte)); - struct page *page =3D pfn_swap_entry_to_page(entry); + struct page *page =3D pfn_swap_entry_to_page(pte_to_swp_entry(orig_pte)); + struct folio *folio =3D page_folio(page); =20 - if (trylock_page(page)) { - restore_exclusive_pte(vma, page, addr, src_pte); - unlock_page(page); + if (folio_trylock(folio)) { + restore_exclusive_pte(vma, folio, page, addr, ptep, orig_pte); + folio_unlock(folio); return 0; } =20 @@ -871,7 +869,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm= _struct *src_mm, * (ie. COW) mappings. */ VM_BUG_ON(!is_cow_mapping(src_vma->vm_flags)); - if (try_restore_exclusive_pte(src_pte, src_vma, addr)) + if (try_restore_exclusive_pte(src_vma, addr, src_pte, orig_pte)) return -EBUSY; return -ENOENT; } else if (is_pte_marker_entry(entry)) { @@ -3979,7 +3977,8 @@ static vm_fault_t remove_device_exclusive_entry(struc= t vm_fault *vmf) vmf->pte =3D pte_offset_map_lock(vma->vm_mm, vmf->pmd, vmf->address, &vmf->ptl); if (likely(vmf->pte && pte_same(ptep_get(vmf->pte), vmf->orig_pte))) - restore_exclusive_pte(vma, vmf->page, vmf->address, vmf->pte); + restore_exclusive_pte(vma, folio, vmf->page, vmf->address, + vmf->pte, vmf->orig_pte); =20 if (vmf->pte) pte_unmap_unlock(vmf->pte, vmf->ptl); --=20 2.48.1 From nobody Fri Dec 19 02:50:40 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 789FE1DE892 for ; Wed, 29 Jan 2025 11:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151903; cv=none; b=YWWY4T61CDqYAy5xoy+w1cYlPWtjOiz8uCWE7k92x9Mryjw5KgjKd88jKxSq15ql0U0dPGDfYYGspIWzywizRXpX8Epk5ih4FEHFJL1QtgR8zw1hln4qyXTgbl4lpiQb2BPfaylBs4JzJehsczvQH7/umreo/Y5is77yenaKzsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738151903; c=relaxed/simple; bh=9PHBiuSbQfK/gtAQxmhDt+JDCvJOGqXhhiGP82nYoCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bzuNFdK1eVuH/4srIWbbKdVFBSkU9PI6Ct6zDEbmXrdccYSv78yCvPfxRjbSB5GLe75/EiyRyVLWx3DPjzC2YQsHc2WSHxNv/xuVUXB9XdTpYrEGGc7oEGHL58D4bHBDkdQ4L0HPaZfc7vBx6G2iQOpHQ6YLXJKpE66tYIVkcmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gMr8HFVc; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gMr8HFVc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FOqcQk5sbfQYMqiwFwVZu0o4Vgt4WnJhwl3OPDX2fpI=; b=gMr8HFVcJxKmjbJtkRH5yYQNFiu+zGbYkXCvDU2GOw937a/JXRypnyGGXSHVHpAmECcrN/ UBmA4626jYNkkxJT2MSCdjeRdkTefZXAfVlNbj/215MglLlGDTr6df95Zpz+SM48N73Hm6 GpQM4Px0kTr/PTHcqVgNbCoXgrgGqOk= 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-680-fUi_F_FjOrGn_a2qoRG_aw-1; Wed, 29 Jan 2025 06:58:19 -0500 X-MC-Unique: fUi_F_FjOrGn_a2qoRG_aw-1 X-Mimecast-MFC-AGG-ID: fUi_F_FjOrGn_a2qoRG_aw Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43631d8d9c7so3373895e9.1 for ; Wed, 29 Jan 2025 03:58:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151898; x=1738756698; 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=FOqcQk5sbfQYMqiwFwVZu0o4Vgt4WnJhwl3OPDX2fpI=; b=KU2KdwlJz7da9ZnyVicenOaPLZd0OCihabfKBMUD2cpM6jyx5KPTxkX8z3hJG5rJKi yX02Z7yPZ4C0Y5ztjkx3KWrEwVkouYglxoy0/DBGI7TR7hv9JoFcNcxvkethLaNtYNV3 SzzwskjLufsPZeZvVEZoMa2QuTzwYpqClzcpLI3lMixyEy3xidehNH/GD89jAeK7CMWI oSoqUu+0fXmfzZ6LAvPJquiwZ/D+RpDR+u4q2Jjc/Tbm6CVemr+3dnuhlYVcx0vtYdRS 8c5CAVU2QuaI0G3TWkLAF/WsYAohphfrHXVX91l9HpTxQ1H9Ca1xZQdLXctWnE32v7cl tUjg== X-Gm-Message-State: AOJu0Yy1vpAcrRgaAPxe5qPp+L5C0CJsDpjdWHPN4LobzkqH05Z7USJL 7dmPib3zleczcmutfbI9MBfOM7VDHFr+2OEvWP5QcpcIkutF0jeugbuNbFWdRzkBMs9wpR3p7c/ ZjAwhTv4N6cAzJW7e4Ovft/ts8PxYlJXLOT0gu7w0UboFqSFFCC0jtCIktODV/bwstCZdzJrBFr cl8RDe2Mg+LF6+89gBU/PSgQu0nQ1xGj0+enBSu2uMUM3G X-Gm-Gg: ASbGncts1OXweSYzpqRP0FCU4vwtDEaVrZ+1xLFLEHu5x2YuPQUhoEemnpuQc08VxZz deZSQUINca4cKwI24Pmk4zWNRYC4ZRYqALqwwtlJ/xheYOOoZEXooSQy/wUyW5x/Qf9QXJ1SKTj n/a2WYTwrBp0TAM0FyHkj0ZNECeAYFgM1f3vtetpl5KuL/tLkRBBOFDE/RVJPwlbqKDvJbSGeoo NQ0M2JjwpW7+CS/28kxQtWLJhUlK233tMTQ2tsqqeiy6PRfjNrpr47gXmyBPDsv8U2CNc2w8KTn I/s4SJt524MI81V16zoGJafQ/tl7LCTFhV0FbThO/ed5WVRLAwMVR3aQn0Lv6ZUDpw== X-Received: by 2002:a05:600c:3d87:b0:436:1b0b:2633 with SMTP id 5b1f17b1804b1-438dbe9a124mr27335905e9.9.1738151898366; Wed, 29 Jan 2025 03:58:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUOJXNPPQ6xLco9EGZUl9hRUezUN+y2Deyf0uuUDDMY6E4w4fKpt4O5zyjSgxt4LyQtnHPOg== X-Received: by 2002:a05:600c:3d87:b0:436:1b0b:2633 with SMTP id 5b1f17b1804b1-438dbe9a124mr27335535e9.9.1738151897999; Wed, 29 Jan 2025 03:58:17 -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 5b1f17b1804b1-438dcc33e04sm20207605e9.29.2025.01.29.03.58.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:58:17 -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?q?J=C3=A9r=C3=B4me=20Glisse?= , 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 4/4] mm/memory: document restore_exclusive_pte() Date: Wed, 29 Jan 2025 12:58:02 +0100 Message-ID: <20250129115803.2084769-5-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's document how this function is to be used, and why the requirement for the folio lock might maybe be dropped in the future. Signed-off-by: David Hildenbrand --- mm/memory.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 46956994aaff..caaae8df11a9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -718,6 +718,31 @@ struct folio *vm_normal_folio_pmd(struct vm_area_struc= t *vma, } #endif =20 +/** + * restore_exclusive_pte - Restore a device-exclusive entry + * @vma: VMA covering @address + * @folio: the mapped folio + * @page: the mapped folio page + * @address: the virtual address + * @ptep: PTE pointer into the locked page table mapping the folio page + * @orig_pte: PTE value at @ptep + * + * Restore a device-exclusive non-swap entry to an ordinary present PTE. + * + * The folio and the page table must be locked, and MMU notifiers must have + * been called to invalidate any (exclusive) device mappings. In case of + * fork(), MMU_NOTIFY_PROTECTION_PAGE is triggered, and in case of a page + * fault MMU_NOTIFY_EXCLUSIVE is triggered. + * + * Locking the folio makes sure that anybody who just converted the PTE to + * a device-private entry can map it into the device, before unlocking it;= so + * the folio lock prevents concurrent conversion to device-exclusive. + * + * TODO: the folio lock does not protect against all cases of concurrent + * page table modifications (e.g., MADV_DONTNEED, mprotect), so device dri= vers + * must already use MMU notifiers to sync against any concurrent changes + * Maybe the requirement for the folio lock can be dropped in the future. + */ static void restore_exclusive_pte(struct vm_area_struct *vma, struct folio *folio, struct page *page, unsigned long address, pte_t *ptep, pte_t orig_pte) --=20 2.48.1