From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (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 51C553D47DA for ; Thu, 18 Jun 2026 07:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768713; cv=none; b=P9thjvNX4omFCNt/krQQs8eewu2z+ifMYyZ6JOLfCiZ7I4A5d0IkDZ7HIdSfdN9C1CKW19K78wK1cL8hLD3/6oQ+iKwJNO6JnclVTE19duE8EtVDide+n+FWK2QUmH2pMs2W5K87r2ooS7gUCYDC7TRzkyYl6YTItiWCmbH0wNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781768713; c=relaxed/simple; bh=osLnLf3kV+Bz+X/dWB1kmGWzAhUk5SE1TQCdb2ycQRc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=j5KN2l3homy1d/dLFcYYfTBVpDL7mNq7jiE65mcx6kx4bsFcTHDDwY3xNcov+eu+0fsQV7Y88UueaFuC4z/1SdsZLk/arTq0dfgqhfgpHNdLpC6Xz4wVXAyVmdF9aXM7DdMQgxG64tfKAX/oGAlrTbI2txsNb/m/tdSZIVFR6n0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ozKxIvFA; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ozKxIvFA" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781768707; h=from:from: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=gcdVk3SD/kQ6YP1sw609Ns7BDds+P1T+xzsWO6YjCAw=; b=ozKxIvFAUa6h8qFuqox1DC8GyPRZZujiOfjuuDrQw254LRyIDKt4OZLamnPy4oo5heYBWX S8iykcBIf8u8heJCx8X0llJ2A76HqkDqGhJZLr8N5wB1N3++onJa/MgXpoGpDXSP1/p3Yg h66F2AGBEaiRsFWs5KiOiHrtLEsGoPw= From: Lance Yang To: dev.jain@arm.com, david@kernel.org Cc: akpm@linux-foundation.org, ljs@kernel.org, chrisl@kernel.org, kasong@tencent.com, hughd@google.com, liam@infradead.org, 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, Lance Yang Subject: Re: [PATCH v4 02/12] mm/rmap: Add try_to_unmap_hugetlb_one Date: Thu, 18 Jun 2026 15:44:49 +0800 Message-Id: <20260618074449.24974-1-lance.yang@linux.dev> In-Reply-To: References: 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=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Tue, Jun 09, 2026 at 04:16:47PM +0200, David Hildenbrand (Arm) wrote: [...] >> --- >> mm/rmap.c | 203 ++++++++++++++++++++++++++++++++---------------------- >> 1 file changed, 121 insertions(+), 82 deletions(-) >> >> diff --git a/mm/rmap.c b/mm/rmap.c >> index 430c91c8fe2ae..06ab1158d4cd1 100644 >> --- a/mm/rmap.c >> +++ b/mm/rmap.c >> @@ -1978,6 +1978,121 @@ static inline unsigned int folio_unmap_pte_batch(struct folio *folio, >> FPB_RESPECT_WRITE | FPB_RESPECT_SOFT_DIRTY); >> } >> >> +static bool __try_to_unmap_hugetlb_one(struct folio *folio, >> + struct vm_area_struct *vma, struct page_vma_mapped_walk *pvmw, >> + struct mmu_notifier_range *range, enum ttu_flags flags) >> +{ >> + unsigned long hsz = huge_page_size(hstate_vma(vma)); > >Can be const. > >> + unsigned long address = pvmw->address; > >Can be const. But do we even need the temporary variable? > >> + struct mm_struct *mm = vma->vm_mm; >> + struct page *subpage; > >a) subpages do not exist. It's just a folio page. >b) subpages are irrelevant for hugetlb, just drop anything that deals with them. > >> + bool ret = true; >> + pte_t pteval; >> + > >Worth adding a comment here, why we don't need a loop. > >/* There is only a single mapping in a VMA. */ > >> + if (!page_vma_mapped_walk(pvmw)) >> + return true; >> + >> + pteval = ptep_get(pvmw->pte); > >Should we now properly use huge_ptep_get()? Right. IIUC, on s390, the hugetlb entry stored in the page table is not in the normal PTE layout. set_huge_pte_at() stores the arch huge-entry format there, and huge_ptep_get() is the helper that decodes it back into a normal pte_t. pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { return __rste_to_pte(pte_val(*ptep)); } >> + VM_WARN_ON(!pte_present(pteval)); >> + subpage = folio_page(folio, pte_pfn(pteval) - folio_pfn(folio)); > >No need for subpages. So plain ptep_get() can feed raw huge-entry bits into pte_pfn(), and the derived subpage can be wrong. Cheers, Lance [...]