From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C36E8C77B6E for ; Fri, 14 Apr 2023 12:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbjDNMWg (ORCPT ); Fri, 14 Apr 2023 08:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjDNMWe (ORCPT ); Fri, 14 Apr 2023 08:22:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E4CAF29 for ; Fri, 14 Apr 2023 05:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kI6nWz/7mbrcqeoJObTAkGI/5raHVgMAa8wusj6R28s=; b=gmdxaxKHu6YQRudBx7W+CuJ2hM ciCileYCHTMdFMQHi5KdFyyA6uKga4aBGYnNb6kKq9jas6amiJzAXViiOuFamzkj0jYf3MRqNMvX7 +r/ok3cmhkgy+1VUCGUWTjF3Mol5OXGsU9/gLgr/pWozRQg2RHrWAjZoNJAI/vaDLDuS7Got8hxI2 4tjGZFE6gqhrwH3j8k+43SbGtpDQL64FENw3DVMDctLFtZQQuJMbRP70iFBHurrXKnvYeKY/UvRYZ 8sDb0DFF+1EUpIKtRUCaC/qSjBjktFS4BgTu3I6VCWMeLbGua6sEnzSHNnbv2zjb7AgT1rl3ZOpiR /k7JZATw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pnIRK-008jnq-MY; Fri, 14 Apr 2023 12:22:07 +0000 Date: Fri, 14 Apr 2023 13:22:06 +0100 From: Matthew Wilcox To: Mel Gorman Cc: Andrew Morton , Vlastimil Babka , Michal Hocko , Oscar Salvador , Yuanxi Liu , David Hildenbrand , Linux-MM , LKML Subject: Re: [PATCH] mm: page_alloc: Assume huge tail pages are valid when allocating contiguous pages Message-ID: References: <20230414082222.idgw745cgcduzy37@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230414082222.idgw745cgcduzy37@techsingularity.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 14, 2023 at 09:22:22AM +0100, Mel Gorman wrote: > + /* > + * Do not migrate huge pages that span the size of the region > + * being allocated contiguous. e.g. Do not migrate a 1G page > + * for a 1G allocation request. CMA is an exception as the > + * region may be reserved for hardware that requires physical > + * memory without a MMU or scatter/gather capability. > + * > + * Note that the compound check is race-prone versus > + * free/split/collapse but it should be safe and result in > + * a premature skip or a useless migration attempt. > + */ > + if (PageHuge(page) && compound_nr(page) >= nr_pages && This confuses me. PageHuge() can be called on tail pages, but if compound_nr() is called on a tail page, it returns 1. So I'm not sure why this works. Also, do you really want PageHuge (ie only hugetlbfs pages), or do you really just want to check PageCompound(), which would also be true for THP?