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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4B6AC3ABB9 for ; Mon, 5 May 2025 12:51:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C35A56B0088; Mon, 5 May 2025 08:51:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B95566B0089; Mon, 5 May 2025 08:51:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E9396B008A; Mon, 5 May 2025 08:51:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7C9AF6B0088 for ; Mon, 5 May 2025 08:51:35 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EEB64B821B for ; Mon, 5 May 2025 12:51:35 +0000 (UTC) X-FDA: 83408840550.16.501C497 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf21.hostedemail.com (Postfix) with ESMTP id 89FA51C0003 for ; Mon, 5 May 2025 12:51:33 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=JCW8JfVX; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf21.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746449493; a=rsa-sha256; cv=none; b=n6x4FErQXCrJsRzG3LwPnzqqYJ5mPsj2lUXNcPd+pqq8ftQp1gL+WrcevJaesCLwMiG6yx OWaQpHbG/VCfs127ShSj7Gb4cSHKjnFdqYNTpPXRX8jcOEV+DZlTRjq1arJiipeHZevvAt mrvZZ9Wgm/J6q6eKaJk3phxjZ4OVC3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746449493; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dyhw/FIP+Ggm5eJ5avMrVAF3kLS/rap+JLAS6WAosgI=; b=FkTjO79zXsoh+cSQ5KbygRWrnQs0Jm3D9sMcYLNGSnCpQ13/DZwOEctG2R6yApYyV7o1WG euHEhcF+yhco1wtMjy/KbkUq5f48Mqn0PYVFOiLezgo0MII5BOmT34cbBH8XhJFw8YnnCu L0L8fjEDWPdjr/zF+UslaCmDXtDl+DU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=JCW8JfVX; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf21.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 545C5DNr007806; Mon, 5 May 2025 12:51:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=dyhw/F IP+Ggm5eJ5avMrVAF3kLS/rap+JLAS6WAosgI=; b=JCW8JfVXwhmjO0Rzx6PLAh SbywPWhxcSwR8HLTKaxaMwDwif5X5J+OB6OkIt6T/003Ev9Q9kq/P2BI6lswX03t LO9cUU3s5C8SN0fnTva5PqhkbaHm7/JsWIKysl7i+o49HlePWl1NarLHXXZ76Ixp g5pDYN86wIp4aac1lzI94GoD3U17bfpfdo5oJPfbIVh0yu7fsZzJDQveqbPp0SII O71v0RDkkkK9xmT7YeTf7FenaLaX6mINiqz83bmdxYiIi6uNixCQUnX3JiqChm6n +dFiigDYObszjdlhu6k+R2L6tUlkHYLoGb796LIGix+2sJebYwJf3AqWD/DTs6RA == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 46egcv2w0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 May 2025 12:51:20 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 545CnHFa018659; Mon, 5 May 2025 12:51:19 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 46egcv2w0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 May 2025 12:51:19 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5458gwKP032220; Mon, 5 May 2025 12:51:18 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 46dxyme4tn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 May 2025 12:51:18 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 545CpIbw30540396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 May 2025 12:51:18 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 733E958050; Mon, 5 May 2025 12:51:18 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F34F58054; Mon, 5 May 2025 12:51:13 +0000 (GMT) Received: from [9.124.223.213] (unknown [9.124.223.213]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 5 May 2025 12:51:13 +0000 (GMT) Message-ID: Date: Mon, 5 May 2025 18:21:11 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/3] driver/base: Optimize memory block registration to reduce boot time To: David Hildenbrand , Oscar Salvador Cc: Mike Rapoport , Zi Yan , Greg Kroah-Hartman , Andrew Morton , rafael@kernel.org, Danilo Krummrich , Ritesh Harjani , Jonathan Cameron , Alison Schofield , Yury Norov , Dave Jiang , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <188fbfba-afb4-4db7-bbba-7689a96be931@redhat.com> <74c500dd-8d1c-4177-96c7-ddd51ca77306@redhat.com> <0e568e33-34fa-40f6-a20d-ebf653de123d@redhat.com> Content-Language: en-US From: Donet Tom In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fHabdSf_RQKPP6W4SqXRBmrzMUryeuL0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTA1MDEyMSBTYWx0ZWRfX20roR/65sH0s FF0KlBjk6J2d0t8pEQ3XgJo+8ufB6iWh+gClrD1PVrbsxNglzRL8/9sicdDI5aPZ0ph5XqWLRF/ hyJ/yBV70MbhYJZ2xRVJ9PpwVKeeeksL+wfWDhVNhGczROvAQSQmwAev2khPWIjkNIsM1G6+u5q DuR8avyB24XpiaqTTUNMT95lCm3tpW3wG1XFCZ/evcb7xkdYHwkBTdF0NX3H29NlY/ZKJJvCyaT 5WKjV6+nPHP1wTOYVI08x5DzlpH9Hu0Cjgu4zxiEQgJTSdLulb4mkW1JZ2AcyPhZ/vp3QhJFt1y DezIhe6JbVrL8C7OyjJZxUkPGphvmDvAftYoATIP0Fo9E33BixfmeN2pZAuC/o2DVrGAAs1NYiy 5fKGgM1ChMkBKpdQ7n73/92LjHn4NtKSeCjziw1QoE1TvbeAnuJ3AOb6ttDFmzFbk7g2yTdq X-Authority-Analysis: v=2.4 cv=O7k5vA9W c=1 sm=1 tr=0 ts=6818b448 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=ndBISzoNWe6kelugQUgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: QKkbnFU8QpeYtmkXTH4Jskx9DvAdOo9l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-05_05,2025-05-05_01,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 adultscore=0 phishscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2505050121 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 89FA51C0003 X-Stat-Signature: 938mh8o6g6kesmmggt1mxyyerjukwghk X-Rspam-User: X-HE-Tag: 1746449493-537441 X-HE-Meta: U2FsdGVkX1+Ntxe0+IJz0StFv6lBYPjR/go/qhZiXSpLI3HoqQ/yUFNlWVBobxssGYttTa9yQk0aYtnYCBJnu6O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WAwXQLAXSunRq7/uc++o3APmIJ1ZZCrT0UTWfUql07GL/IcV6YFlCoqn4hRfr+XD2693kCuthohdQMrkrZGXufURmgRJz6nnBMqfc1aZEagyD3lxztB2SA67aTGGGlF9tSk8gOP4UQbsbAQOa2mJadidsGIFhMZgLA= 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: List-Subscribe: List-Unsubscribe: On 5/5/25 4:06 PM, David Hildenbrand wrote: > On 05.05.25 11:36, Oscar Salvador wrote: >> On Mon, May 05, 2025 at 10:12:48AM +0200, David Hildenbrand wrote: >>> Assume you hotplug the second CPU. The node is already >>> registered/online, so >>> who does the register_cpu_under_node() call? >>> >>> It's register_cpu() I guess? But no idea in which order that is >>> called with >>> node onlining. >>> >>> The code has to be cleaned up such that onlining a node does not >>> traverse >>> any cpus / memory. >>> >>> Whoever adds a CPU / memory *after onlining the node* must register the >>> device manually under the *now online* node. >> >> So, I think this is the sequence of events: >> >> - hotplug cpu: >>    acpi_processor_hotadd_init >>     register_cpu >>      register_cpu_under_node >> >>    online_store >>     device_online()->dev_bus_online() >>      cpu_subsys->online() >>       cpu_subsys_online >>        cpu_device_up >>         cpu_up >>          try_online_node  <- brings node online >>           ... >>           register_one_node <- registers cpu under node >>          _cpu_up > > My thinking was, whether we can simply move the > register_cpu_under_node() after the try_online_node(). See below > regarding early. > > And then, remove the !node_online check from register_cpu_under_node(). > > But it's all complicated, because for memory, we link a memory block > to the node (+set the node online) when it gets added, not when it > gets onlined. > > For CPUs, we seem to be creating the link + set the node online when > the CPU gets onlined. > >> >> The first time we hotplug a cpu to the node, note that >> register_cpu()->register_cpu_under_node() will bail out as node is still >> offline, so only cpu's sysfs will be created but they will not be linked >> to the node. > > Later, online_store()->...->cpu_subsys_online()->..->cpu_up() will > take> care of 1) onlining the node and 2) register the cpu to the node > (so, >> link the sysfs). > > > And only if it actually gets onlined I assume. > >> >> The second time we hotplug a cpu, >> register_cpu()->register_cpu_under_node() will do its job as the node is >> already onlined. >> And we will not be calling register_one_node() from __try_online_node() >> because of the same reason. >> >> The thing that bothers me is having register_cpu_under_node() spread >> around. > > Right. > >> I think that ideally, we should only be calling >> register_cpu_under_node() >> from register_cpu(), but we have this kinda of (sort of weird?) relation >> that even if we hotplug the cpu, but we do not online it, the numa node >> will remain online, and so we cannot do the linking part (cpu <-> node), >> so we could not really only have register_cpu_under_node() in >> register_cpu(), which is the hot-add part, but we also need it in the >> cpu_up()->try_online_node() which is the online part. > > Maybe one could handle CPUs similar to how we handle it with memory: > node gets onlined + link created as soon as we add the CPU, not when > we online it. > > But likely there is a reason why we do it like that today ... > >> >> And we cannot also remove the register_cpu_under_node() from >> register_cpu() because it is used in other paths (e.g: at boot time ). > > Ah, so in that case we don't call cpu_up ... hm. > > Of course, we can always detect the context (early vs. hotplug). > Maybe, we should split the early vs. hotplug case up much earlier. > > register_cpu_early() / register_cpu_hotplug() ... maybe Hi David and Oscar, I was thinking that __try_online_node(nid, true) being called from try_online_node() might cause issues with this patch. From the discussion above, what I understand is: When try_online_node() is called, there are no memory resources available for the node, so register_memory_blocks_under_node() has no effect. Therefore, our patch should work in all cases. Do you think we need to make any changes to this patch? Thanks Donet