Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1669398pxb; Mon, 12 Apr 2021 04:00:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6iRvJSHNCpAt/nAayPeGOKx9owYV/GfXf9RVPwI0NtZUX9Gql/yhWW0ElIl/E/QesrVjV X-Received: by 2002:a65:66c3:: with SMTP id c3mr26141956pgw.355.1618225204313; Mon, 12 Apr 2021 04:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618225204; cv=none; d=google.com; s=arc-20160816; b=0iuCHGJixuKySAargTv4GGYhgVcuhMuN19CW6pAD0lkd2mRz+YRlrraKeU5RiIaI4R R9tgXzfN+6BhSDl6IvFUqfDkqjCAKYHWP8Um6pvnckYqIhdY06LLD07hL9Xy5Lbw5Mdr jsbousayu1J0wf+08GP51jdGGkzfHsURYnvfkr9AbohB5gTzi3KxVUTXJ/orrTXMnGDI yBkedYDM8LjL7Mba5uiYi+mqkMdcIzSyt0wa4wdT7lTAftxqwkaIyxG9V7b89u5XG/4p L64r1ip0d7q0tjYMCxN3rlVzArv879kzuVG+l4Vvh4Bdsct6xdC51t7F179rMBYQueKx JvRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=XN+Hsj3t6DX31g/xnH3Xi2F3eoqFtj18NDGe4ivrblc=; b=z48u0cM71kJQ++qLjYSL68ZG1mA8lcO67Yez61FXsxlnd++MidYK2zT56KAfNMURy1 Nlg5jMNQhmKoRCUFC9c6qJUt5QPLpah6xq3HLuWLO3p41Tl2Q33SWDSxQ8fc4B2gZ7e/ 47WgLkLA+02h2kDRj616uCzWliHkKs85KZVjkrmc7fcHGHUNPM2xhBp6TK9vXsg44nGw 6/8TynumtnYBHd1UboEi/3+JUrH6XRzeknh5hxuQh8z8rihPU7P+dGlICNtcct9xWKMh AHlwe3suVpl9q3wgmvwQKn2pUxej9h5JNsMbWYQgPP7cmGHUmXTZ+EYNKE0CRsA7rFpR /j/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si12890164pjd.151.2021.04.12.03.59.48; Mon, 12 Apr 2021 04:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239817AbhDLLAA (ORCPT + 99 others); Mon, 12 Apr 2021 07:00:00 -0400 Received: from outbound-smtp26.blacknight.com ([81.17.249.194]:59420 "EHLO outbound-smtp26.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239705AbhDLK76 (ORCPT ); Mon, 12 Apr 2021 06:59:58 -0400 Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp26.blacknight.com (Postfix) with ESMTPS id CBACDCABA6 for ; Mon, 12 Apr 2021 11:59:39 +0100 (IST) Received: (qmail 8089 invoked from network); 12 Apr 2021 10:59:39 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 12 Apr 2021 10:59:39 -0000 Date: Mon, 12 Apr 2021 11:59:38 +0100 From: Mel Gorman To: Vlastimil Babka Cc: Andrew Morton , Chuck Lever , Jesper Dangaard Brouer , Christoph Hellwig , Alexander Duyck , Matthew Wilcox , Ilias Apalodimas , LKML , Linux-Net , Linux-MM , Linux-NFS Subject: Re: [PATCH 2/9] mm/page_alloc: Add a bulk page allocator Message-ID: <20210412105938.GU3697@techsingularity.net> References: <20210325114228.27719-1-mgorman@techsingularity.net> <20210325114228.27719-3-mgorman@techsingularity.net> <28729c76-4e09-f860-0db1-9c79c8220683@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <28729c76-4e09-f860-0db1-9c79c8220683@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, Apr 12, 2021 at 12:21:42PM +0200, Vlastimil Babka wrote: > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 8a3e13277e22..eb547470a7e4 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -4965,6 +4965,124 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, > > return true; > > } > > > > +/* > > + * __alloc_pages_bulk - Allocate a number of order-0 pages to a list > > + * @gfp: GFP flags for the allocation > > + * @preferred_nid: The preferred NUMA node ID to allocate from > > + * @nodemask: Set of nodes to allocate from, may be NULL > > + * @nr_pages: The number of pages desired on the list > > + * @page_list: List to store the allocated pages > > + * > > + * This is a batched version of the page allocator that attempts to > > + * allocate nr_pages quickly and add them to a list. > > + * > > + * Returns the number of pages on the list. > > + */ > > +int __alloc_pages_bulk(gfp_t gfp, int preferred_nid, > > + nodemask_t *nodemask, int nr_pages, > > + struct list_head *page_list) > > +{ > > + struct page *page; > > + unsigned long flags; > > + struct zone *zone; > > + struct zoneref *z; > > + struct per_cpu_pages *pcp; > > + struct list_head *pcp_list; > > + struct alloc_context ac; > > + gfp_t alloc_gfp; > > + unsigned int alloc_flags; > > Was going to complain that this is not set to ALLOC_WMARK_LOW. Must be faster > next time... > Good that you caught it anyway! > > + int allocated = 0; > > + > > + if (WARN_ON_ONCE(nr_pages <= 0)) > > + return 0; > > + > > + /* Use the single page allocator for one page. */ > > + if (nr_pages == 1) > > + goto failed; > > + > > + /* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */ > > I don't understand this comment. Only alloc_flags_nofragment() sets this flag > and we don't use it here? > It's there as a reminder that there are non-obvious consequences to ALLOC_NOFRAGMENT that may affect the bulk allocation success rate. __rmqueue_fallback will only select pageblock_order pages and if that fails, we fall into the slow path that allocates a single page. I didn't deal with it because it was not obvious that it's even relevant but I bet in 6 months time, I'll forget that ALLOC_NOFRAGMENT may affect success rates without the comment. I'm waiting for a bug that can trivially trigger a case with a meaningful workload where the success rate is poor enough to affect latency before adding complexity. Ideally by then, the allocation paths would be unified a bit better. > > + gfp &= gfp_allowed_mask; > > + alloc_gfp = gfp; > > + if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags)) > > + return 0; > > + gfp = alloc_gfp; > > + > > + /* Find an allowed local zone that meets the high watermark. */ > > Should it say "low watermark"? > Yeah, that's leftover from an earlier prototype :( -- Mel Gorman SUSE Labs