From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from flow-b1-smtp.messagingengine.com (flow-b1-smtp.messagingengine.com [202.12.124.136]) (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 8A8E8472780; Thu, 10 Sep 2026 13:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789045484; cv=none; b=eZYbHlUhiMBkh/eNXqSyryastQZHsU4hdolVWM9feul6O/p39WpReq7e3ZRDUiA5T6c3e3m9tcnSWlyWbXvEpNt01SErymGuxLOLay1RK/TuVehdH7MxH2tRdtQldfyq5UAdAQnrNJTi3qkSKfREj8bbYeLsLooHUAZXzedXzVo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789045484; c=relaxed/simple; bh=6SUrTyrFC4X0SauFaRhaOHmqGLiDynswuu7D7Set+T4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WyWI5eqjxGLMZufsBowJ7f9r1DDCNatfVX+o/TzYmTvHrQG9PtaKVLk7gKN9BxKEuAUKJPNtPb0fHGdwQmk9Y9pXaUFblvQ2FnFIhu8cHbVnG72qualPXtGBBEhP24w6LR9quL+xJantTTiDshIXS3h2cCuUCnsBdgTEyjx125U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name; spf=pass smtp.mailfrom=shutemov.name; dkim=pass (2048-bit key) header.d=shutemov.name header.i=@shutemov.name header.b=HbElgJRM; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=oVBZsIV/; arc=none smtp.client-ip=202.12.124.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shutemov.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shutemov.name header.i=@shutemov.name header.b="HbElgJRM"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oVBZsIV/" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id 311BC1300DC9; Thu, 10 Sep 2026 09:04:40 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 10 Sep 2026 09:04:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1789045480; x= 1789052680; bh=KV7XC8+HfJo2WCcRdFe2DjTL8zq9dSIHiccyK3AlT4Q=; b=H bElgJRMEbERl1+nAd+kW9yaqu2UYYpiIMMfqBOlgxuZCg8RzxiGpYJ3HJLUO1lzO LDl0gXvqTEsdY1A/P6dKgL/PlY39t3HlsPhcsQrC9g7ITFQiNILUVZqLE1lFKvSI hCYWo8hWgzVUu4/uegICPxVIYjvnm+BKURMtflLpLWaolzZJwSYLIiHCDtWpUTU/ h1Uot5ZXV5vBIMZycPWrhHBouSonC0RIQn6CLlNKZFa9DrZ2gDkdjQEfn5MoLjzC Wl2+kF+G+77XzuHyHeZIaIDSqsxAIaxGxrc3XYvKLiyUJlf2AFwngH+m7IcT+jL0 Xv0w/x+1LhsDBTd0/wwdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1789045480; x=1789052680; bh=KV7XC8+HfJo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ovWpO0fZH0AUyFOq2PvNUvlBRdEbHCJz4jyQ X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 10 Sep 2026 09:04:37 -0400 (EDT) Date: Thu, 10 Sep 2026 14:04:35 +0100 From: Kiryl Shutsemau To: Baolin Wang Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, rppt@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, usama.anjum@arm.com, usama.arif@linux.dev, nico.pache@linux.dev, ziy@nvidia.com, baohua@kernel.org, dev.jain@arm.com, hughd@google.com, lance.yang@linux.dev, liam@infradead.org, mhocko@suse.com, ryan.roberts@arm.com, shuah@kernel.org, surenb@google.com, vbabka@kernel.org, agordeev@linux.ibm.com, jgg@ziepe.ca, leon@kernel.org, kernel-team@meta.com Subject: Re: [PATCH v5 08/19] selftests/mm: add folio-order check for address ranges Message-ID: References: <20260908125105.1510704-1-kirill@shutemov.name> <20260908125105.1510704-9-kirill@shutemov.name> <65bf1722-c1fd-452a-88c1-c030b042cfbc@linux.alibaba.com> 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-Disposition: inline In-Reply-To: <65bf1722-c1fd-452a-88c1-c030b042cfbc@linux.alibaba.com> On Thu, Sep 10, 2026 at 07:14:42PM +0800, Baolin Wang wrote: > > > On 9/10/26 6:45 PM, Kiryl Shutsemau wrote: > > On Wed, Sep 09, 2026 at 06:01:13PM +0800, Baolin Wang wrote: > > > > > > > > > On 9/8/26 8:50 PM, Kiryl Shutsemau wrote: > > > > From: "Kiryl Shutsemau (Meta)" > > > > > > > > An mTHP collapse test needs to know that a range is backed by folios of the > > > > target order, and that they sit where a collapse would put them. Nothing > > > > answers that today: is_backed_by_folio() classifies the folio behind a > > > > single page, and check_huge_anon() reads smaps AnonHugePages, which only > > > > accounts PMD mappings. > > > > > > Have you checked check_large_folios() in vm_util.c? It seems to meet your > > > requirements, or am I missing something? > > > > The changelog is out of date, sorry: since 6dedaf0d46a9 check_huge_anon() > > counts mTHP folios through check_large_folios() rather than reading > > smaps, and it is what check_huge() already uses for mthp_khugepaged. > > > > It could do this job too, called once per window. > > > > What is_range_backed_by_order() adds is alignment check: the folio has > > to sit at the window start. And check_large_folios() reopens two fds per > > per call which kinda wasteful. > > OK. But can we extend the check_huge_xxx() functions to meet your > requirements, for example by adding a check_aligned_huge_xxx() that wraps > the underlying implementation of check_large_folios()? > > I still find it confusing that khugepaged.c has two separate sets of > functions for checking large folios. Agreed that two sets is one too many. Yeoreum's series rewrites check_huge_xxx() on top of pagemap and kpageflags, which is what is_backed_by_folio() already walks, so once that lands the two can meet: the mTHP branch of check_huge() checks each window for a folio of the order at its start, and is_range_backed_by_order() goes away or becomes its internal. That also makes the generic mTHP cases stricter for free. I would rather do that as a follow-up than fold it into either series now, since both touch the same functions. -- Kiryl Shutsemau / Kirill A. Shutemov