Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4739563iob; Sun, 8 May 2022 23:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUE5OV+X/H/GlvGb8l3oua3goCNJ327BPQhhs+o5bLHquniyxErIzJUtiH+h/J+ZDlKv7F X-Received: by 2002:a05:6a00:ad0:b0:4e1:2d96:2ab0 with SMTP id c16-20020a056a000ad000b004e12d962ab0mr14843303pfl.3.1652079086246; Sun, 08 May 2022 23:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652079086; cv=none; d=google.com; s=arc-20160816; b=xGyK9IUHTRzwF/RrAyLNNndWffSjmmb9mJIm+/Khp9CAM7IjukqDdkpMBMmJEeQ49n MC7ng2+E2215FcS7pvPrM48UdMmTPb1PnQRu4ZN3sKlAudYeCsblpLRW9a07ktiHbkrN JUdtss2khv70MXXHNNIxHLyI6w1FESKe60aRv6CoqJOxGBSlDHkDeAUHY4cJIEI9Vh7C 2ynQQspW4PI5e+tkM+yrUBRVGxTalI5NHp+vruNwJAiFz38cQ8Nn9PWzbJVPPd+QdJbf WBtHS2gbNzSf9IJ3MoGsD+lyAaEFJ+svBxScvqZCQmDYLYU9q3TkCRS00HeYJ1oevJFt bPSg== 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 :dkim-signature; bh=GTwVS8/eqyBZAbCKa/0l/VA+S7qOOVL2pm+hvdN4ZkE=; b=Vl46E9udZvbY0DKRfxB18Rz1aQO8Ie0vo/IUiew9H93vwBWMmhgry9jZRNrPubkcqi a+k4DcKHsNkCqLrejeWHGNH3Cbh8oPWniK3IO3Mxx/1EIgisFKMohmVBNT2oI3PkURBD Ts/OWa0CzFon6sQ0y7yYdGs2iOu8setT6a/XnGXwvaJ2UfSyt5E8iUenqOsOIKLPiVk4 kPyb/2dgNkLBJQd9sV0flDtgHHKjvCbmM4i1iOCJeRqkVzFTnNYOSN90MX4wvglxZd3b IYVIws9EIHxRocnvq7v6szctAYva19w17uVrRPSBYQnLWMAsmoFzHDqoYG6iwETWTarT gk7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Y691v4KG; dkim=neutral (no key) header.i=@suse.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k7-20020a056a00134700b004faec051bd4si14649568pfu.242.2022.05.08.23.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:51:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Y691v4KG; dkim=neutral (no key) header.i=@suse.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DF7F0196FFE; Sun, 8 May 2022 23:48:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240102AbiEEKlb (ORCPT + 99 others); Thu, 5 May 2022 06:41:31 -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> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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