Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3195300pxb; Tue, 20 Apr 2021 02:47:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD8k1Oj8JiSqnx71gviDg6N2iu+BZ2lJOmL7jA56fMT9PMVR9MRkVN5lphcBNOf5Ks5lnd X-Received: by 2002:a17:906:3ec1:: with SMTP id d1mr164512ejj.523.1618912035919; Tue, 20 Apr 2021 02:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618912035; cv=none; d=google.com; s=arc-20160816; b=ElNB1PyaXOw8xyQTfH5DbeV8nkuR5aQD3qiu0gBO10d6U3M5GdoQsEd47vIaTcmW7L SBZx/f1ziXIPtjjcPXYVJRgM/1xeyKcAcbabgllIfiqS8aBGwW8L9qh32KH6MLEiFSOr 9FHbkMMSseaWlDRQGQC+QhJ8QGrURSR57sAq9hV/VdkdhwXfFr7F6PmKYZak/d2za/fv 0pinR+vr42fpBTRh7u4aQM2klXdjvlBocfUjo8SzeepT9fjw5dOFJicuD5/EXqv/kDUK 3t51HR2ipUTKxk/mvjJjtUsHWyXqbVlxZw2Pj+JoqcT5xu/dCdR7B7zPSCUVpC+ZYi+M xVCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=14X461r6HBwVx+hhqwaqj6dMjiJR1g/Aupr5pNSp110=; b=GR+340pEDu3SNxEcLvGy/sTmvnsEyhVrirc4yZnrN24lom+WvfYcjCCvHC0nzSHUvy rjLj4yh7SOc3WYdVuZYDJ8g+7cmAcEEJgo0dc15OuC5ZA94UZ5yYVspn8CCW/5YGecBh Oz7+jS8VpvvwbR7TRYniUHDH4QA5zsmKvTJoNN8ikWOjgItk+gxWF7nW6sn4MOoteSIg sgpM8DcEYL+K3kDu/TcWwEXUIRZ4Ztdi2wJ6aoVsQiEQWEg+B+CM0TcB8k0AP9khK6qv 9cgBlr19Qct2Uuj2zxYLxW/yY+AviXMZdHzRI93cfzdKydjEirm9pm4WuzjFjjWDvTZP eAUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="pS/ibClZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si14700606eja.14.2021.04.20.02.46.52; Tue, 20 Apr 2021 02:47:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="pS/ibClZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbhDTJq2 (ORCPT + 99 others); Tue, 20 Apr 2021 05:46:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:47304 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbhDTJq1 (ORCPT ); Tue, 20 Apr 2021 05:46:27 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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