Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp535814rwe; Fri, 14 Apr 2023 06:36:33 -0700 (PDT) X-Google-Smtp-Source: AKy350YqAqx4dBqEUOj6iNKwBOIXwT3b6ie2P6dyFsrc4E1Ckqxv2rLFHCnvlH7kL0iu7WAW37Kj X-Received: by 2002:a05:6a20:b712:b0:d9:3937:43a7 with SMTP id fg18-20020a056a20b71200b000d9393743a7mr5950396pzb.55.1681479393068; Fri, 14 Apr 2023 06:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681479393; cv=none; d=google.com; s=arc-20160816; b=ijbkCnKMfZqOVs5/LMNzmx+tq7JCyQFypD8U3W2/e6gM75oM58X6YBf9gOlN5mJ/NO lq/Nt8sT4vBLB9P5M6La15HtNdp9dbgziNmWoXz9CK1Ph/751WfMKBsJQSc1ksqTAMbJ aFV8fODAAU2941eo0VcFreO/E0sQ0Wpp5aQFxiqTiPKVCK4snYV8lxwlHH3EK8Duwu3G FpTHltEILo6FifXkssyappCjT7ggIvrih1cX/+OgECTcGNedU3nuxLw2bxSdjBjB6k8M PxF52dqwYuYo5kpptbpLK4lzTetfbUO71nQv5cMugEI8QSdJ5Ty9FisLXno4jXQVKaxB OtZw== 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; bh=EgKSHp1GDdcxsHFSeY4I4nyap4KqJegeD1mmI+AMYvM=; b=c57yEjnVItOYJPLFnFBlDTRKOOu07jJn9ewOpFcpohB1syLNfFqg0HyB2HK+rICAv4 GhcWcsmxg6t9ln59+wdamq95lILr059lEBtyY3ubODQsBDvjnG2bGOQbjxKdTQouKe5t jTx2FvHVVrrWw+qnDHqzbqaFaXkfpjgbLW2fehfN/4wgmQEXqC/HZY3IDa7Wm3eokwg7 lMsyMaLda8/QDpsLI+A1D1xJHxO7lKSqNOcJjqAxF+RKOY5hzTUTekscCarkEm/BN3SX pOg74bhgvXszD8/M8u48VyUkuwfiIfbay8UhM9R6M9d+3C7l6FVbYq8RL2Eq3K5IEIvb QCSQ== ARC-Authentication-Results: i=1; mx.google.com; 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 a21-20020a63e855000000b00513f070aaa1si4811999pgk.892.2023.04.14.06.36.19; Fri, 14 Apr 2023 06:36:33 -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; 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 S229830AbjDNN3u (ORCPT + 99 others); Fri, 14 Apr 2023 09:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjDNN3t (ORCPT ); Fri, 14 Apr 2023 09:29:49 -0400 Received: from outbound-smtp11.blacknight.com (outbound-smtp11.blacknight.com [46.22.139.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637108A41 for ; Fri, 14 Apr 2023 06:29:44 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp11.blacknight.com (Postfix) with ESMTPS id AD9591C3FC5 for ; Fri, 14 Apr 2023 14:29:42 +0100 (IST) Received: (qmail 17515 invoked from network); 14 Apr 2023 13:29:42 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.21.103]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 14 Apr 2023 13:29:42 -0000 Date: Fri, 14 Apr 2023 14:29:40 +0100 From: Mel Gorman To: Matthew Wilcox 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: <20230414132940.chjmsuiurnygajxs@techsingularity.net> References: <20230414082222.idgw745cgcduzy37@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,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 01:22:06PM +0100, Matthew Wilcox wrote: > 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. Given the calling context is a linear scan, the head page will be scanned first so the value for compound_nr() called on a tail page shouldn't occur. > 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? > For now I only want hugetlbfs pages as the fix is for a regression when allocating 1G hugetlbfs pages and previous behaviour avoided existing hugetlbfs pages. THP pages can be split+migrated of course but the cost of the 1G allocation attempt may be excessive relative to any benefit. -- Mel Gorman SUSE Labs