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 X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D46C7C4727D for ; Mon, 5 Oct 2020 12:52:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1BF3D2078D for ; Mon, 5 Oct 2020 12:52:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="EDNTZtVl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BF3D2078D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 358146B0068; Mon, 5 Oct 2020 08:52:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3080D6B006C; Mon, 5 Oct 2020 08:52:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F72A6B006E; Mon, 5 Oct 2020 08:52:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id E6C4C6B0068 for ; Mon, 5 Oct 2020 08:52:51 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8CBC78249980 for ; Mon, 5 Oct 2020 12:52:51 +0000 (UTC) X-FDA: 77337861342.27.print79_5101f82271be Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 631EE3D663 for ; Mon, 5 Oct 2020 12:52:51 +0000 (UTC) X-HE-Tag: print79_5101f82271be X-Filterd-Recvd-Size: 4544 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Mon, 5 Oct 2020 12:52:50 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601902369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ns5ZwFCdhDQq4nuYCyyIwqB39q09F/YpJPjZ7uWOQmY=; b=EDNTZtVlRR9rydSnWsBPBEsy9+JwwzprOyNvfSZbCe1SyXZ8VlxTvHFinU4FWOO501B9o7 Gv6AuREmjDmsxD6vP90QvMQ9bzlZxBJFlt6g1zYyRwdr0p3Oys4PvXdZti26k7ffY+6Ga1 4fdeizJ2gsnSAz3DO9aooUaw9MS2+m8= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6B235ADBE; Mon, 5 Oct 2020 12:52:49 +0000 (UTC) Date: Mon, 5 Oct 2020 14:52:47 +0200 From: Michal Hocko To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pavel Tatashin , David Hildenbrand , Oscar Salvador , Joonsoo Kim Subject: Re: [PATCH 2/9] mm, page_alloc: calculate pageset high and batch once per zone Message-ID: <20201005125247.GX4555@dhcp22.suse.cz> References: <20200922143712.12048-1-vbabka@suse.cz> <20200922143712.12048-3-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922143712.12048-3-vbabka@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue 22-09-20 16:37:05, Vlastimil Babka wrote: > We currently call pageset_set_high_and_batch() for each possible cpu, which > repeats the same calculations of high and batch values. > > Instead call the function just once per zone, and make it apply the calculated > values to all per-cpu pagesets of the zone. > > This also allows removing the zone_pageset_init() and __zone_pcp_update() > wrappers. > > No functional change. > > Signed-off-by: Vlastimil Babka > Reviewed-by: Oscar Salvador > Reviewed-by: David Hildenbrand I like this. One question below Acked-by: Michal Hocko > --- > mm/page_alloc.c | 42 ++++++++++++++++++------------------------ > 1 file changed, 18 insertions(+), 24 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index a163c5e561f2..26069c8d1b19 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6219,13 +6219,14 @@ static void setup_pageset(struct per_cpu_pageset *p) > } > > /* > - * Calculate and set new high and batch values for given per-cpu pageset of a > + * Calculate and set new high and batch values for all per-cpu pagesets of a > * zone, based on the zone's size and the percpu_pagelist_fraction sysctl. > */ > -static void pageset_set_high_and_batch(struct zone *zone, > - struct per_cpu_pageset *p) > +static void zone_set_pageset_high_and_batch(struct zone *zone) > { > unsigned long new_high, new_batch; > + struct per_cpu_pageset *p; > + int cpu; > > if (percpu_pagelist_fraction) { > new_high = zone_managed_pages(zone) / percpu_pagelist_fraction; > @@ -6237,23 +6238,25 @@ static void pageset_set_high_and_batch(struct zone *zone, > new_high = 6 * new_batch; > new_batch = max(1UL, 1 * new_batch); > } > - pageset_update(&p->pcp, new_high, new_batch); > -} > - > -static void __meminit zone_pageset_init(struct zone *zone, int cpu) > -{ > - struct per_cpu_pageset *pcp = per_cpu_ptr(zone->pageset, cpu); > > - pageset_init(pcp); > - pageset_set_high_and_batch(zone, pcp); > + for_each_possible_cpu(cpu) { > + p = per_cpu_ptr(zone->pageset, cpu); > + pageset_update(&p->pcp, new_high, new_batch); > + } > } > > void __meminit setup_zone_pageset(struct zone *zone) > { > + struct per_cpu_pageset *p; > int cpu; > + > zone->pageset = alloc_percpu(struct per_cpu_pageset); > - for_each_possible_cpu(cpu) > - zone_pageset_init(zone, cpu); > + for_each_possible_cpu(cpu) { > + p = per_cpu_ptr(zone->pageset, cpu); > + pageset_init(p); > + } > + > + zone_set_pageset_high_and_batch(zone); I hope I am not misreading the diff but it seems that setup_zone_pageset is calling pageset_init which is then done again by zone_set_pageset_high_and_batch as a part of pageset_update -- Michal Hocko SUSE Labs