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 3B057C433EF for ; Wed, 16 Feb 2022 12:02:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C33D46B007D; Wed, 16 Feb 2022 07:02:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE1906B007E; Wed, 16 Feb 2022 07:02:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA9B86B0080; Wed, 16 Feb 2022 07:02:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0029.hostedemail.com [216.40.44.29]) by kanga.kvack.org (Postfix) with ESMTP id 974A96B007D for ; Wed, 16 Feb 2022 07:02:04 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5750E8DF68 for ; Wed, 16 Feb 2022 12:02:04 +0000 (UTC) X-FDA: 79148504568.19.8690A85 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf20.hostedemail.com (Postfix) with ESMTP id 908F41C0010 for ; Wed, 16 Feb 2022 12:02:03 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3AF0321763; Wed, 16 Feb 2022 12:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1645012922; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kr9dETkBJpugtcSkfZO+bjcmUGF0KSfTN/IBCGVngP4=; b=nfePnksG+NG2Z0qM7wRUlAloNATUCtIQUk6znsvYEpA4hxSTZsw5bFcerWsG8u8cpTCe8d EFqsssmkAnhb6wUyRkbLkp+4dkvBgCi/kpKbIgjVAoGKU4TP7pL3+kw+KhTuaT2uck89BN RKLIIhI63NxuWfr0co0p9JtcCWR4e6o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1645012922; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kr9dETkBJpugtcSkfZO+bjcmUGF0KSfTN/IBCGVngP4=; b=Dd1MZt1sZ8lHTN+X+ydf4DfYr812TeEkgjBiybL0cdX7B9OK5TtVvtm/FEqztwOeS8ZBwR xp+n6JXhvcgHoZDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1A04513AF3; Wed, 16 Feb 2022 12:02:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id H5ShBbrnDGJqQAAAMHmgww (envelope-from ); Wed, 16 Feb 2022 12:02:02 +0000 Message-ID: Date: Wed, 16 Feb 2022 13:02:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Content-Language: en-US To: Mel Gorman , Andrew Morton Cc: Aaron Lu , Dave Hansen , Michal Hocko , Jesper Dangaard Brouer , LKML , Linux-MM References: <20220215145111.27082-1-mgorman@techsingularity.net> <20220215145111.27082-3-mgorman@techsingularity.net> From: Vlastimil Babka Subject: Re: [PATCH 2/5] mm/page_alloc: Track range of active PCP lists during bulk free In-Reply-To: <20220215145111.27082-3-mgorman@techsingularity.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 908F41C0010 X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=nfePnksG; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Dd1MZt1s; spf=pass (imf20.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Stat-Signature: z9y3h6agsifzbwnss67cfka3wz56zpaj X-HE-Tag: 1645012923-933729 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: On 2/15/22 15:51, Mel Gorman wrote: > free_pcppages_bulk() frees pages in a round-robin fashion. Originally, > this was dealing only with migratetypes but storing high-order pages > means that there can be many more empty lists that are uselessly > checked. Track the minimum and maximum active pindex to reduce the > search space. > > Signed-off-by: Mel Gorman > --- > mm/page_alloc.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 08de32cfd9bb..c5110fdeb115 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1450,6 +1450,8 @@ static void free_pcppages_bulk(struct zone *zone, int count, > struct per_cpu_pages *pcp) > { > int pindex = 0; > + int min_pindex = 0; > + int max_pindex = NR_PCP_LISTS - 1; > int batch_free = 0; > int nr_freed = 0; > unsigned int order; > @@ -1478,10 +1480,17 @@ static void free_pcppages_bulk(struct zone *zone, int count, > if (++pindex == NR_PCP_LISTS) Hmm, so in the very first iteration at this point pindex is already 1. This looks odd even before the patch, as order 0 MIGRATE_UNMOVABLE list is only processed after all the higher orders? > pindex = 0; Also shouldn't this wrap-around check also use min_index/max_index instead of NR_PCP_LISTS and 0? > list = &pcp->lists[pindex]; > - } while (list_empty(list)); > + if (!list_empty(list)) > + break; > + > + if (pindex == max_pindex) > + max_pindex--; > + if (pindex == min_pindex) So with pindex 1 and min_pindex == 0 this will not trigger until (eventually) the first pindex wrap around, which seems suboptimal. But I can see the later patches change things substantially anyway so it may be moot... > + min_pindex++; > + } while (1); > > /* This is the only non-empty list. Free them all. */ > - if (batch_free == NR_PCP_LISTS) > + if (batch_free >= max_pindex - min_pindex) > batch_free = count; > > order = pindex_to_order(pindex);