From patchwork Fri Mar 1 09:14:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13578199 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 BE326C5475B for ; Fri, 1 Mar 2024 09:20:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEA916B00A1; Fri, 1 Mar 2024 04:20:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9B0E6B00A0; Fri, 1 Mar 2024 04:20:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C62956B00A1; Fri, 1 Mar 2024 04:20:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B29296B009F for ; Fri, 1 Mar 2024 04:20:20 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 841A816106E for ; Fri, 1 Mar 2024 09:20:20 +0000 (UTC) X-FDA: 81847924200.27.D5CBCF7 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by imf07.hostedemail.com (Postfix) with ESMTP id C348540014 for ; Fri, 1 Mar 2024 09:20:18 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=CY5QjhmR; spf=pass (imf07.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.50 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=1709284818; 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=rdWlfuEJdB5bVZdrcri04Zmq/yhRfMcRDdftEw7qNFA=; b=ppnnuqyOd/ZsToq2RMOLQsKzGaH7p0cnwkmC1BAGKjcZX2B9ft/DAEX2jtxxeyYMiu4lxD NDvRXrW3Sz8H9mNoLAq8sEMVKN+J/ldUSuW9w28jSSft/u2hvU1xSImHdmbhukyJ4D9yyL vJqKVlqjH0phk5pWGZ20OasiOKLXzaQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709284818; a=rsa-sha256; cv=none; b=Yz/5Pqk9CJqBFhw942BYb3FelDyfNtBV7NJk3sIbrFEFFLeR99Z5V9wvNu1bHgoUlx2lrA iU4F9DbqFWDecQyKGnn09/z/eD4yQEfrZm8KrPutmPVUED/J7kjG6beIBepa5Hh2JLIVPJ HHJW9U6x+sf8AbuRSwj92pN5UWGFlkA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=CY5QjhmR; spf=pass (imf07.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com; dmarc=none Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-412bb23e5c5so10031075e9.1 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=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=rdWlfuEJdB5bVZdrcri04Zmq/yhRfMcRDdftEw7qNFA=; b=CY5QjhmR5Wgy4JH6hhxyPii6FtmI1o3PGz8OSOjKRwb+/Id6LBBcCYZWUNXYkkBbjr aCAg6dasIkcwT5WDiJHNvKk7KswTeiXUeGk7fKCs6hSAHN4R6G14ROByu/DqC5qMiUcb gwAS9qIPU/OI353fMEhGT6R/MXURxvtc+9kEJEVoi5+YUwGKNxOYGTK8Hyr8GSmS4GUU O4DJduUUQopfW1Pcau2k4EFQNOf7uvGRAapgA+PJzdXlnWs+gUNP9O82dyVvxbZjM2Rl q0FUyzOSWq0bVvJ5DmVhcrXXCv7JTPF3lny+qkZ2mlMIWbcZBPxWmgTpNJYjx+9f2eVC Ov0g== 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=AF9jvZwDz7nkfO8s+DY47YknvvTNaQXaivvl0SAhLroytVqYiPWo3Fzm0zL6W/ZrCQ rpvFJkbU2St6z1VmzUBqpeC29uNG1p0xKWvreJAVU3/6rLZBiYG11b7yhaEmz81FdDDT QogzT6t1Sh1XUWQn7pOsWkFbfb9BKrnivHqjQaqvOKrJmQmwORRITvjpGRx1rA83X3ld nRVada8QKrHJR4y9yuejYZ6yh7nbtUABSXkVrwTaNI3lWg8xuoeDCFy6lBdF0/z21kYJ gwFBEdEO+0nohK/mnE/lLNDmkvFg+jjAhQYfc1Dco20nvR4QnpGQ4/5SwikAvzZW7Oo3 sjZQ== X-Forwarded-Encrypted: i=1; AJvYcCVklxZxjUr2h1YD06jYmeCXx3UUvtZ36JaVkol6bfPXM1LKt2U/7JopNrUzTBRgbwOxKlFqyoHwX00DEIYC1k4/hnk= X-Gm-Message-State: AOJu0YyPjWOHwGkl+J7nUTF89tKfhd2WsKv9f6fqQH3gmrDPRiP85Weq Ig9/0zcdWRVPn90HRNEx51YqmYwL/02tFWeIsRK8J37/7JX9pEduyHjXAliOxGU= X-Google-Smtp-Source: AGHT+IHirYUWWAQ3EzQ3D3sM4w5kbNmWdiMfyHww76VDivA5fk7+UlmhKkRo6vORNs4FOsSe8ylbjw== 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> MIME-Version: 1.0 X-Stat-Signature: coyg8fo4zoiqm5s77frteu1swxr1ne88 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C348540014 X-Rspam-User: X-HE-Tag: 1709284818-21644 X-HE-Meta: U2FsdGVkX19OuDy0luEE4lK13jCarJp0NA41GgmzmANzWgZqd+ot7SUa/gQCVcbShkG/YQ/uz0pvcuPLUGE8F7hIkFK2sQt39S/qsN07obGtZ0bFKRZW9oAWypBAUn7J8d/Gj0jkj+CRX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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: 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); +}