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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EACD4CDB465 for ; Mon, 16 Oct 2023 12:40:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8986F8D006E; Mon, 16 Oct 2023 08:40:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 821088D0001; Mon, 16 Oct 2023 08:40:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C25B8D006E; Mon, 16 Oct 2023 08:40:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5A4998D0001 for ; Mon, 16 Oct 2023 08:40:50 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 24A50C0713 for ; Mon, 16 Oct 2023 12:40:50 +0000 (UTC) X-FDA: 81351283860.25.D362993 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 54B49100010 for ; Mon, 16 Oct 2023 12:40:48 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697460048; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AsLmyt110z4Suc5ezbb4lyvxxLLwXKqTbt16jhjddvY=; b=DscZScQRihiAOZbYq9AP463mRKJS893grAbZ9OJwy465osRaa34tICa10K2i+I+qFCYYpP Oo9RtkS43c5DPfnBVMhGzHljXVV6L/blpRk1ey0WEhfQ3ZEooI8jAR6sOm9P13tqTfObfI 8noQjU8ym10MPJ2we6u6KhX+5rvahAs= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697460048; a=rsa-sha256; cv=none; b=hkZeUlu0dw5bH6W+tDmnGC2W2o4wuJO3nBeps7/nY1BTbHSSH4BqV/wq4bw0M5N1bwpUeu ydQQ6WM9h8bDq5VuGL8qAk8VIQ5rdWFnIl094740HQTFR3O3UZ5Q/X/78XzoYxxgSUR42p 8oreQmfpc5pKH/49TLSFRdbu5z6bgQ4= 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-Rspam-User: X-Stat-Signature: mxh33daeh8srbfz9ntumehiyaz96zij9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 54B49100010 X-HE-Tag: 1697460048-756709 X-HE-Meta: U2FsdGVkX1+yq0RPr5UKWWatNUR7miW9ZhunwR4nfW+dlYrq2Yqr3G4tbzSRu20CQFNdB1HSM25915+LotFkdy1xyobVP/8MVAixLJDYXBvTeQ3MnnTfwd8JDybOK0JjqMEGVRJ4WOIAQX02P/RV7iXSfuwRur6UzWBKFytam70X8uq41nVfaWkQYc0yVcoIkvDK3ZQIg4esNuap4Y/UeIRDGaYjLBF8GdGzTXZkrUgmcvyhCqWCXarNGg2iUwakq98++IgdczvcVy5SKRt+ttsR+PeVGBYmNa9ePQMlu6i/FmQO6wsQ443gJ75VjFoNoOx4mnOXkzIlrwNJ5wn6LxxcO16ivgZCNUxucmAKWaY4l+yssRUoASnS4vImYfM+7MlO6VvW7/gcDBhUyjU11vAoHzIwa6+nDoOPW8Ln3bIhh7TFyncEhXgfPOUA/SfjNvIj/C+PULN9pih2VufP0HCgcj5roCt8e72PHfGIiGlK6D4dFEzac6ihVkIXSZdTm6Rw+RtBsd1qVws/m2NEzoC1JXXhYg5H3puHxazW+NaJ23RwfnbjerOvj09DDO5xo7pcwLTIwfcu6OoM/PC8QEqukqzc6ql9ADiXOJmWq/W9FkO/EmbgIsskBzOKZZUi99oUDWVqBqNLXwbikRTehTqvFBgh7waQyaomjnzIsH8YLJafqWgiWKS3vd+FtjfFSf35idceOJQYjCzGKdPS4y4R71+SufR4BfPozPQLDGu585xK7iCF5Tc3DtSRbFZrhb2prqw2k9F5FP7pnoqfDQLUN598EZNyVmKPtDslNBJZz4I3d6aoBAAKegH88nd96q/C5KGmPH22tuwlLnGFWgwpPLsATB8Y2o2uxVe0SHMkzsbPJ8UwiEBvXD7SIonsO8lU0gLxPS8/+cymF3TAsfVAY24mM7QUH0g0iK/PeNhUx2F4hPndxJZ3yR7/dePmkTLI87r2tPUuvUAY/Fu n/2IE8SX YE01Fo2qhM5jqvkmD4FBdpV6xSL6uruPdrgTcW1V1kjH3twSZecGtUqsrkn2xRJx68sJGT7EzFGJz8BKZCXW8mquTFPEVCWKi9/y6ZnPIvqGmjAQEMjBJjst6dib5XVbZFtpmOZdlaXepzbHY3vORjbgxrvZNVbfFrmCZPvbBrIjV7+rHe8uHquE4eE8FknhHKZJ6lH+0lN42r0S6DzByGpMprw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 > > > >