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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3763EC433EF for ; Wed, 16 Feb 2022 12:02:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232967AbiBPMCS (ORCPT ); Wed, 16 Feb 2022 07:02:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232909AbiBPMCP (ORCPT ); Wed, 16 Feb 2022 07:02:15 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 829B8E7F43 for ; Wed, 16 Feb 2022 04:02:03 -0800 (PST) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);