Message ID | 20250129115411.2077152-11-david@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 C6219C0218D for <linux-mm@archiver.kernel.org>; Wed, 29 Jan 2025 11:55:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 526C9280042; Wed, 29 Jan 2025 06:55:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AF34280025; Wed, 29 Jan 2025 06:55:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 301D8280042; Wed, 29 Jan 2025 06:55:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0DC01280025 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 06:55:14 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 38FEB1C8001 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 11:54:47 +0000 (UTC) X-FDA: 83060332656.24.AF62EED Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 03AD8100010 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 11:54:44 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bO9At6Bx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738151685; a=rsa-sha256; cv=none; b=IByV9B4UVUaLVVPI+MRsK38lzq0tghEAdgInyugJabLnBhKqX6hoXltnodAMdWNgZCHBd1 cbuwBt1EFJfBo+R8kgM9qVwGKm9A7dS2BIa9LipQoG6YtYTTgtRFoGQJLS61Jd0H1HoG/A DDOqKzoO4nAPPByRqeUGAA041wubAkI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bO9At6Bx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.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=1738151685; 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=mNM6Zw+nv5CKX0FXtzXMADzAxRUJZ/HteqC2IEBjnh8=; b=eldfgR1MXlWk9rV0JAm8uilIgH2i89yFChQjQ2TKbAoSGScW6SP+30ocbq3zeWMKWKCwJL jkBz8u84/dGSNQDPEUZeaQXS3OfCOiHxhyJTSZ38NvMPg6OmHL21HWz7sdVRuIZDHIOYvj 0YIoZurzEqvJ+T863lbTzchtPuAm0+k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151684; 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=mNM6Zw+nv5CKX0FXtzXMADzAxRUJZ/HteqC2IEBjnh8=; b=bO9At6Bx6yVnB4LQRYoi4poyPOA/wIgJ9YksvQlBEBeNrLVxxicFX+myPSRXZCP9JG4VDh P2C8DTiOIoNG0WknXdumRcdaUAjzQql6eMxUEqKPon7wr02deEEPDZbSJFUcoPx9vgJZn7 1NdiVQSiUcKOXzeBHxAxVnvnoGNoRCA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-hCJQFP-COUeColKpYXrf-Q-1; Wed, 29 Jan 2025 06:54:43 -0500 X-MC-Unique: hCJQFP-COUeColKpYXrf-Q-1 X-Mimecast-MFC-AGG-ID: hCJQFP-COUeColKpYXrf-Q Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3862c67763dso2402813f8f.3 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 03:54:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151682; x=1738756482; 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=mNM6Zw+nv5CKX0FXtzXMADzAxRUJZ/HteqC2IEBjnh8=; b=DoFSg7nmhFwM747Mah1Nc5otWFLJOEeSXU0yhdnEt9UXhGJOqg2W8fRmJ4n6zefd/l 9AYWNcWxWSuGwJC5VFAYJJhk+lNcI6xrHM/8itBBC7iNRdn8oXyzmQZNqodiWnb7aEvJ yn5LoL8WQLxU8bj74rxPFc1qLOFebRSH1sZwSo25lblF21cXZ1oVuO5TCs7OlInBmHwP VbA6gl/yIwDs3V2LM7nxQBIpCOmX6sRELW2SjwDy23f9jVRizbj7ZQjfXqItcbBP8muM RAmXjhgIreNcHeZU6uN4oFUdDWXJ2wgJAU540xZi5S3IAbXdlXQLB22rj3W0fpnXLoNQ ekrg== X-Forwarded-Encrypted: i=1; AJvYcCWAC3OQpRL1Lnv44ZCoa/ogn+Jh0RO4jhgzMHW8yxzIM/aTEHBg2eR8dmk87hV8d/lLD/eKcJdUTg==@kvack.org X-Gm-Message-State: AOJu0Yw6jBc6WfFkm5DQIVA5ymKYzohHm2J3ExMBLOqEvA+76Lj28bk+ JhH2IfTB7T410OHmKssGoXX+8sQjYro6xl9ZFaO5CI5m6WS7W+aafaqyTGdM+AHdQ8aErxPGiC9 bUflSvJst5xygiHdzQcFz0pqiHSCKzbde7cnJk1BL9Rq8iD/V5lSdtZODEzA= X-Gm-Gg: ASbGncsBnmVlNtY1lDCf1FQTGGWPvowyCuRWu3SlhlntUiybyxAx2/vmRiHtFvt0tVI PH0fXZQd8O7D4D97p8PoxTBUESJdzJRuCXMcFABG9wpsJKoL5TKQBMatdiHfVNXbfmAgDY2r48y GfFP95A16bFkTm3iN2PqUhH0oegyHx3YLpZpzEuanRApMezCQ5nSUGBwL1KEQU7maM80poECrSk yVo15k/d1hEnWrxu4iVHYlePHU0JpUPP3qcd/A79digrwVtGr3QyZuBrQHIFON5m4D9ieI2bXyL Iwl+4dlmMA4XM4OhpGNAe+/gwoWmMPozBCngolryAxCJmEGyVDyc7XPv8C3cjZ0Oww== X-Received: by 2002:a05:6000:4013:b0:385:f631:612 with SMTP id ffacd0b85a97d-38c5195f2e5mr2414977f8f.17.1738151682118; Wed, 29 Jan 2025 03:54:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfVb9Gb5/TQQdvQH0d8Y86brLumLHRijGlRqbPqwAUyE2LkrZ873cAyk0+z1AQr8yjahg13A== X-Received: by 2002:a05:6000:4013:b0:385:f631:612 with SMTP id ffacd0b85a97d-38c5195f2e5mr2414952f8f.17.1738151681703; Wed, 29 Jan 2025 03:54:41 -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-38c2a1c4212sm16316119f8f.87.2025.01.29.03.54.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:54:41 -0800 (PST) From: David Hildenbrand <david@redhat.com> 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 <david@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= <jglisse@redhat.com>, Jonathan Corbet <corbet@lwn.net>, Alex Shi <alexs@kernel.org>, Yanteng Si <si.yanteng@linux.dev>, Karol Herbst <kherbst@redhat.com>, Lyude Paul <lyude@redhat.com>, Danilo Krummrich <dakr@kernel.org>, David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>, "Liam R. Howlett" <Liam.Howlett@oracle.com>, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>, Pasha Tatashin <pasha.tatashin@soleen.com>, Peter Xu <peterx@redhat.com>, Alistair Popple <apopple@nvidia.com>, Jason Gunthorpe <jgg@nvidia.com> Subject: [PATCH v1 10/12] mm/rmap: handle device-exclusive entries correctly in folio_referenced_one() Date: Wed, 29 Jan 2025 12:54:08 +0100 Message-ID: <20250129115411.2077152-11-david@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250129115411.2077152-1-david@redhat.com> References: <20250129115411.2077152-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: t0H4xmmHlZPwn4C1NiYcsH4Jksym3QcQ38I2qqa0mZs_1738151682 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 03AD8100010 X-Stat-Signature: gapbikinxe9gwurf1do7mmdkz759gfop X-Rspam-User: X-HE-Tag: 1738151684-924841 X-HE-Meta: U2FsdGVkX18vkyuDE6jIDP2skSZCXBPH9OlCO5iM+8gZ88cVCfwF/jbQ++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ZZRvWhu9OXNyBnbwlAsAbbSffdQ5fA/KrSb0EJc4rYqAOD0iZ8qdpcqF+WlYGOqqt/wVO6sep9lruU9keHzM7H1L1JgAN/qMf0a8K4GJ18MS1bFVszLlCKvngGCVgHDrQrXrfNBmXcJ7pihMbZnJQ7D0yK1LJiH/6G+uv7zeE022Y5+eW4Gc1g4oRuFfbyXiR/8KzjbsbfjJ3EaqzVrF9AAgRebsBpfogSkQSUrJasuiL1n9UKBtzGyqJnSdKfXYWFjKiP6/CoTLuF5K2RwWzpvhX30AjAjZFqmncwbhwmrkM72KN6plAUxfJkDV0ckCn51sVz5OxRlf+njkw6pdFOMLpzeh1pNfY5YJgpFKGwQo5GF3XN77EhAZ/3SygxQIe6vOfEATb1A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm: fixes for device-exclusive entries (hmm)
|
expand
|
diff --git a/mm/rmap.c b/mm/rmap.c index 903a78e60781..77b063e9aec4 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -899,8 +899,14 @@ static bool folio_referenced_one(struct folio *folio, if (lru_gen_look_around(&pvmw)) referenced++; } else if (pvmw.pte) { - if (ptep_clear_flush_young_notify(vma, address, - pvmw.pte)) + /* + * We can end up here with selected non-swap entries + * that actually map pages similar to PROT_NONE; see + * page_vma_mapped_walk()->check_pte(). From a CPU + * perspective, these PTEs are old. + */ + if (pte_present(ptep_get(pvmw.pte)) && + ptep_clear_flush_young_notify(vma, address, pvmw.pte)) referenced++; } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) { if (pmdp_clear_flush_young_notify(vma, address,
Ever since commit b756a3b5e7ea ("mm: device exclusive memory access") we can return with a device-exclusive entry from page_vma_mapped_walk(). folio_referenced_one() is not prepared for that, so teach it about these non-present nonswap PTEs. We'll likely never hit that path with device-private entries, but we could with device-exclusive ones. It's not really clear what to do: the device could be accessing this PTE, but we don't have that information in the PTE. Likely MMU notifiers should be taking care of that, and we can just assume "not referenced by the CPU". Note that we could currently only run into this case with device-exclusive entries on THPs. For order-0 folios, we still adjust the mapcount on conversion to device-exclusive, making the rmap walk abort early (folio_mapcount() == 0). We'll fix that next, now that folio_referenced_one() can handle it. Fixes: b756a3b5e7ea ("mm: device exclusive memory access") Signed-off-by: David Hildenbrand <david@redhat.com> --- mm/rmap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)