Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2468127rdg; Mon, 16 Oct 2023 05:41:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFG3yaeVzVlS83+B/bxYI9xIO9ZHEA0bp+6fR4KGUO45o2blnsF5Un9MIrBwRiIZLRCGXih X-Received: by 2002:a05:6a20:9389:b0:154:6480:83a4 with SMTP id x9-20020a056a20938900b00154648083a4mr32813705pzh.14.1697460095774; Mon, 16 Oct 2023 05:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697460095; cv=none; d=google.com; s=arc-20160816; b=VvKZngIymkk93eHPtMdw7LLpAdpYaC3Wizc+Bij791t1x/tKUofKuHkAL0dJAqofnm xXGGpbbbC9c2rEGR6oH1zMu8YwO9z0aV5pF+8UBxaOHNqw36v7CXHYPPFmF7Xh6mAlCA zQq1LbF7NEIYLSM9kBRHnI/x1PwyKOf/D+YpE8ZOFi8g4nB1gf7qFauDoKMEjjROADmJ jb6fTG9x686fUgsIJ1W5LT0GAGGOS68jgA9pbx2XEt5ZH/1Afup7oNbM9z/NybSPC2Ei mlfEkbeL2JM9aY0zuyOTj7XTD1/ANpHEi0kOJBHlupyjbVnV6c8DsrolDuFrW5St1q+r RQIw== 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=AsLmyt110z4Suc5ezbb4lyvxxLLwXKqTbt16jhjddvY=; fh=662FnxvaMUPpGpbpQaKOb5FYDcM6B26e8RC2ZBxI39o=; b=V7TVCny6vCCEc/ZDhD3igXfBncanckpL+Ib6YBJ+f8x7HY0RgMwj1mZEAf3Hb0wNGy YLtKtlK87bCG3uWxCYFxQ2JWCTMJ3Drt+zk9iYZ+1NTeYgqUu8Y/eOLlswwg1Eoq72sK 0jsVmabfpgDVimI8Chq4k+0hujE7RgrqW2EyKkX4aKpdmps87kd/xjJikfFdAvwbOYGP 5P9EYe6M6mH79qY0vu5iJ6kvZYqXT6/bTYMe0bPX3S96pcZzW9xw9ksyxywbTc9EY14U 9SYAu/Hwdqamn5oybEaTneCO6uauyrFAZU7Uo29QLx4AZ8/ue2apvbM8tUXEj+IKgmqC EPSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id o7-20020a637307000000b005b5c68e2c92si3508742pgc.371.2023.10.16.05.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 05:41:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2DE8A8082854; Mon, 16 Oct 2023 05:41:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233545AbjJPMl0 (ORCPT + 99 others); Mon, 16 Oct 2023 08:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233537AbjJPMlE (ORCPT ); Mon, 16 Oct 2023 08:41:04 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CDCF7D76; Mon, 16 Oct 2023 05:40:47 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D2672F4; Mon, 16 Oct 2023 05:41:28 -0700 (PDT) Received: from monolith (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F2A323F5A1; Mon, 16 Oct 2023 05:40:41 -0700 (PDT) Date: Mon, 16 Oct 2023 13:41:15 +0100 From: Alexandru Elisei To: Hyesoo Yu Cc: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com, pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, david@redhat.com, eugenis@google.com, kcc@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH RFC 06/37] mm: page_alloc: Allocate from movable pcp lists only if ALLOC_FROM_METADATA Message-ID: References: <20230823131350.114942-1-alexandru.elisei@arm.com> <20230823131350.114942-7-alexandru.elisei@arm.com> <20231010074823.GA2536665@tiffany> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231010074823.GA2536665@tiffany> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 16 Oct 2023 05:41:33 -0700 (PDT) Hi, On Thu, Oct 12, 2023 at 10:25:11AM +0900, Hyesoo Yu wrote: > On Wed, Aug 23, 2023 at 02:13:19PM +0100, Alexandru Elisei wrote: > > pcp lists keep MIGRATE_METADATA pages on the MIGRATE_MOVABLE list. Make > > sure pages from the movable list are allocated only when the > > ALLOC_FROM_METADATA alloc flag is set, as otherwise the page allocator > > could end up allocating a metadata page when that page cannot be used. > > > > __alloc_pages_bulk() sidesteps rmqueue() and calls __rmqueue_pcplist() > > directly. Add a check for the flag before calling __rmqueue_pcplist(), and > > fallback to __alloc_pages() if the check is false. > > > > Note that CMA isn't a problem for __alloc_pages_bulk(): an allocation can > > always use CMA pages if the requested migratetype is MIGRATE_MOVABLE, which > > is not the case with MIGRATE_METADATA pages. > > > > Signed-off-by: Alexandru Elisei > > --- > > mm/page_alloc.c | 21 +++++++++++++++++---- > > 1 file changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 829134a4dfa8..a693e23c4733 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -2845,11 +2845,16 @@ struct page *rmqueue(struct zone *preferred_zone, > > > > if (likely(pcp_allowed_order(order))) { > > /* > > - * MIGRATE_MOVABLE pcplist could have the pages on CMA area and > > - * we need to skip it when CMA area isn't allowed. > > + * PCP lists keep MIGRATE_CMA/MIGRATE_METADATA pages on the same > > + * movable list. Make sure it's allowed to allocate both type of > > + * pages before allocating from the movable list. > > */ > > - if (!IS_ENABLED(CONFIG_CMA) || alloc_flags & ALLOC_CMA || > > - migratetype != MIGRATE_MOVABLE) { > > + bool movable_allowed = (!IS_ENABLED(CONFIG_CMA) || > > + (alloc_flags & ALLOC_CMA)) && > > + (!IS_ENABLED(CONFIG_MEMORY_METADATA) || > > + (alloc_flags & ALLOC_FROM_METADATA)); > > + > > + if (migratetype != MIGRATE_MOVABLE || movable_allowed) { > > Hi! > > I don't think it would be effcient when the majority of movable pages > do not use GFP_TAGGED. > > Metadata pages have a low probability of being in the pcp list > because metadata pages is bypassed when freeing pages. > > The allocation performance of most movable pages is likely to decrease > if only the request with ALLOC_FROM_METADATA could be allocated. You're right, I hadn't considered that. > > How about not including metadata pages in the pcp list at all ? Sounds reasonable, I will keep it in mind for the next iteration of the series. Thanks, Alex > > Thanks, > Hyesoo Yu. > > > page = rmqueue_pcplist(preferred_zone, zone, order, > > migratetype, alloc_flags); > > if (likely(page)) > > @@ -4388,6 +4393,14 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, > > goto out; > > gfp = alloc_gfp; > > > > + /* > > + * pcp lists puts MIGRATE_METADATA on the MIGRATE_MOVABLE list, don't > > + * use pcp if allocating metadata pages is not allowed. > > + */ > > + if (metadata_storage_enabled() && ac.migratetype == MIGRATE_MOVABLE && > > + !(alloc_flags & ALLOC_FROM_METADATA)) > > + goto failed; > > + > > /* Find an allowed local zone that meets the low watermark. */ > > for_each_zone_zonelist_nodemask(zone, z, ac.zonelist, ac.highest_zoneidx, ac.nodemask) { > > unsigned long mark; > > -- > > 2.41.0 > > > >