Message ID | 20250129115411.2077152-12-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 EDAA5C0218D for <linux-mm@archiver.kernel.org>; Wed, 29 Jan 2025 11:54:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 508D728001A; Wed, 29 Jan 2025 06:54:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4665A280018; Wed, 29 Jan 2025 06:54:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28C2528001A; Wed, 29 Jan 2025 06:54:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F0661280018 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 06:54:52 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ABFD944F19 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 11:54:52 +0000 (UTC) X-FDA: 83060332824.13.69AA71F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 729E640007 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 11:54:50 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VWeyw6W7; spf=pass (imf17.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=1738151690; 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=1V8bFv4UpnBG412679q6Wat0SbxTmvFr7JjVIwnpoX4=; b=pFfjNOvw6jG6ymnBTZrXjawJG7EBoru43029BN3iP7V8tXeJ6jQKFqLpYkffQE9i5GDc5J UEO3CW7TsjzUVxWNoRAPtrRJ0NvQpc12xI6jpumyv/LIcw/a9NZNGcGcOQjqux7T8bH0BA np//gPpBjPOvaw0pHKoPU20DfY0RsaM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VWeyw6W7; spf=pass (imf17.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738151690; a=rsa-sha256; cv=none; b=V8hWqTwruU8WCEmuq0LsUpnX6OBzpo9P3uWPJwdfpTRLiZT+tOFjiPJnEG+8/Ax4Nq00fW jXvgP9SxEy9p5BRKREXHgx7aXMm3tiekMxTzTj8AY7MOC6aWOw/dhBgMuuZwT9uCMT6qNW NJQ9YDuLnTq97d1IORDnqeZT0mjGgMo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151689; 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=1V8bFv4UpnBG412679q6Wat0SbxTmvFr7JjVIwnpoX4=; b=VWeyw6W74m6rOCvyXrdJZ8gyf/OBwXXcoG/uLji8TZ1iORNrpMp+JKTrPCCYNV+E+hVyq9 S4K0t1+uke/o2Y7o4SiCxHoJH43hrW5xPy0KjFZyS6szPJI088cqK7i1mi1NoHcILHDg/3 A4ONrmZil5wi5g17/aN3bR0ZBvEwF9M= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-hdoAmLa6N5Kiij3paPKA0A-1; Wed, 29 Jan 2025 06:54:46 -0500 X-MC-Unique: hdoAmLa6N5Kiij3paPKA0A-1 X-Mimecast-MFC-AGG-ID: hdoAmLa6N5Kiij3paPKA0A Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-38c24ac3706so5219057f8f.0 for <linux-mm@kvack.org>; Wed, 29 Jan 2025 03:54:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151685; x=1738756485; 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=1V8bFv4UpnBG412679q6Wat0SbxTmvFr7JjVIwnpoX4=; b=v9lEzswVhxV8C5k2GdZ0+L7gxpcr2Q4ZSzmZNQxOT8rN3h+7vfzaWNtEhHt9i49Nru bf5Dq8xMWcnjwwFMUXthYhi5YAmWd3tF+ajaHAS07TY8NX4D8XT0f7HdNiF6H7Sq0oKb oUtnpAUrp8clRTjVPxqEo/jgh8NMjc73jEQCMWtmy7oMQO1iyG5/geaZFkgA4LEl27IX XMXaFdm9UkKTfzPRccLOxjE8S60aLsasYRYTDu3laV53nxHd8gK9OXHALs4xwOfaY550 C/3DN7HEoa9cYjZ4GznmyYmC09yIAunp2tFMAvjnQsA102aDF64qASEpdHBu90rqdJqv 6hyg== X-Forwarded-Encrypted: i=1; AJvYcCXfcYlmL/dHkdbua58EbkTfGyXyv8biAKHfn4P0keaLyvLfHQjzDQ6370gSLlJ9aClhYoWgO9kHxg==@kvack.org X-Gm-Message-State: AOJu0YxbCvV39Mi6RgFSW5RLnrHndgPhErt6htD3kRTw5NhLI7bEseWW 4Y3dEYJaAVE4RhX096xTQmqkJCaBz/IJ41MkoMA48Mm81NwKfbdopFrUO1kpFHxyLNZVPNCQ7T0 qkj2XCUiHJ4d8a88UGUbBn0JtnzpayKd7U/6oV2IXSyrQa9ob X-Gm-Gg: ASbGncuZYAEgK58Rll2ZkzStPEPxdZta3bAqST1cYIl2I1LyAH7YxA7IAXpKzNEsYez PisHC+ZYswlXvTXlkUzHOTgKW/QmOY0HgFJH6JzhPEjVRgA3Nm1GZDmVIfGCoZFASWh2pvVEGEn Fqk39GMaWYWmlpnABvDH5sg4VIve7QGDR+aswZMp3h7jWnDYgP5eYZffl0AoUvmRhTQbDM7FxY6 C9lh6VH4ZpePRIx6DjelPfdgsn+MlET0fqybU8VWxaJgeVd9lQPcQ/Rcj2JWArgWUvF/dqwz7bY JeeeoQK1rQa8DDtxWj0RlY7prXRUKMPcfMqHTpo15QvEkD00cwr52ls9hsZ+lSe/dw== X-Received: by 2002:a05:6000:1f88:b0:385:e176:4420 with SMTP id ffacd0b85a97d-38c5194da70mr2305422f8f.10.1738151685456; Wed, 29 Jan 2025 03:54:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUbIgz0SPBde6y+6m4GBK9jxdSxFJzhj9pSmwm9jjlsojNxFlCvTBxohQUGPQAzMIjP8ET+w== X-Received: by 2002:a05:6000:1f88:b0:385:e176:4420 with SMTP id ffacd0b85a97d-38c5194da70mr2305401f8f.10.1738151685052; Wed, 29 Jan 2025 03:54:45 -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-438dcc2ef08sm20681625e9.22.2025.01.29.03.54.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:54:43 -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 11/12] mm/rmap: handle device-exclusive entries correctly in page_vma_mkclean_one() Date: Wed, 29 Jan 2025 12:54:09 +0100 Message-ID: <20250129115411.2077152-12-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: V_hpEI_1Arew1g4GELaLatR64rYXz-UIn_zuvFEKVAA_1738151685 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: 729E640007 X-Stat-Signature: 55n4ax9wcz3ie8rkygxfbcrt5qpf9nrz X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1738151690-240985 X-HE-Meta: U2FsdGVkX18JSZrOMH0pYMIPjk/zY6kTDxD8bLeMwkJSuK04Y3mn/ub1gp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otV0TT+pqi+M51evUzQebVnTTkE8g/pEHeMwNdb0nQeXLHWGsNA++H4Q+hExUa/ozqvW8IImvsJORxMQCfskdQ20WhS7898Tr+LjagrGroTrIYds8GHY9hZV4IvAGgnPzQXr8FiNMsYzavi0chZ7NYDogfGEUAvRPbdWEdS7EiBwFJi3/d2ggYmcPU2zRGT0sLceDH537iaoG8GCz/SmdvD3AS9yhCTw90WIyLLcmTtjRQwouHRWbscQllJEycM2Uu08oYjRD6Gli1nI3mUO9UygGF7HCWr1Pw7LFWvhWvSWhGcExVyfBR5t80QcPAnr2rdGwcRV1UFX0Uo7IBjRPR9ChyR6Ue6ke0xy6snEKlqHIqnMF1f+oJj1A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, 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 77b063e9aec4..9e2002d97d6f 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1050,6 +1050,14 @@ static int page_vma_mkclean_one(struct page_vma_mapped_walk *pvmw) pte_t *pte = pvmw->pte; pte_t entry = ptep_get(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 clean and not writable. + */ + if (!pte_present(entry)) + continue; if (!pte_dirty(entry) && !pte_write(entry)) continue;
Ever since commit b756a3b5e7ea ("mm: device exclusive memory access") we can return with a device-exclusive entry from page_vma_mapped_walk(). page_vma_mkclean_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 writable and not dirty from CPU perspective". Note that we could currently only run into this case with device-exclusive entries on THPs. We still adjust the mapcount on conversion to device-exclusive, making the rmap walk abort early (folio_mapcount() == 0) for order-0 folios. We'll fix that next, now that page_vma_mkclean_one() can handle it. Fixes: b756a3b5e7ea ("mm: device exclusive memory access") Signed-off-by: David Hildenbrand <david@redhat.com> --- mm/rmap.c | 8 ++++++++ 1 file changed, 8 insertions(+)