Message ID | 20231220224504.646757-21-david@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-7544-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp55106dyi; Wed, 20 Dec 2023 14:49:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMDMbgkvRUYcfgS5Ql+XeyZiCtnfxkViuyZ9ltjaNfemGInPGGYcYkihcXgPZ4w/BdvNsJ X-Received: by 2002:a17:906:3f4b:b0:a1c:8af6:a19b with SMTP id f11-20020a1709063f4b00b00a1c8af6a19bmr9863720ejj.10.1703112592350; Wed, 20 Dec 2023 14:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703112592; cv=none; d=google.com; s=arc-20160816; b=kF+dC9iXGkWcQQ5jLDMAB7lUVPDKH3CLboFFc717w3j7X6A0MR5Yt4SknYAZvpOh/j I9EjvR1BBWAEaVGEwI7eES+O3vLOe7JshXS6/jdqm1SIKanfzXm2yumaUhS4Na2XGgz6 BVYWFtZJfct3qX/1Ygj8ztxrvCl/6XCs5mZgmZ1HFI1GBYYx7U6IjcwYygAOar8mGacQ 4katwzMIFS/QTA9cD6SyzITlxr0vU8/i8R7yUJzFpKz5ARQR7Uw56V6pY350w0H5qHDp lfZFzGvZmBU3gceeEvu/f74Z35KxGEqBpRY2v6rMy8JTcXH8dymiNNtpNEZ3/CDSZGCU vHNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9Tzzmpk6zqHgghmJ+i7focJ8fdDU2jQOAW0uh5TyPi4=; fh=UlFXU+hKOMcm6idRzNfe3Pu+B5L1f7aeir3C6i/NWQA=; b=xKhJSDeUtR1ZzWtXLpvcndHUbzOdV9fcy3yuBoiA17IUZVKyFjBXJ8QkP9WDwXt9YT ExK+di9zI2yq9popwmcUufu+45G0D9ojQVA0RYkThmG9Gku/YvuQJTQJZnxyFrsed1bS spB2g0M3D7oeS/HEcCEdsoHefg5u0lGryuihWnGg02ls2rObQ4sCpogjoKr+WTYfBe1Z eITr8OuYxb3Wv81kr1wtSuWYX53U2QOGqc8b9oeTNaNB4UA+BBQvfJvMga2jDa0BgkBf k+nIkKoLqqvLSgXwzyMrrTQEZ+Tp2Sr4OMpnnSUUvN7m+oGqFBUksNc3kOdHbBFVSx1H dkHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TZmH7XcE; spf=pass (google.com: domain of linux-kernel+bounces-7544-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7544-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id zt15-20020a170907088f00b00a1b60e9bed7si230439ejb.79.2023.12.20.14.49.52 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:49:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7544-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TZmH7XcE; spf=pass (google.com: domain of linux-kernel+bounces-7544-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7544-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F13021F2437F for <ouuuleilei@gmail.com>; Wed, 20 Dec 2023 22:49:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECD474EB5F; Wed, 20 Dec 2023 22:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TZmH7XcE" X-Original-To: linux-kernel@vger.kernel.org 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 100784EB32 for <linux-kernel@vger.kernel.org>; Wed, 20 Dec 2023 22:46:04 +0000 (UTC) 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703112364; 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=9Tzzmpk6zqHgghmJ+i7focJ8fdDU2jQOAW0uh5TyPi4=; b=TZmH7XcEH6I+TnAUQC5PbvA8H4rjhL8hcY9nXHqOm0Wv8wNTilU1/qPY4/tuwHenBbIRqY fjikaA5glv0y5iRtkTNcmyWsVXCddkWTasyKfIWm2UVOO1HgQljY3spt+UbY1PFDOW6Y2n KR+tZXbIGUHuPk3iVlprPeH6M1j6EgM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-LliV0quuP_Oqxcmuv5B2DA-1; Wed, 20 Dec 2023 17:46:00 -0500 X-MC-Unique: LliV0quuP_Oqxcmuv5B2DA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E106486EB20; Wed, 20 Dec 2023 22:45:59 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD18440C6EB9; Wed, 20 Dec 2023 22:45:57 +0000 (UTC) From: David Hildenbrand <david@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Hugh Dickins <hughd@google.com>, Ryan Roberts <ryan.roberts@arm.com>, Yin Fengwei <fengwei.yin@intel.com>, Mike Kravetz <mike.kravetz@oracle.com>, Muchun Song <muchun.song@linux.dev>, Peter Xu <peterx@redhat.com> Subject: [PATCH v2 20/40] mm/memory: page_add_anon_rmap() -> folio_add_anon_rmap_pte() Date: Wed, 20 Dec 2023 23:44:44 +0100 Message-ID: <20231220224504.646757-21-david@redhat.com> In-Reply-To: <20231220224504.646757-1-david@redhat.com> References: <20231220224504.646757-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785842989630958459 X-GMAIL-MSGID: 1785842989630958459 |
Series |
mm/rmap: interface overhaul
|
|
Commit Message
David Hildenbrand
Dec. 20, 2023, 10:44 p.m. UTC
Let's convert restore_exclusive_pte() and do_swap_page(). While at it,
perform some folio conversion in restore_exclusive_pte().
Signed-off-by: David Hildenbrand <david@redhat.com>
---
mm/memory.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c index c77d3952d261f..6552ea27b0bfa 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -710,6 +710,7 @@ static void restore_exclusive_pte(struct vm_area_struct *vma, struct page *page, unsigned long address, pte_t *ptep) { + struct folio *folio = page_folio(page); pte_t orig_pte; pte_t pte; swp_entry_t entry; @@ -725,14 +726,15 @@ static void restore_exclusive_pte(struct vm_area_struct *vma, else if (is_writable_device_exclusive_entry(entry)) pte = maybe_mkwrite(pte_mkdirty(pte), vma); - VM_BUG_ON(pte_write(pte) && !(PageAnon(page) && PageAnonExclusive(page))); + VM_BUG_ON_FOLIO(pte_write(pte) && (!folio_test_anon(folio) && + PageAnonExclusive(page)), folio); /* * No need to take a page reference as one was already * created when the swap entry was made. */ - if (PageAnon(page)) - page_add_anon_rmap(page, vma, address, RMAP_NONE); + if (folio_test_anon(folio)) + folio_add_anon_rmap_pte(folio, page, vma, address, RMAP_NONE); else /* * Currently device exclusive access only supports anonymous @@ -4075,7 +4077,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) folio_add_new_anon_rmap(folio, vma, vmf->address); folio_add_lru_vma(folio, vma); } else { - page_add_anon_rmap(page, vma, vmf->address, rmap_flags); + folio_add_anon_rmap_pte(folio, page, vma, vmf->address, + rmap_flags); } VM_BUG_ON(!folio_test_anon(folio) ||