From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61AF6469D for ; Thu, 11 Dec 2025 05:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765430174; cv=none; b=SiRwybtOTPCe+Hb6AARt85EzVROjKoqmx+7xQJRQ3tYeshv+au7fMnPe9FhfV4sV4g9EbdmUmWxKq0uPM6IqcFKjvF4gzLL3P9tBNsZzqedCu3vd59gLi0QuBrQGx/j8F7IiCYaW26hPYezJSrq/rmuVAyVs0OuTSddcbw/5muI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765430174; c=relaxed/simple; bh=BNqygVdZF3uN5WIog7uwIMe0BCKFklBO6X8EKjHsoM4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GmpeKFn+gmmGdUWxFxmyMzxKi+b2708FMnP2kwRge/Hvw/dQW1GNCjv13zUfAONZLILAuAQOtWlN9IZlIkh3bqDiE/OlKkrd2NRf+JZ6Dxy+dqiFpQmpe02Mh0uhKyPrctSAN13xPrVXwT91/zx7vpHwtXAy9rR58+RD0yIX4Hs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=EsqaK+b4; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=QIElUVwL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=nBItFmQX; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=iTBATg1k; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="EsqaK+b4"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="QIElUVwL"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="nBItFmQX"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="iTBATg1k" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4CDA05BD5B; Thu, 11 Dec 2025 05:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1765430170; 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=ers3ixHL8W9DPh68jGWp3T9AioXIVuTQmqnETwRdD1Q=; b=EsqaK+b4SdN62gbYftoi+D5PvvwkH079hPM+fkU5bw5Ax5L5rkwToEdoinKV8FxG9K7JiK oNKIK9C+/PR8QQBR4C27BwRMn/e5MzQO5bPySd3rG8DG+vdCTUtjeeg3r46tIcKcSfuBlD dCfhLq+FATW8YrCORtl1cafg874O2TU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1765430170; 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=ers3ixHL8W9DPh68jGWp3T9AioXIVuTQmqnETwRdD1Q=; b=QIElUVwLqPS1gNkSQiVhWG76WLcdRnpWy3oGp3AHPxc5pZbbS9LdtPUdi8dtKbrCgJ6wG2 4V6duAIDR3dzgWCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nBItFmQX; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=iTBATg1k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1765430169; 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=ers3ixHL8W9DPh68jGWp3T9AioXIVuTQmqnETwRdD1Q=; b=nBItFmQXDkG8I231s6XiKi6WFRS5w/IGziORPA8VO3x8CHa22zWEJuGPwhqrKeEXTV3OZ7 9O3OHJOlNVuJag0avAEd5MckEM/jT2cZgf+WSco09nGnEjchh1PsSuwGewKkg7q2tJIcB9 f3YexrjqfiL1jvZZd/0iZGqiE739/ns= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1765430169; 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=ers3ixHL8W9DPh68jGWp3T9AioXIVuTQmqnETwRdD1Q=; b=iTBATg1kQPGtuMhJA+/6oDb5O1fjVJ9WaLVN3D3o5QoCZnlSr3pHOgU5NOKAqb1laHW5oR AiSYm09lwYjxF+Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7789A3EA63; Thu, 11 Dec 2025 05:16:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id en1PGphTOmnHHAAAD6G6ig (envelope-from ); Thu, 11 Dec 2025 05:16:08 +0000 Date: Thu, 11 Dec 2025 06:16:02 +0100 From: Oscar Salvador To: Tianyou Li Cc: David Hildenbrand , Mike Rapoport , Wei Yang , linux-mm@kvack.org, Yong Hu , Nanhai Zou , Yuan Liu , Tim Chen , Qiuxu Zhuo , Yu C Chen , Pan Deng , Chen Zhang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 2/2] mm/memory hotplug: fix zone->contiguous always false when hotplug Message-ID: References: <20251208152544.1150732-1-tianyou.li@intel.com> <20251208152544.1150732-3-tianyou.li@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251208152544.1150732-3-tianyou.li@intel.com> X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWELVE(0.00)[14]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,kernel.org,gmail.com,kvack.org,intel.com,linux.intel.com,jd.com,vger.kernel.org]; DBL_BLOCKED_OPENRESOLVER(0.00)[intel.com:email,localhost.localdomain:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; MISSING_XM_UA(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Level: X-Rspamd-Queue-Id: 4CDA05BD5B X-Spam-Flag: NO X-Spam-Score: -3.01 On Mon, Dec 08, 2025 at 11:25:44PM +0800, Tianyou Li wrote: > From: Yuan Liu > > Function set_zone_contiguous used __pageblock_pfn_to_page to > check the whole pageblock is in the same zone. One assumption is > the memory section must online, otherwise the __pageblock_pfn_to_page > will return NULL, then the set_zone_contiguous will be false. > When move_pfn_range_to_zone invoked set_zone_contiguous, since the > memory section did not online, the return value will always be false. Then, this means that zone->contiguous was always left false on new memory-hotplug operations, if it was false before? I guess we did not notice this before because it is just an optimization so we always took the long road. Nice catch. > To fix this issue, we removed the set_zone_contiguous from the > move_pfn_range_to_zone, and place it after memory section onlined. > > Function remove_pfn_range_from_zone did not have this issue because > memory section remains online at the time set_zone_contiguous invoked. > > Reviewed-by: Tianyou Li > Reviewed-by: Nanhai Zou > Signed-off-by: Yuan Liu > --- > mm/memory_hotplug.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index d711f6e2c87f..f548d9180415 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -809,8 +809,7 @@ void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, > { > struct pglist_data *pgdat = zone->zone_pgdat; > int nid = pgdat->node_id; > - const enum zone_contig_state contiguous_state = > - zone_contig_state_after_growing(zone, start_pfn, nr_pages); > + > clear_zone_contiguous(zone); > > if (zone_is_empty(zone)) > @@ -840,8 +839,6 @@ void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, > memmap_init_range(nr_pages, nid, zone_idx(zone), start_pfn, 0, > MEMINIT_HOTPLUG, altmap, migratetype, > isolate_pageblock); > - > - set_zone_contiguous(zone, contiguous_state); > } > > struct auto_movable_stats { > @@ -1150,6 +1147,7 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages, > { > unsigned long end_pfn = pfn + nr_pages; > int ret, i; > + enum zone_contig_state contiguous_state = ZONE_CONTIG_NO; > > ret = kasan_add_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages)); > if (ret) > @@ -1164,6 +1162,10 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages, > if (mhp_off_inaccessible) > page_init_poison(pfn_to_page(pfn), sizeof(struct page) * nr_pages); > > + if (IS_ALIGNED(end_pfn, PAGES_PER_SECTION)) > + contiguous_state = zone_contig_state_after_growing(zone, pfn, > + nr_pages); Uhm, I think this deserves a little comment. I guess that if we are not allocating memmap pages worth of a full section, we keep it ZONE_CONTIG_NO. -- Oscar Salvador SUSE Labs