From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-114.mta1.migadu.com [95.215.58.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3918C429CD0 for ; Fri, 2 Oct 2026 09:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.114 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790934972; cv=none; b=LzOQD5nt+AR9fSbkxQV1BDkSkQN0t/MhcfRlnR7FaVdS0MsLNGqQwiIi0FjTFpDOHoR5A7uAsyWph/88/IgMMwKF3k+etICpHVRHNfmRjkKTdBucRn12UoVwDVWTgE/oLlwUyR1cdj9dTrdsY1NBnw9i4cP+KuMIRw/a1Tup1p4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790934972; c=relaxed/simple; bh=xkb7MkR54E2nqz4EqcW/yiNvszHDEep7fC71s6pB1co=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g5L1fvgbLGeel328yE39iePrrEgsz9bZdl9en2b8vdJvxmVkyqvbygD4ReelVZRBdYzCweZ63DDBt1O4zPeDO/nKouhQRT/WrFID9hmtjdDvaHD350HueBJyErBGdZYRjSUN5B6u0m4e0fbQ4V0MdRX7FAnJ5PjzGV9r3D7IOtE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=FRvb8BC8; arc=none smtp.client-ip=95.215.58.114 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="FRvb8BC8" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=xkb7MkR54E2nqz4EqcW/yiNvszHDEep7fC71s6pB1co=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1790934969; v=1; x=1791539769; b=FRvb8BC8jNZDzn3n5eorUjYsDvxPs2NJklKrorbDwP10aquuH9AQcMJbI2zOWACc6p0e2EXf AZBI0zJ0hU3NGxYCGgK5twa61YNPG/ccgZFu2inLu9cY14ykgSEQL5Fg7J0Ye3p/HvF26kj8wd5 W6LZT38VMhL9bQ0O7tdEQQ9Q= X-Envelope-To: linux-kernel@vger.kernel.org Received: by mta11.migadu.com with ESMTPS id 13f9800596f01563; Fri, 02 Oct 2026 09:56:08 +0000 X-Mizu-Trace-ID: 13f9800596f01563 X-Migadu-Flow: FLOW_OUT From: Usama Arif To: Andrew Morton , david@kernel.org, chrisl@kernel.org, kasong@tencent.com, ljs@kernel.org, ziy@nvidia.com, linux-mm@kvack.org Cc: ying.huang@linux.alibaba.com, Baoquan He , willy@infradead.org, youngjun.park@lge.com, hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, alex@ghiti.fr, kas@kernel.org, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, Nico Pache , Liam R. Howlett , ryan.roberts@arm.com, Vlastimil Babka , lance.yang@linux.dev, linux-kernel@vger.kernel.org, nphamcs@gmail.com, shikemeng@huaweicloud.com, yosry@kernel.org, qi.zheng@linux.dev, luizcap@redhat.com, kernel-team@meta.com, Usama Arif , Paul Walmsley , Palmer Dabbelt , Albert Ou Subject: [PATCH v8 05/30] riscv: mm: add PMD swap-exclusive helpers Date: Fri, 2 Oct 2026 02:52:19 -0700 Message-ID: <20261002095503.3585565-6-usama.arif@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261002095503.3585565-1-usama.arif@linux.dev> References: <20261002095503.3585565-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Prepare for keeping a PMD-mapped anonymous THP mapped by a PMD across the swap round-trip, which makes PG_anon_exclusive have to survive in a swap PMD and not just in a swap PTE. riscv encodes a swap PMD exactly like a swap PTE, so the new helpers wrap the PTE ones and reuse _PAGE_SWP_EXCLUSIVE. Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Signed-off-by: Usama Arif Reviewed-by: David Hildenbrand (Arm) --- arch/riscv/include/asm/pgtable.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index d48f90140841e..b644db16bda94 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -1219,6 +1219,21 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) } #ifdef CONFIG_ARCH_HAS_PMD_SOFTLEAVES +static inline bool pmd_swp_exclusive(pmd_t pmd) +{ + return pte_swp_exclusive(pmd_pte(pmd)); +} + +static inline pmd_t pmd_swp_mkexclusive(pmd_t pmd) +{ + return pte_pmd(pte_swp_mkexclusive(pmd_pte(pmd))); +} + +static inline pmd_t pmd_swp_clear_exclusive(pmd_t pmd) +{ + return pte_pmd(pte_swp_clear_exclusive(pmd_pte(pmd))); +} + #define __pmd_to_swp_entry(pmd) ((swp_entry_t) { pmd_val(pmd) }) #define __swp_entry_to_pmd(swp) __pmd((swp).val) #endif /* CONFIG_ARCH_HAS_PMD_SOFTLEAVES */ -- 2.53.0-Meta