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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 53F64C433ED for ; Tue, 20 Apr 2021 09:45:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D50C613AE for ; Tue, 20 Apr 2021 09:45:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D50C613AE Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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 E90D56B0036; Tue, 20 Apr 2021 05:45:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E40B46B006E; Tue, 20 Apr 2021 05:45:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE1546B0070; Tue, 20 Apr 2021 05:45:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id AC42A6B0036 for ; Tue, 20 Apr 2021 05:45:57 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6D6673636 for ; Tue, 20 Apr 2021 09:45:57 +0000 (UTC) X-FDA: 78052263954.18.7A316A2 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf05.hostedemail.com (Postfix) with ESMTP id 341C5E000137 for ; Tue, 20 Apr 2021 09:45:56 +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=1618911955; h=from:from:reply-to: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=14X461r6HBwVx+hhqwaqj6dMjiJR1g/Aupr5pNSp110=; b=pS/ibClZ+PdVBaXkraMfXYWWZyknMiWXYB0cOI3dg24PtHbbhEV2BLo3bWAsUSvzYYUhYS qu0SkdwpWsw4gquNGRqcNTtcrDSM5/NnKQqa8pNXEgkkqnOZNJE0SHgCKIX/LACaiMQUhp nsSi7QSEcymIN3J4n/1qtCZpvXkdUeo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CCB0AADD7; Tue, 20 Apr 2021 09:45:55 +0000 (UTC) Date: Tue, 20 Apr 2021 11:45:55 +0200 From: Michal Hocko To: Oscar Salvador Cc: Andrew Morton , David Hildenbrand , Anshuman Khandual , Pavel Tatashin , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 3/8] mm,memory_hotplug: Factor out adjusting present pages into adjust_present_page_count() Message-ID: References: <20210416112411.9826-1-osalvador@suse.de> <20210416112411.9826-4-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210416112411.9826-4-osalvador@suse.de> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 341C5E000137 X-Stat-Signature: hdfm7b1fhuxhq31wuq848naqms6gg9yi Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618911956-813443 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 Fri 16-04-21 13:24:06, Oscar Salvador wrote: > From: David Hildenbrand > > Let's have a single place (inspired by adjust_managed_page_count()) where > we adjust present pages. > In contrast to adjust_managed_page_count(), only memory onlining/offlining > is allowed to modify the number of present pages. > > Signed-off-by: David Hildenbrand > Signed-off-by: Oscar Salvador > Reviewed-by: Oscar Salvador Not sure self review counts ;) Acked-by: Michal Hocko Btw. I strongly suspect the resize lock is quite pointless here. Something for a follow up patch. > --- > mm/memory_hotplug.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 25e59d5dc13c..d05056b3c173 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -829,6 +829,16 @@ struct zone * zone_for_pfn_range(int online_type, int nid, unsigned start_pfn, > return default_zone_for_pfn(nid, start_pfn, nr_pages); > } > > +static void adjust_present_page_count(struct zone *zone, long nr_pages) > +{ > + unsigned long flags; > + > + zone->present_pages += nr_pages; > + pgdat_resize_lock(zone->zone_pgdat, &flags); > + zone->zone_pgdat->node_present_pages += nr_pages; > + pgdat_resize_unlock(zone->zone_pgdat, &flags); > +} > + > int __ref online_pages(unsigned long pfn, unsigned long nr_pages, > int online_type, int nid) > { > @@ -882,11 +892,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, > } > > online_pages_range(pfn, nr_pages); > - zone->present_pages += nr_pages; > - > - pgdat_resize_lock(zone->zone_pgdat, &flags); > - zone->zone_pgdat->node_present_pages += nr_pages; > - pgdat_resize_unlock(zone->zone_pgdat, &flags); > + adjust_present_page_count(zone, nr_pages); > > node_states_set_node(nid, &arg); > if (need_zonelists_rebuild) > @@ -1701,11 +1707,7 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages) > > /* removal success */ > adjust_managed_page_count(pfn_to_page(start_pfn), -nr_pages); > - zone->present_pages -= nr_pages; > - > - pgdat_resize_lock(zone->zone_pgdat, &flags); > - zone->zone_pgdat->node_present_pages -= nr_pages; > - pgdat_resize_unlock(zone->zone_pgdat, &flags); > + adjust_present_page_count(zone, -nr_pages); > > init_per_zone_wmark_min(); > > -- > 2.16.3 -- Michal Hocko SUSE Labs