Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp169798lqg; Fri, 1 Mar 2024 01:20:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXPP/2mh2nzWPzR524onvhJ1OnPZvzHdjAvxEAgUeKTZqups1EpGQVB+eImPy1yacFgCY/XQNlC7CoF1vvcJMqunz8e1np/lt4VUK4i4w== X-Google-Smtp-Source: AGHT+IFAd49hOF2EqZUt6pSd7XfJN4AsWgupaLcjA0Gtzo0QueFx2LpLaIPdNFUq3XsLp2PCd+ED X-Received: by 2002:aa7:da8b:0:b0:561:f2b1:a68 with SMTP id q11-20020aa7da8b000000b00561f2b10a68mr1018025eds.20.1709284832785; Fri, 01 Mar 2024 01:20:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709284832; cv=pass; d=google.com; s=arc-20160816; b=tsUvylkICsRfRle48S/Xh2EUSf1gBEPdXX6EcTX3q3Lqz1IEMCfkSkt6YltueYB+k9 zmQZR2aC2A7yPauaxkzxVU4XOvRHr80a2FYNaJgFEpJqmnYqNQg7zOgePk3muY3V7gP2 glpCqMJKOGnZQ7xaJXcnDarFE1NMMO82rPO1cUqL/PMdkNcjk/tIkETC4a4h/AsCoj8w iakpbo5G15hDswX19/Gj5cIj3h0eYhQtVKXwJkWc3TCo3MG51s3yhKofITIKwou5WuJk WNCUm5SGLO1FwsfrIZGtVGpr9noRb9neM9QInkXPPNFpH+prQKc/bewjZs2H8Hu0A8Mx 0nEQ== ARC-Message-Signature: i=2; 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=rdWlfuEJdB5bVZdrcri04Zmq/yhRfMcRDdftEw7qNFA=; fh=V3iMy3oCKyuptVynJIiGa25OJqhd+t3w6cseJIP7JGk=; b=HVzmyQzFDTSvNc5RSoRNXqO2nJ8KqJ81Ibvy0r4aPhcEZzDDGZR3ACb9G/BsNpNMUk oQvVT94D2KRTKID12RpyGnhlzjxZA1FkbjlMdgZfTkkG1VHtyy2uVWflDCezgx30bbMz NuNhjzCbY/DG1ArY4iKEIizm9IbKhItSUHfGzQAeay5OFIlDe3snNHJxDqZdtQNgw/eB 7ZD397yc5vDvE6F7iny9eLT8IxNsO/nxjjQbruEA1QRAfvk4EDpa0pP7drLAeAeZf0G4 97E2e4/9vFqoF9D+TA96Tm78TjjFwSLNlOqK8W0xpd8oEA7dNNYapNYP7QBkNxDSN6Ry 2Unw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=zPCwsrHJ; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-88164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88164-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eb14-20020a0564020d0e00b00564c7885268si1319020edb.103.2024.03.01.01.20.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 01:20:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88164-linux.lists.archive=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=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=zPCwsrHJ; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-88164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88164-linux.lists.archive=gmail.com@vger.kernel.org" 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 79C991F22BB9 for ; Fri, 1 Mar 2024 09:20:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC0E26A8A4; Fri, 1 Mar 2024 09:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="zPCwsrHJ" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 DE5AD6A34B for ; Fri, 1 Mar 2024 09:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709284820; cv=none; b=WpVWFzLVWvAQWKUHn1bXzzjLWzKZ26ZLZyoVWsIE5qvaz89TAYEjZnO/1VdWPFM5cpPqf/YYfpExm2k4vN7KaNp1W8gYmiZxWgQ4bnZNzIIOSKuyAJ+12bXSr9rmQf6BRgCHJkc9PjQIfRIiNfZzFaX7CGXaaw+mJ8IEW44UDjE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709284820; c=relaxed/simple; bh=deJfNqmd+84vDDBO0fDBd8YCdfhsA76uVTjUbdf6HeU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mJOz939GfnMa5SzyKDCcWv5uY2AeAexXHXNUKwGEWPlqWuw3DmiaBYLzseA3Gb6ujyhb4ktRQj8n4g7r6Iyk4nmBV0HXCc/l49fG7D0gFMPUkOgYjQgLxfZiF6qYkG5SqM7sdsjj9fy2JKIe971I4vKbRqtSIKwbIpuSReBiLEE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=zPCwsrHJ; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-412a9e9c776so17909525e9.0 for ; Fri, 01 Mar 2024 01:20:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709284817; x=1709889617; darn=vger.kernel.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=rdWlfuEJdB5bVZdrcri04Zmq/yhRfMcRDdftEw7qNFA=; b=zPCwsrHJ0eOHW1Zv7kbRW3DsboeAnoZUSy0hAXtloUAYPfO4RAkUjsac/X2ewPz05k W6hoat+sjn8uzRpkkIEHZ/bxqUXkMWuIhCymnz5+GL2NRotPD2c3n0Vs9caGI/nP9MAg 7/yY4MVZ4/Pws1E8MFkip8bxCsn/2/k5FrTdIh50aDXYOjZVJD/qLxxN1D5ietqs28Y1 fsrcWfMP+K4AQF1mphtfOYovOE3FA/b8HfnCJkaaBMsr6BGDPQv+24Q318PBfhdK9cEj Vcs2DwNsQFc/qFX6IITboGPZAjyfk+nN2bPmiDjOHbBRPIerGSIGZfpJuCGyt1I6qQMX wBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709284817; x=1709889617; 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=rdWlfuEJdB5bVZdrcri04Zmq/yhRfMcRDdftEw7qNFA=; b=hAsxSpopjcCdoCdM7aXFhbRdCzIZK8lHZmCxLZLSKxmJxwGfP61P1JcIuETRHqHo3u 5TMgj+7NU4UebDQX9TCzjGpEwqPSrN8SLIkLKtZHz9FBfTxvKHBgGkGroLHp1s95i7Tx OtF8J9wmtdIng9sb0zcxHwJfBvIERbiM2MHs+IhECIlI/GZb1g7m3M3EJAovWaqG6xBq 0iXR44l9S4N8OJuKpELb8zt0a+tknS2kSYHkUek1D9FJIVfv0n9hAd7d7ScMYaegZscE MQ4WRp5TnPtOWzMcnSzD4ik9GcMvoV7lFy7CC0fvr2rU62YoSNRINdEsxxAVLB/NGYsX zDLw== X-Forwarded-Encrypted: i=1; AJvYcCWLB7yOdZipiapj6YFKl6mo2Iv92wv2xL9B3KDKuuAOp73nUwtWmhX26uwZjXD1A/fKNdrDMXNh2xsA/7MEbfZ1eEOFugE//2VxnOHc X-Gm-Message-State: AOJu0YxdAZWDJp0UnSK+6oTk5P4Odw2V4rogoJMOhR1jeYNXtN2e+TPC jxlUGOllBwiEEYC+MowPN4hZUVz6qwjJ4WBFLiDCmWbge0Ez0cY2dRnJwaV2kPw= X-Received: by 2002:adf:a3c9:0:b0:33e:21bc:bc6f with SMTP id m9-20020adfa3c9000000b0033e21bcbc6fmr809159wrb.11.1709284817327; Fri, 01 Mar 2024 01:20:17 -0800 (PST) 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 l9-20020a056000022900b0033cf2063052sm3994161wrz.111.2024.03.01.01.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 01:20:17 -0800 (PST) From: Alexandre Ghiti To: Catalin Marinas , Will Deacon , Ryan Roberts , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH 5/9] mm: Use common huge_pte_clear() function for riscv/arm64 Date: Fri, 1 Mar 2024 10:14:51 +0100 Message-Id: <20240301091455.246686-6-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301091455.246686-1-alexghiti@rivosinc.com> References: <20240301091455.246686-1-alexghiti@rivosinc.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 Both architectures have the same implementation so move it to generic code. Signed-off-by: Alexandre Ghiti --- arch/arm64/mm/hugetlbpage.c | 12 ------------ arch/riscv/mm/hugetlbpage.c | 19 ------------------- mm/contpte.c | 13 +++++++++++++ 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 4da951e81bde..09b55bac8c7c 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -284,18 +284,6 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags) return entry; } -void huge_pte_clear(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, unsigned long sz) -{ - int i, ncontig; - size_t pgsize; - - ncontig = arch_contpte_get_num_contig(NULL, sz, &pgsize); - - for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - pte_clear(mm, addr, ptep); -} - pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index ebc735f5d325..01b1403dd4cb 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -254,25 +254,6 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, return get_clear_contig_flush(vma->vm_mm, addr, ptep, pte_num); } -void huge_pte_clear(struct mm_struct *mm, - unsigned long addr, - pte_t *ptep, - unsigned long sz) -{ - size_t pgsize; - pte_t pte = ptep_get(ptep); - int i, pte_num; - - if (!pte_napot(pte)) { - pte_clear(mm, addr, ptep); - return; - } - - pte_num = arch_contpte_get_num_contig(ptep, 0, &pgsize); - for (i = 0; i < pte_num; i++, addr += pgsize, ptep++) - pte_clear(mm, addr, ptep); -} - static bool is_napot_size(unsigned long size) { unsigned long order; diff --git a/mm/contpte.c b/mm/contpte.c index f7bfa861c6a1..5200c234404d 100644 --- a/mm/contpte.c +++ b/mm/contpte.c @@ -19,6 +19,7 @@ * This file implements the following contpte aware API: * huge_ptep_get() * set_huge_pte_at() + * huge_pte_clear() */ pte_t huge_ptep_get(pte_t *ptep) @@ -101,3 +102,15 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, set_contptes(mm, addr, ptep, pte, ncontig, pgsize); } + +void huge_pte_clear(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, unsigned long sz) +{ + int i, ncontig; + size_t pgsize; + + ncontig = arch_contpte_get_num_contig(ptep, sz, &pgsize); + + for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) + pte_clear(mm, addr, ptep); +} -- 2.39.2