From mboxrd@z Thu Jan 1 00:00:00 1970 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 811D1C433EF for ; Mon, 27 Jun 2022 06:18:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB1288E0001; Mon, 27 Jun 2022 02:18:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E62196B0072; Mon, 27 Jun 2022 02:18:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D774B8E0001; Mon, 27 Jun 2022 02:18:48 -0400 (EDT) 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 C74976B0071 for ; Mon, 27 Jun 2022 02:18:48 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 93C8233E7D for ; Mon, 27 Jun 2022 06:18:48 +0000 (UTC) X-FDA: 79623012336.27.DC82900 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP id EBD3D140014 for ; Mon, 27 Jun 2022 06:18:47 +0000 (UTC) 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 10B471758; Sun, 26 Jun 2022 23:18:47 -0700 (PDT) Received: from [10.162.42.6] (unknown [10.162.42.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B19AE3F5A1; Sun, 26 Jun 2022 23:18:43 -0700 (PDT) Message-ID: Date: Mon, 27 Jun 2022 11:48:40 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] mm: hugetlb: kill set_huge_swap_pte_at() Content-Language: en-US To: Qi Zheng , mike.kravetz@oracle.com, songmuchun@bytedance.com, akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20220626145717.53572-1-zhengqi.arch@bytedance.com> From: Anshuman Khandual In-Reply-To: <20220626145717.53572-1-zhengqi.arch@bytedance.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf26.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656310728; a=rsa-sha256; cv=none; b=78RFCM4kDFYGUDDgohKz+4YJJrTTKFdiFzFjdAK3ykqucBVDz00+YCBF8o4zrLTJgg7G/k 5ZxMt0r0TNPhsqRCCCQtjVnv4QMYnD076dQzzFvlelI1tILVeJ2InFR7cHogyrleiQxuWv N92b00/5LuoNQXq0xUpsocd2P9RZ6Vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656310728; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AHqNw5obln3mF68tpV8o6HjRflBPZr5mSB3BrK3bRSI=; b=DYha1SvXG4rab51+jBFYGzvdJA3iRg3bqe5jom+foZKRwfCCdJs0y91bI8xKOLnWiIgf0V cpl5k37auQzOQ+XiWN3uErTV17IsuMZLED279Qs0naTzb4RdonqmqPXwc+i2Sh44S+ZBjS e2lt8GWv0dES05uobr5nLC4pMZiM/Jw= X-Stat-Signature: n8g4jtxafzngwnxyum7qr6azhf9jsws7 X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: EBD3D140014 Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf26.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-HE-Tag: 1656310727-523293 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: On 6/26/22 20:27, Qi Zheng wrote: > The commit e5251fd43007 ("mm/hugetlb: introduce set_huge_swap_pte_at() > helper") add set_huge_swap_pte_at() to handle swap entries on > architectures that support hugepages consisting of contiguous ptes. > And currently the set_huge_swap_pte_at() is only overridden by arm64. > > The set_huge_swap_pte_at() provide a sz parameter to help determine > the number of entries to be updated. But in fact, all hugetlb swap > entries contain pfn information, so we can find the corresponding > folio through the pfn recorded in the swap entry, then the folio_size() > is the number of entries that need to be updated. > > And considering that users will easily cause bugs by ignoring the > difference between set_huge_swap_pte_at() and set_huge_pte_at(). > Let's handle swap entries in set_huge_pte_at() and remove the > set_huge_swap_pte_at(), then we can call set_huge_pte_at() > anywhere, which simplifies our coding. > > Signed-off-by: Qi Zheng > --- > arch/arm64/include/asm/hugetlb.h | 3 --- > arch/arm64/mm/hugetlbpage.c | 34 ++++++++++++++++---------------- > include/linux/hugetlb.h | 13 ------------ > mm/hugetlb.c | 8 +++----- > mm/rmap.c | 11 +++-------- > 5 files changed, 23 insertions(+), 46 deletions(-) > > diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h > index 1fd2846dbefe..d20f5da2d76f 100644 > --- a/arch/arm64/include/asm/hugetlb.h > +++ b/arch/arm64/include/asm/hugetlb.h > @@ -46,9 +46,6 @@ extern void huge_pte_clear(struct mm_struct *mm, unsigned long addr, > pte_t *ptep, unsigned long sz); > #define __HAVE_ARCH_HUGE_PTEP_GET > extern pte_t huge_ptep_get(pte_t *ptep); > -extern void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, > - pte_t *ptep, pte_t pte, unsigned long sz); > -#define set_huge_swap_pte_at set_huge_swap_pte_at > > void __init arm64_hugetlb_cma_reserve(void); > > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > index c9e076683e5d..58b89b9d13e0 100644 > --- a/arch/arm64/mm/hugetlbpage.c > +++ b/arch/arm64/mm/hugetlbpage.c > @@ -238,6 +238,13 @@ static void clear_flush(struct mm_struct *mm, > flush_tlb_range(&vma, saddr, addr); > } > > +static inline struct folio *hugetlb_swap_entry_to_folio(swp_entry_t entry) > +{ > + VM_BUG_ON(!is_migration_entry(entry) && !is_hwpoison_entry(entry)); > + > + return page_folio(pfn_to_page(swp_offset(entry))); > +} Extracting this huge page size from swap entry is an additional operation which will increase the over all cost for set_huge_swap_pte_at(). At present the size value is readily available near set_huge_swap_pte_at() call sites.