From patchwork Wed May 8 19:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13659107 Return-Path: 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 31288C04FFE for ; Wed, 8 May 2024 19:26:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B707E6B00A2; Wed, 8 May 2024 15:26:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B20A96B00A3; Wed, 8 May 2024 15:26:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C2146B00A4; Wed, 8 May 2024 15:26:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 801AA6B00A2 for ; Wed, 8 May 2024 15:26:47 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2D8F612014E for ; Wed, 8 May 2024 19:26:47 +0000 (UTC) X-FDA: 82096210854.23.D7BA724 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by imf05.hostedemail.com (Postfix) with ESMTP id 32D4B10000C for ; Wed, 8 May 2024 19:26:45 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=HsqPgOFP; spf=pass (imf05.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715196405; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7NXxlYw1RM9+WdFNtDaqsh0kbg9AU8PQDaN/vzezo7A=; b=0HhjkS7lbWHF4gDmYwotKG4DA1aDHPJ2LWc0yUR02D1h4pd+O0itp6Dke2b0VOyan+HgQD zZmeP8oL/LN09yIcldvY+8pWF1w3nJAg5MKvBRlnDXHTIsbz1RXdUnnLzfbbf5vdYxKyU/ K1cmdOSeEnHViz2BpL5MpK18lMUIBbQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=HsqPgOFP; spf=pass (imf05.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715196405; a=rsa-sha256; cv=none; b=YyqcJdKMNT7YefqC1UY86UbHTCDRnduPgnKOH0eHeGJlv7WZ2TbYuFpXhcBi+u0N6ugPxC KfhBHXmi1mJSR/JSpv/c9EXCML91yIvsgnIgMnH/3ULmlgQ7yYRRM/oGyyxTIwXh2+YQsz bEKtjIQRU46O1ZFUhmCb6o82LmeVGyA= Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-41b5dd5af48so711345e9.0 for ; Wed, 08 May 2024 12:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715196404; x=1715801204; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7NXxlYw1RM9+WdFNtDaqsh0kbg9AU8PQDaN/vzezo7A=; b=HsqPgOFPNEQuyHedLsnJS07Cn8zDRBI77vPsOxelulOwqtybJOhKSI4Z2C9ei8bO93 gkLNZoAFdClS7ird0DLxA3/IciET+ojj0eAfVhpMYEvL/MCfsKTJAwIrFtN1uhEXaHQh zRLhCr6pH0fjfd2UAPxG2R+7R34/M5NOTv/pX6NiXpzawako47/zuuc0cGFAHTUQtWA7 XNxQsvHtFitVGktY1HprrRf3hIu22A3l1iEv7aRza7M2Sg116fY/2tNPjj/fy3g/qKyz rbXDFVGX5gjbIR9dTkSHP2lyQ6MKmHH0GYgGSgaWVaP8afAZ0y1opM2HDNWjvxO7xmi2 ds9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715196404; x=1715801204; 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=7NXxlYw1RM9+WdFNtDaqsh0kbg9AU8PQDaN/vzezo7A=; b=aDMTR/z/TNDKfYUgvIkmuJUUH3GoTiOCq6rPLlipU696lzgGN+7VR+JOnxGTSdNCQd x/+J6oADlna2QGSqpVVyAIsyu3OnUIWjJZLSeW4nfe/JBDH2DByNdBc36bNVy8dHRrLQ PSaK8LnWe+GBcRyqxTUc5iue1885EXdSAOlSggrgrpOpUPcLU/NNYYRCT3GzqzXFqEEb eDAlTuUMKwqvODCew8hARU0xdj7WrtIMyjU6EbbfD8GXV8KLQZkJSD2Vq7Vo7X1hHY/7 XS3xwKrNqlxw1u7Z25FpFKB1nYakY/ms6fUs4ordngTzoeSu+K7elci5Dk+Ab9iyU0Aa +J7A== X-Forwarded-Encrypted: i=1; AJvYcCV7W2Frm3J3VvSBzzNQPTNb/EgyfvMSu8A+gagi3s1dIJXbCRMJ18y9kxB7/tYkFjxEM6H3Y73UgNQYU3bEzquItuw= X-Gm-Message-State: AOJu0YyaZiWAp3tYuhZcv1nSOynpUtCyOjFgv3wGpKQyREbyGJAcWQGn D6EhVwPnPNtGMZbU9TleCOv8Rr+IDC3wMi4RacUevordU8hrUAvC8AG4zu4/dFw= X-Google-Smtp-Source: AGHT+IGACzzezThLxVMxwcYVQ6pqU/BhrbSjplAZdXD5UPpMsvfoJ1LwcNLet4jFhPFrbMRRJqyyWw== X-Received: by 2002:a5d:4522:0:b0:34c:bb79:452b with SMTP id ffacd0b85a97d-34fca62159dmr2733749f8f.52.1715196403826; Wed, 08 May 2024 12:26:43 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id o16-20020adfcf10000000b0034b1bd76d30sm15921429wrj.28.2024.05.08.12.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 12:26:43 -0700 (PDT) From: Alexandre Ghiti To: Ryan Roberts , Catalin Marinas , Will Deacon , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Paul Walmsley , Palmer Dabbelt , Albert Ou , Ard Biesheuvel , Anup Patel , Atish Patra , Andrey Ryabinin , Andrey Konovalov , Vincenzo Frascino , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-riscv@lists.infradead.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH 07/12] mm, riscv, arm64: Use common ptep_get_and_clear() function Date: Wed, 8 May 2024 21:19:26 +0200 Message-Id: <20240508191931.46060-8-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240508191931.46060-1-alexghiti@rivosinc.com> References: <20240508191931.46060-1-alexghiti@rivosinc.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 32D4B10000C X-Rspamd-Server: rspam06 X-Stat-Signature: u7ncsaunmmc858g6umg3ag5gd61s16eo X-HE-Tag: 1715196405-336581 X-HE-Meta: U2FsdGVkX19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FMCqMA9puG9DTXORv+8lRq8EvgJEKjCxPwXmonCBRJ+UdWqWv06BkbdPpxRKLOesTGe1OAKH9xkyL+76uaXqygI/KFQeTPYsYMGkVeUPXKetY5KhoIp1nhfDPZ3wA9t3mPBs24xdH6wtDi8odpeh1MltGyHpb2USHHQk/oTg9jxYrmVRFAuCFJYyljsWuU812gL+G1NwLQN4nNVaiu5S6+MJ4Bp/PjpcudUS2Rch12BgJP4qUetvJ8tJrjkn91+QHT8pxc83PFR6gthaqMDUS/6k8SDA3ZBG6ucnQZsbOr0dPHN8voeN2CfBtSJaS23ZT/ReEhJc9lIN/Jn9KuwvQcAE+1odom6yz92gep9cOS6uRKvr1jizGHiNWD1W7B0TxawpQpAWXfD7Z9cAr7CYZvsXGtbR3CFcT1VxRYx1ZiD0x3GoKVlZjjRKwqZIMd6eMxft1o+uje2ua7aIA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Make riscv use the contpte aware ptep_get_and_clear() function from arm64. Signed-off-by: Alexandre Ghiti --- arch/arm64/include/asm/pgtable.h | 8 ++------ arch/riscv/include/asm/pgtable.h | 7 +++++-- mm/contpte.c | 8 ++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 74e582f2884f..ff7fe1d9cabe 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1473,12 +1473,8 @@ static inline pte_t get_and_clear_full_ptes(struct mm_struct *mm, } #define __HAVE_ARCH_PTEP_GET_AND_CLEAR -static inline pte_t ptep_get_and_clear(struct mm_struct *mm, - unsigned long addr, pte_t *ptep) -{ - contpte_try_unfold(mm, addr, ptep, __ptep_get(ptep)); - return __ptep_get_and_clear(mm, addr, ptep); -} +extern pte_t ptep_get_and_clear(struct mm_struct *mm, + unsigned long addr, pte_t *ptep); #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 41534f4b8a6d..03cd640137ed 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -794,6 +794,9 @@ extern void set_pte(pte_t *ptep, pte_t pte); #define set_pte set_pte extern void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); #define pte_clear pte_clear +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +extern pte_t ptep_get_and_clear(struct mm_struct *mm, + unsigned long addr, pte_t *ptep); #else /* CONFIG_THP_CONTPTE */ @@ -801,11 +804,11 @@ extern void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); #define set_ptes __set_ptes #define set_pte __set_pte #define pte_clear __pte_clear +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +#define ptep_get_and_clear __ptep_get_and_clear #endif /* CONFIG_THP_CONTPTE */ -#define __HAVE_ARCH_PTEP_GET_AND_CLEAR -#define ptep_get_and_clear __ptep_get_and_clear #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS #define ptep_set_access_flags __ptep_set_access_flags #define __HAVE_ARCH_PTEP_SET_WRPROTECT diff --git a/mm/contpte.c b/mm/contpte.c index c9eff6426ca0..5bf939639233 100644 --- a/mm/contpte.c +++ b/mm/contpte.c @@ -46,6 +46,7 @@ * - ptep_get_lockless() * - set_pte() * - pte_clear() + * - ptep_get_and_clear() */ pte_t huge_ptep_get(pte_t *ptep) @@ -682,4 +683,11 @@ void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) contpte_try_unfold(mm, addr, ptep, __ptep_get(ptep)); __pte_clear(mm, addr, ptep); } + +pte_t ptep_get_and_clear(struct mm_struct *mm, + unsigned long addr, pte_t *ptep) +{ + contpte_try_unfold(mm, addr, ptep, __ptep_get(ptep)); + return __ptep_get_and_clear(mm, addr, ptep); +} #endif /* CONFIG_THP_CONTPTE */