Received: by 2002:a05:7412:a9a8:b0:f9:92ae:e617 with SMTP id o40csp24681rdh; Wed, 20 Dec 2023 14:49:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8c3BJj+BSM4Bbm1h5/IrBnRj6ftgyKpQwhEisNXMcWobnPK9aICouz6hxOOBhsJB4AzwM X-Received: by 2002:ad4:5d44:0:b0:67f:660f:7754 with SMTP id jk4-20020ad45d44000000b0067f660f7754mr4913776qvb.78.1703112591506; Wed, 20 Dec 2023 14:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703112591; cv=none; d=google.com; s=arc-20160816; b=ZI2C3ORhS3HOYI+zvo4++sBBUpBYTby7v3K+6/6Ph0N7fOHE8P+7j/zgNiQiWe1kx5 dpIPJELvJ4ndAUzERRcQ3DFZEjo0d+2eB8zb7w3xNrRJxTytqorc6AueSu3YrekUy7SO 55uIfD/6+zwif65PkeQZ5HNdBfDdUc5t8kB4DMCqJjSi09FaVu2N17VVJyatwYrUpLKC nk5hNLPb2ohTCd9z7OkuUp9MwDRBj8T/mQP6v0R3gm/c4eCdEI2RIFakUL8ZylRSG/6+ 3wdzd+qDR0EHP9xYMNSIIffdWtrchSGk9/ChDwUisETewrYy3+LmgVihrIE8YUEeY+m6 R9IA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r2-20020a0ce282000000b0067f0f922a03si687124qvl.460.2023.12.20.14.49.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:49:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7544-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7544-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 122F71C232A2 for ; Wed, 20 Dec 2023 22:49:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DDE64EB4D; Wed, 20 Dec 2023 22:46:07 +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 ; 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 To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Hugh Dickins , Ryan Roberts , Yin Fengwei , Mike Kravetz , Muchun Song , Peter Xu 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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 --- 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) || -- 2.43.0