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 7742AC433EF for ; Thu, 5 May 2022 10:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243840AbiEEKld (ORCPT ); Thu, 5 May 2022 06:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230474AbiEEKla (ORCPT ); Thu, 5 May 2022 06:41:30 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7B8615A03 for ; Thu, 5 May 2022 03:37:49 -0700 (PDT) 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 7309D218EA; Thu, 5 May 2022 10:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651747068; 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=GTwVS8/eqyBZAbCKa/0l/VA+S7qOOVL2pm+hvdN4ZkE=; b=Y691v4KG12nrehqbFRumAxTm0U3do6LGpran0xuYs2VJs556/qMVRGzkX506WOJ/4Tejya nMvr4Os6Mb5jtS8kkDgVo5kAiGZsqLN/CG3CMTPZcFWjFF/NiFKe0mlJuSbCo5BDORjbyl iglvOVHeamzW+Vz3+wrrsB5Lurqc7iw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651747068; 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=GTwVS8/eqyBZAbCKa/0l/VA+S7qOOVL2pm+hvdN4ZkE=; b=PZsLciE3RxED7WH9BHH3zmF63v3B/dzCxY8262Ug9DncbaLD6MaYtfXtLcxOaxq6gA4K3+ JfpufGt2DDHH/yCg== 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 0B4D813B11; Thu, 5 May 2022 10:37:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id NlsZAPyoc2IOTQAAMHmgww (envelope-from ); Thu, 05 May 2022 10:37:48 +0000 Date: Thu, 5 May 2022 12:37:46 +0200 From: Oscar Salvador To: David Hildenbrand Cc: Andrew Morton , Michal Hocko , Wei Yang , Miaohe Lin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] mm/memory_hotplug: Reset node's state when empty during offline Message-ID: References: <20220307150725.6810-1-osalvador@suse.de> <20220307150725.6810-3-osalvador@suse.de> <0d2853f6-66e5-251a-2d9e-c229f0ebcd5e@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0d2853f6-66e5-251a-2d9e-c229f0ebcd5e@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 28, 2022 at 02:30:20PM +0200, David Hildenbrand wrote: > On 07.03.22 16:07, Oscar Salvador wrote: > > +static void node_reset_state(int node) > > +{ > > + pg_data_t *pgdat = NODE_DATA(node); > > + int cpu; > > + > > + kswapd_stop(node); > > + kcompactd_stop(node); > > + > > + reset_node_managed_pages(pgdat); > > + reset_node_present_pages(pgdat); > > + > > + pgdat->nr_zones = 0; > > + pgdat->kswapd_order = 0; > > + pgdat->kswapd_highest_zoneidx = 0; > > + pgdat->node_start_pfn = 0; > > > I'm confused why we have to mess with > * present pages > * managed pages > * node_start_pfn > > here at all. > > 1) If there would be any present page left, calling node_reset_state() > would be a BUG. > 2) If there would be any manged page left, calling node_reset_state() > would be a BUG. > 3) node_start_pfn will be properly updated by > remove_pfn_range_from_zone()->update_pgdat_span() Yes, you are right, trusting update_pgdat_span() is the right to do here. > To make it clearer, I *think* touching node_start_pfn is very wrong. > > What if the node still has ZONE_DEVICE? They don't account towards > present pages but only towards spanned pages, and we're messing with the > start range. Did not think of that scenario, but as you said, we should be leaving node/zone's pages accounting alone here. > remove_pfn_range_from_zone()->update_pgdat_span() should be the only > place that modifies the spanned range when offlining. Will update the patch. Thanks for the review David! -- Oscar Salvador SUSE Labs