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 85FE0438FE1 for ; Tue, 10 Mar 2026 08:47:10 +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=1773132431; cv=none; b=afhCCuys95b5c05yyEH32XYXOYAelFW/6IEKtyotg+u7I9MYKdrx4UeEgQ2GYgKGlNfQ1J8Rcb0v29nWRsm9rpb1FhLyD5tGs3blSAS/7HSkToSoYLNunMLQhC4uQgaOZOJTkcofB0wqyUdJuY4rUBfwDzaMFCBFcflC+KdeCUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773132431; c=relaxed/simple; bh=/sfhPkS96PI/ltzPGU3MuIoiFvrGuDwihTvIQ/eF02E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fd21Q8l5FHEnoziUF3CxtVWTj9N+vOwp86vCZTlaKhgJY+oDzS1slCGbV8TKPC5HQqRnTCOj1jF+aG/Dp2x3Lt70FXaP2JU+4LeLJPqAlwx3Oxly/w+cvYwlk7dtcTBDHw7eC793Qa9TfO6LEHCwZPRCuhWyNZ6PznBBf0c1P1Q= 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 AFD63169C; Tue, 10 Mar 2026 01:47:03 -0700 (PDT) Received: from [10.164.19.59] (unknown [10.164.19.59]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1E0C03F7BD; Tue, 10 Mar 2026 01:47:01 -0700 (PDT) Message-ID: <959607a5-4112-47da-95fb-6388d96af5e7@arm.com> Date: Tue, 10 Mar 2026 14:16:59 +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 6/9] mm/swapfile: Make folio_dup_swap batchable To: Kairui Song Cc: akpm@linux-foundation.org, axelrasmussen@google.com, yuanchu@google.com, david@kernel.org, hughd@google.com, chrisl@kernel.org, weixugc@google.com, ljs@kernel.org, Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, pfalcato@suse.de, baolin.wang@linux.alibaba.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, baohua@kernel.org, youngjun.park@lge.com, ziy@nvidia.com, kas@kernel.org, willy@infradead.org, yuzhao@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ryan.roberts@arm.com, anshuman.khandual@arm.com References: <20260310073013.4069309-1-dev.jain@arm.com> <20260310073013.4069309-7-dev.jain@arm.com> Content-Language: en-US From: Dev Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 10/03/26 1:57 pm, Kairui Song wrote: > On Tue, Mar 10, 2026 at 3:36 PM Dev Jain wrote: >> >> Teach folio_dup_swap to handle a batch of consecutive pages. Note that >> folio_dup_swap already can handle a subset of this: nr_pages == 1 and >> nr_pages == folio_nr_pages(folio). Generalize this to any nr_pages. > > Thanks a lot for doing this. I was thinking it's about time we respin > the batch unmapping of anon folios idea. Barry tried that before with > an RFC, and now batching from swap side is easier, so some parts can > be done cleaner. > >> 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, and explicitly pass subpage != NULL, and the number of >> pages required. > > I was hoping most callers will just use the whole folio, but after > checking your code, yeah, using explicit subpage and nr does fit the > other parts better. > >> diff --git a/mm/swapfile.c b/mm/swapfile.c >> index 915bc93964dbd..eaf61ae6c3817 100644 >> --- a/mm/swapfile.c >> +++ b/mm/swapfile.c >> @@ -1738,7 +1738,8 @@ int folio_alloc_swap(struct folio *folio) >> /** >> * folio_dup_swap() - Increase swap count of swap entries of a folio. >> * @folio: folio with swap entries bounded. >> - * @subpage: if not NULL, only increase the swap count of this subpage. >> + * @subpage: Increase the swap count of this subpage till nr number of >> + * pages forward. > > The new nr_pages parameter isn't documented in the kernel-doc comment? Oops, will add this in v2, thanks.