From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77EAA3E1D08 for ; Thu, 30 Jul 2026 19:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785439565; cv=none; b=KpF8hVReBygFEUycCUDh2cECredtCWp0vZDJPbpf9yLGlb1j2P0f21tx2droj6qEdcp/zlcsbI+JJKfJCDa6DrTOqpGIhfzKsV5grDtfN48ustAKVGG95fTBmysX0ENXk8FG5EPrgdWBHy4d1eEpiqlDG0B3uL75xTAaaW8LpZ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785439565; c=relaxed/simple; bh=1mC+yylq1z5QKU8cSpY7u0SJmfUQJhqE1Q5leCTwNi0=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=iz9JxsFBwKXFRBSzDp8bm0eJLVHahRe3aFCla928RR7CQQBsSDiRRqhm7e/2fV5mx5IMxTDY8vTPZE4+BjD11c0Bd3jTYnmJXYvCYN/uBCplEURosGluBD6j7rnE2hgZsYlWVCPIIEGj5fR5YNjGAJ0rAKPXLuUiA+pMyYaoZbg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=z63lMu7t; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="z63lMu7t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 683381F000E9; Thu, 30 Jul 2026 19:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1785439563; bh=9Mu63+TXTdPWbpzCzG/liNanm6XyD5XCxB88149EcWI=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=z63lMu7tXWHGvvdGZKjWKifKRdW6gtCoUrnoLT/EC62tESOltxEo37cabBtOFu4IG hqGqFehBnJSJADqtX/yMkcBMcM22ARhPfWGd83T11G8LHKfDpOSgODfLPGbwbNDljJ mWG1UG68d0gjKJWkUO8qkQ5RfDTYP7Ge7WOMAzQE= Date: Thu, 30 Jul 2026 12:26:02 -0700 From: Andrew Morton To: Dev Jain Cc: david@kernel.org, ljs@kernel.org, muchun.song@linux.dev, osalvador@suse.de, 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 Subject: Re: [PATCH v4 0/5] mm/rmap: Refactor try_to_unmap_one Message-Id: <20260730122602.587dc6cfea1859059e29ac6c@linux-foundation.org> In-Reply-To: <20260730094559.418003-1-dev.jain@arm.com> References: <20260730094559.418003-1-dev.jain@arm.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Thu, 30 Jul 2026 09:45:51 +0000 Dev Jain wrote: > In preparation for batching anonymous large folio unmapping to optimize it, > refactor try_to_unmap_one. This series refactors hugetlb, anon-lazyfree > and anon-swapbacked logic into their own functions, significantly > reducing the length of the huge try_to_unmap_one. > Thanks, updated. > > v3->v4: > - Tighten comment around TTU_HWPOISON > - try_to_unmap_hugetlb_one -> try_to_unmap_poisoned_hugetlb_one > - VM_WARN_ON -> VM_WARN_ON_ONCE Here's how v4 altered mm.git: mm/rmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/mm/rmap.c~b +++ a/mm/rmap.c @@ -1978,7 +1978,7 @@ static inline unsigned int folio_unmap_p FPB_RESPECT_WRITE | FPB_RESPECT_SOFT_DIRTY); } -static bool try_to_unmap_hugetlb_one(struct folio *folio, +static bool try_to_unmap_poisoned_hugetlb_one(struct folio *folio, struct vm_area_struct *vma, unsigned long address, void *arg) { DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, address, 0); @@ -1993,7 +1993,7 @@ static bool try_to_unmap_hugetlb_one(str * The try_to_unmap() is only passed a hugetlb folio in the case * where the hugetlb folio is poisoned. */ - VM_WARN_ON_FOLIO(!folio_test_hwpoison(folio), folio); + VM_WARN_ON_ONCE_FOLIO(!folio_test_hwpoison(folio), folio); VM_WARN_ON_ONCE(!(flags & TTU_HWPOISON)); range.end = vma_address_end(&pvmw); @@ -2031,7 +2031,7 @@ static bool try_to_unmap_hugetlb_one(str if (!folio_test_anon(folio)) { struct mmu_gather tlb; - VM_WARN_ON(!(flags & TTU_RMAP_LOCKED)); + VM_WARN_ON_ONCE(!(flags & TTU_RMAP_LOCKED)); if (!hugetlb_vma_trylock_write(vma)) { ret = false; goto walk_done; @@ -2350,7 +2350,7 @@ static bool try_to_unmap_one(struct foli /* Update high watermark before we lower rss */ update_hiwater_rss(mm); - /* With TTU_HWPOISON, we only expect small folios here. */ + /* unmap_poisoned_folio() only refs order-0 folios */ if (folio_test_hwpoison(folio) && (flags & TTU_HWPOISON)) { pteval = swp_entry_to_pte(make_hwpoison_entry(page)); dec_mm_counter(mm, mm_counter(folio)); @@ -2440,7 +2440,7 @@ void try_to_unmap(struct folio *folio, e { struct rmap_walk_control rwc = { .rmap_one = folio_test_hugetlb(folio) ? - try_to_unmap_hugetlb_one : try_to_unmap_one, + try_to_unmap_poisoned_hugetlb_one : try_to_unmap_one, .arg = (void *)flags, .done = folio_not_mapped, .anon_lock = folio_lock_anon_vma_read, _