From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1A433D3301 for ; Tue, 3 Feb 2026 18:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770142662; cv=none; b=llEpuQUDgYg5oRKownbT/sxmbC1jf/Xzyl+aB/QX8678L2vpvowxYDhaIgPw7JFb+VfpKRVzb386khoOp8PFCg12RgSPGWCCHL1xt9OVf7PkAxdgXGhLc//4TxhZDj5UoR8xbd1OwuCVw2FWjQV7f1Dq101oYH886/2w2IGJItc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770142662; c=relaxed/simple; bh=ZjEDhUAqz3NmS64bm1ZecuDnM+cluhzlt4kqj7tlUQo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KD4jkf4a2SkoTBSfgvVrr49eAkHbxijCjUBYVrZukACYk98Mk6aBl3CVgvj1LCkg9WPRLmBvwoH2Ur6+prLcBwbHMIxpM6+7vT2dy9qwlkJPiTsFp0K5K2ZNNjXvPv1rid9vwXjOOTvyibBvyyalgRsIaf+XT53vNYh7Sn9rg/Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E9A69339; Tue, 3 Feb 2026 10:17:31 -0800 (PST) Received: from arm.com (arrakis.cambridge.arm.com [10.1.197.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EAA573F740; Tue, 3 Feb 2026 10:17:36 -0800 (PST) Date: Tue, 3 Feb 2026 18:17:33 +0000 From: Catalin Marinas To: Arnd Bergmann Cc: Will Deacon , Arnd Bergmann , Anshuman Khandual , Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: hugetlbpage: avoid unused-but-set-parameter warning (gcc-16) Message-ID: References: <20260203162147.2103175-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260203162147.2103175-1-arnd@kernel.org> On Tue, Feb 03, 2026 at 05:21:23PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > gcc-16 warns about an instance that older compilers did not: > > arch/arm64/mm/hugetlbpage.c: In function 'huge_pte_clear': > arch/arm64/mm/hugetlbpage.c:369:57: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter=] > > The issue here is that __pte_clear() does not actually use its second > argument when CONFIG_ARM64_CONTPTE is disabled. > > Reword this to compute the offset each time instead of updating the > argument variable. I checked that the resulting object code is > unchanged. > > Signed-off-by: Arnd Bergmann > --- > arch/arm64/mm/hugetlbpage.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > index a42c05cf5640..4ad7662e8323 100644 > --- a/arch/arm64/mm/hugetlbpage.c > +++ b/arch/arm64/mm/hugetlbpage.c > @@ -374,8 +374,8 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr, > > ncontig = num_contig_ptes(sz, &pgsize); > > - for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) > - __pte_clear(mm, addr, ptep); > + for (i = 0; i < ncontig; i++, ptep++) > + __pte_clear(mm, addr + pgsize*i, ptep); Should we not fix the macro instead? Either with a (void)(addr) or just turn it into an inline function (still compiling): diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 64d5f1d9cce9..c248b033a472 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -179,8 +179,6 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) #define pte_none(pte) (!pte_val(pte)) -#define __pte_clear(mm, addr, ptep) \ - __set_pte(ptep, __pte(0)) #define pte_page(pte) (pfn_to_page(pte_pfn(pte))) /* @@ -1320,6 +1318,12 @@ static inline bool pud_user_accessible_page(pud_t pud) /* * Atomic pte/pmd modifications. */ +static inline void __pte_clear(struct mm_struct *mm, + unsigned long addr, pte_t *ptep) +{ + __set_pte(ptep, __pte(0)); +} + static inline int __ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)