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 3C10330D3F6 for ; Tue, 23 Jun 2026 10:03:21 +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=1782209002; cv=none; b=rXaTwy/S4DL/njFwLfHkbMAuMvn4VL30lJlrRnCwt7WqH6UQ9XyIVu36YrYcAo96j/9/U+DlGbm9/w4NVSwpMy3oxf+yhT8nQQ6kHf0yvipq3F0/F5b56fEppebJKeV7B02O3gRqY4lpgi80CO+dI6gedANHqn+zpddT46jgSfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782209002; c=relaxed/simple; bh=pMiJn9AVMsjDxLBSA9Pg+nfI5z/CtaYasU8faQqnI1c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=H/H+1fPjtCU4ririm1cppeBXWdKpZtRi/+F4bozD/EwfLMhQ6DOSbbo87afYC4z7GfgFzvII0H/MfaHhh5s10Mkm2KxEw3hI5EEavAxU6tweC4239YFG4bCsZCq4SInuidNtROoaz9Ly1/7knrCbm8mVKnk0O8puC8pcKIUQADU= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=eA0tg0G0; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="eA0tg0G0" 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 D3B392F; Tue, 23 Jun 2026 03:03:15 -0700 (PDT) Received: from [10.164.19.14] (unknown [10.164.19.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 024293F632; Tue, 23 Jun 2026 03:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1782209000; bh=pMiJn9AVMsjDxLBSA9Pg+nfI5z/CtaYasU8faQqnI1c=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=eA0tg0G0wJRnZHMeS0kxkbAelz4GKfw9hru5z2iUs20XNqFzhJchjvp/ndC6OVVwa ZKShpTWy6IL4zS5q7DfTbmrxZLpNPp0Xrn8AHhPJh1AXMIKxrZ6H4qeFnEoQMhkVk+ oKXR/hdMc7vWpr4AJrrBU0+yruVXufNl1/am7s2E= Message-ID: <9a80af3f-439c-43e6-a65d-66a58c482604@arm.com> Date: Tue, 23 Jun 2026 15:33:10 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 08/12] mm/swapfile: Add batched version of folio_put_swap To: "David Hildenbrand (Arm)" , akpm@linux-foundation.org, ljs@kernel.org, chrisl@kernel.org, kasong@tencent.com, hughd@google.com, liam@infradead.org Cc: riel@surriel.com, vbabka@kernel.org, harry@kernel.org, jannh@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, qi.zheng@linux.dev, shakeel.butt@linux.dev, baohua@kernel.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, youngjun.park@lge.com, baolin.wang@linux.alibaba.com, pfalcato@suse.de, ryan.roberts@arm.com, anshuman.khandual@arm.com References: <20260526063635.61721-1-dev.jain@arm.com> <20260526063635.61721-9-dev.jain@arm.com> <17c5f031-17e5-44c3-b572-ee224cb294cd@kernel.org> Content-Language: en-US From: Dev Jain In-Reply-To: <17c5f031-17e5-44c3-b572-ee224cb294cd@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 16/06/26 7:24 pm, David Hildenbrand (Arm) wrote: > On 5/26/26 08:36, Dev Jain wrote: >> Add folio_put_swap_pages to handle a batch of consecutive pages. Note >> that folio_put_swap already can handle a subset of this: nr_pages == 1 and >> nr_pages == folio_nr_pages(folio). Generalize this to any nr_pages. >> >> Currently we have a not-so-nice logic of passing in subpage == NULL if >> we mean to exercise the logic on the entire folio, and subpage != NULL if >> we want to exercise the logic on only that subpage. Remove this >> indirection: the caller invokes folio_put_swap_pages() if it wants to >> operate on a range of pages in the folio (i.e nr_pages may be anything >> between 1 till folio_nr_pages()), and invokes folio_put_swap() if it > > "between 1 and folio_nr_pages()" ? Ok. > >> wants to operate on the entire folio. >> >> Signed-off-by: Dev Jain >> --- > > > [...] > >> +++ b/mm/swap.h >> @@ -208,7 +208,8 @@ extern int swap_retry_table_alloc(swp_entry_t entry, gfp_t gfp); >> int folio_alloc_swap(struct folio *folio); >> int folio_dup_swap_pages(struct folio *folio, struct page *page, >> unsigned long nr_pages); >> -void folio_put_swap(struct folio *folio, struct page *page); >> +void folio_put_swap_pages(struct folio *folio, struct page *page, >> + unsigned long nr_pages); > > Nit \tab\tab (same below) > >> >> /* For internal use */ >> extern void __swap_cluster_free_entries(struct swap_info_struct *si, >> @@ -397,7 +398,8 @@ static inline int folio_dup_swap_pages(struct folio *folio, struct page *page, >> return -EINVAL; >> } >> > > > [...] > >> >> swap_put_entries_cluster(si, swp_offset(entry), nr_pages, false); >> } >> @@ -2499,7 +2497,8 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, >> new_pte = pte_mkuffd_wp(new_pte); >> setpte: >> set_pte_at(vma->vm_mm, addr, pte, new_pte); >> - folio_put_swap(swapcache, folio_file_page(swapcache, swp_offset(entry))); >> + folio_put_swap_pages(swapcache, >> + folio_file_page(swapcache, swp_offset(entry)), 1); >> out: >> if (pte) >> pte_unmap_unlock(pte, ptl); > > > We could consider having a simple folio_put_swap_page() helper. But maybe most > of these will be converted to batching in the long run either way. Yep. > > Acked-by: David Hildenbrand (Arm) Thanks! >