Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp442477rwe; Fri, 14 Apr 2023 05:22:55 -0700 (PDT) X-Google-Smtp-Source: AKy350YqcZJqkA2L+ZnagCBB0Y3bWdfBKZsx/R2clOO0GJ5a/IIklQWJoXCNn+nj51F8b9Thw3Yk X-Received: by 2002:a17:903:4281:b0:1a1:bf22:2b6e with SMTP id ju1-20020a170903428100b001a1bf222b6emr2545062plb.43.1681474974997; Fri, 14 Apr 2023 05:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681474974; cv=none; d=google.com; s=arc-20160816; b=cX6k+RxSQO/CVRwlCh1YyDNtn0sWctl0EvbB/noZLtdaiyFDeIz+dAbDCWWKdD8RAw ng+sQ0OXEvaol83mxMFlYIrRF53Tt9kyA6xeFL5w3EwLzErfGIj0RB+oy5gy59Rh99aq CqBTX1BpIxgZv2U7mLVfOLJZaYfdJEUyRGJ+hOZvfH+FKiobCYzPb9biOc1kVPu6sPPX YkKq0swTIPxw+sSmylZWRq0ZqguFNGowrmBLrLOqIGXZQ+1MRq9UvQkeInCoPgpSRYZO QqQ9faol7QGliBCBRvhmMemcCxF2wN0nbQ7VvCJ+DEAk62oavG6G4loVpVo9hWfk0peS 07HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kI6nWz/7mbrcqeoJObTAkGI/5raHVgMAa8wusj6R28s=; b=LISjtxsCv8zQW+WtjGq/kqxFMDKBerxAAQbcJOXwQQYsufwD0uNuMe/Aoy54UFoa5I 0pAnf37hgket6Wdg800OQkOk/d+PMXi5mhmRq+YH6EtWvzZ7BxAo+yctKHE9hnOeV1d+ l3PlerQVT+P0IgewaQBAmW6SnFSH4Q8UqKClRsML1igyYlh00XOvDDmxKumO4tvgebti 2gV/Ho61Tky5da4ujat56Qu57uQUOg5nNiom9Wopr7qIG7cUXYJeG3MyNl1VM8YoUfVW ef+8NWX70L80pDzm2iMTeljU9D6STylldGjv2dKXtQhqGOi85mn/jcFPSWYWspdhTfrn 46DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gmdxaxKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a170902d48100b001a1b0a828a8si4591181plg.621.2023.04.14.05.22.43; Fri, 14 Apr 2023 05:22:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gmdxaxKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbjDNMWf (ORCPT + 99 others); Fri, 14 Apr 2023 08:22:35 -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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.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?