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 B2E443F823E for ; Fri, 10 Jul 2026 13:13: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=1783689204; cv=none; b=B6647c0sesQS4BQzhfGP+txO6ARLCN6HWGctWIJasZ0w7kQlpgZEhK8vrTm0FvORI1BGWgwvN/x0sSYLUWeuYZWel3hplGXe9WZE34I8gwuHY0CHuJAbYdANGKv25EaiOtoymO06cGDmQU4jXI5BufrQPCLxY+NLMTWKSHJNt0U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783689204; c=relaxed/simple; bh=Dz+rBYa5uMfuc05j8/QbOewekJXZQIzUiNonDDQ2YCo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ltoTRW6H1N3LM600kpFNRNEeE4wiaVJ0TrgDoi7Kz8G2qN8Fp2zRE+AdF9jkbugc7SP1bl8XnnhDtWpgs6rSwcD+TGXIOkz2xTMm9e44CkgmaM7tal3S7VmwnyYFjDTWjrQQ9BIc77W9e+DFLOj+c0wc8yXhw1nlagoP8aAaeNY= 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=gHKR1jOj; 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="gHKR1jOj" 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 93DD0176A; Fri, 10 Jul 2026 06:13:16 -0700 (PDT) Received: from [10.164.19.51] (unknown [10.164.19.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1014A3F66F; Fri, 10 Jul 2026 06:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783689200; bh=Dz+rBYa5uMfuc05j8/QbOewekJXZQIzUiNonDDQ2YCo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gHKR1jOjt7QCu91OrQyhYTWE6z7tWRrsPrLcLJyogfZsmcrO1zcQzkTE/7l9qsV/i 09u12atqLLnIDhbZB5aAaH9CLlmnqRDuMy/SIGeu9zjyjxTgVGe3az0ZXn+5a/4q+y xwb5Dwiz9ZCSwCFmEtmfTNwzWAS01dpf47wxh5Tc= Message-ID: <42300e6c-523b-4f58-98f7-672ce9173fe2@arm.com> Date: Fri, 10 Jul 2026 18:43:14 +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 v2 5/5] mm/rmap: add anon folio unmap dispatcher To: "David Hildenbrand (Arm)" , akpm@linux-foundation.org, ljs@kernel.org, muchun.song@linux.dev, osalvador@suse.de Cc: riel@surriel.com, liam@infradead.org, vbabka@kernel.org, harry@kernel.org, jannh@google.com, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ryan.roberts@arm.com, anshuman.khandual@arm.com References: <20260710055915.638659-1-dev.jain@arm.com> <20260710055915.638659-6-dev.jain@arm.com> <00467fbf-0360-47be-94bc-d1456323e5a1@kernel.org> From: Dev Jain Content-Language: en-US In-Reply-To: <00467fbf-0360-47be-94bc-d1456323e5a1@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/07/26 5:57 pm, David Hildenbrand (Arm) wrote: > On 7/10/26 07:59, Dev Jain wrote: >> Add ttu_anon_folio() as the common entry point for anonymous folio >> unmapping. It dispatches to the lazyfree or swapbacked helper as >> appropriate. >> >> Keep restoration of cleared PTEs in the caller, where the PTEs were >> removed. >> >> No functional change intended. >> >> Signed-off-by: Dev Jain >> --- >> mm/rmap.c | 47 +++++++++++++++++++++++++---------------------- >> 1 file changed, 25 insertions(+), 22 deletions(-) >> >> diff --git a/mm/rmap.c b/mm/rmap.c >> index 68459f23f5c0a..55aa3ff8bf216 100644 >> --- a/mm/rmap.c >> +++ b/mm/rmap.c >> @@ -2172,6 +2172,28 @@ static bool ttu_anon_swapbacked_folio(struct vm_area_struct *vma, >> return true; >> } >> >> +static bool ttu_anon_folio(struct vm_area_struct *vma, struct folio *folio, >> + struct page *page, unsigned long address, pte_t *ptep, >> + pte_t pteval, unsigned long nr_pages) >> +{ >> + /* >> + * Store the swap location in the pte. >> + * See handle_pte_fault() ... >> + */ >> + if (unlikely(folio_test_swapbacked(folio) != >> + folio_test_swapcache(folio))) { >> + WARN_ON_ONCE(1); > > Can't you directly do > > if (WARN_ON_ONCE(...)) > return false; Right. I didn't do it perhaps because I was playing with if (VM_WARN_ON_ONCE) somewhere and that didn't build. But this is without the VM_ , this will work. Andrew, could you you squash this diff: diff --git a/mm/rmap.c b/mm/rmap.c index 55aa3ff8bf216..41a049e7dd231 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2180,11 +2180,9 @@ static bool ttu_anon_folio(struct vm_area_struct *vma, struct folio *folio, * Store the swap location in the pte. * See handle_pte_fault() ... */ - if (unlikely(folio_test_swapbacked(folio) != - folio_test_swapcache(folio))) { - WARN_ON_ONCE(1); + if (WARN_ON_ONCE(folio_test_swapbacked(folio) != + folio_test_swapcache(folio))) return false; - } if (!folio_test_swapbacked(folio)) return ttu_anon_lazyfree_folio(vma, folio, nr_pages); > > That even implies the unlikely() :) > >> + return false; >> + } >> + >> + if (!folio_test_swapbacked(folio)) >> + return ttu_anon_lazyfree_folio(vma, folio, nr_pages); >> + >> + /* nr_pages > 1 not supported yet */ >> + return ttu_anon_swapbacked_folio(vma, folio, page, address, ptep, > > LGTM > > Acked-by: David Hildenbrand (Arm) >