From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010053.outbound.protection.outlook.com [40.93.198.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 074A918C02E for ; Mon, 30 Mar 2026 04:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.53 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774846691; cv=fail; b=INZl0xZZfFUcFA5inSUEKrHrfFXNrOVpRdKKSSWizMwd886ZFcnokL703zT8L1SbXmL2j+6/VayIr5klmOZbqqnjtR447E9yjw88UT2VQTUbXT8QjnTOEvQ8QhMt9KB22Q93E27O3BEIPhVDWw4dvWkAGRnvhIFmAGqqe2YOCwA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774846691; c=relaxed/simple; bh=STTeMEMYExQ1Pu8aFldkiw6nvUafjWgMEJMk8OSMX6k=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=lP5rDZNq7mdQm4a6OASZmUXM44yBIZg1dT/W6v9qqwOu/AH9lqjfXG5s0fNr/6tKk8xDVuCh599pcucyyPna1/MGiUaOHQcWPSnQrzZg/S2yas9hFQ/AEQ3DPZEg3NMM+gePC7AB9uedpASGDrjlB1RHIOYoWubwlbr9SxaDTIc= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=aluNaUnF; arc=fail smtp.client-ip=40.93.198.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="aluNaUnF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PGoudUVzvZIIXOkyjGW+l99S3Z09xOoA44bEIsDN90yKB9WQfpVnyjf9zXese0C6bDsH2evu8KEoehfwAKNP/xN4b/sBypc20LTE9T1t2XTjEOspYEOZPuXGbwJQx+bea6HyNzrJrBR0CdXqk3q9D584S6PbY4BtAsLlBJIz/u3E61rM99ePbK66N9qY73hOnMiXlB6WWZZXK7n4Wzjg+W7AY5Ouzw1Lz3f+W4Zgfe9U5eYCFjxOFu46LVYamGxvogoY4o+CwsEMTgw/AKERnJGoKiHGm9eWQRhPij9+q1or2CzZT6i/Z60f1P9k1rvcloO18AEo6IzSWONqKELcww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jq0/O8/uRdl3EIEmC1di3yxy29RAXkj0QJ9eld1MUAg=; b=mNLgi/Ci0EUBHtQj4jUF8pHUjqU4y57F7t2RYx1EDmZoYFHKE9Hq3ArSUj92rXdUmP86xMWJiZStm28LSF2QDacauKKSU0s6E+s7LIEcWjTPmscQO26ZnFxOvs7xDj63TSIYuH1O0meJ1EXCtlwr3VmDEX5RBZAmr9iumBnc/l23lItF1LusmX8ZwGQwEsoipDBXHHqJSNmhT2Ikn+mijOOpiHRYyIF51ikxRlmHUJ+H3S1GZ/AAld96OYaWeZBB63M0U67uc+hTLN+qgAtvlCxv+WR+3LQfItUgDinBOGSEz+ZqYeh7v36UsBXWpVJ2ZAqPw1CxLV9A0ckJ5IL/uQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jq0/O8/uRdl3EIEmC1di3yxy29RAXkj0QJ9eld1MUAg=; b=aluNaUnF4vXKjpQ0YYQ1kpo8t87s7x3L+ba1rcYsVhfEKK6p/GQ50dntJbAujI5KPsXyLz+dSwXE8DWc+gRIf6UWQ9VyNcPH2fnkeaG97+TTjSnmiJGEolJD5d7cUDepNx9Y6mK+3e2tXRSXrqLF6endj6VSsGlaZBMI1XKzcXw= Received: from BY5PR20CA0006.namprd20.prod.outlook.com (2603:10b6:a03:1f4::19) by MW5PR12MB5651.namprd12.prod.outlook.com (2603:10b6:303:19f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.12; Mon, 30 Mar 2026 04:58:06 +0000 Received: from SJ1PEPF000026C6.namprd04.prod.outlook.com (2603:10b6:a03:1f4:cafe::81) by BY5PR20CA0006.outlook.office365.com (2603:10b6:a03:1f4::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.27 via Frontend Transport; Mon, 30 Mar 2026 04:58:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF000026C6.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9745.21 via Frontend Transport; Mon, 30 Mar 2026 04:58:06 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.17; Sun, 29 Mar 2026 23:58:05 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 29 Mar 2026 23:58:05 -0500 Received: from [172.31.184.125] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Sun, 29 Mar 2026 23:57:59 -0500 Message-ID: <4dde81e8-98cc-4666-a4e7-b5083210fbd0@amd.com> Date: Mon, 30 Mar 2026 10:27:58 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] x86/topo: Unify srat_detect_node among amd/intel/hygon To: "Nikola Z. Ivanov" , , , , , , , , , , , , , , , , , , , , CC: , References: <20260329120841.2118684-1-zlatistiv@gmail.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260329120841.2118684-1-zlatistiv@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Received-SPF: None (SATLEXMB04.amd.com: kprateek.nayak@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000026C6:EE_|MW5PR12MB5651:EE_ X-MS-Office365-Filtering-Correlation-Id: a3bf4c17-545d-4365-965b-08de8e18ee59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700016|82310400026|921020|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: kNHp2bCXzMuc9vx2vptX3sbRfVBqxJAQJv3I9QZqi7ZcMzBN2qbQYMi6Vex5lbZ9ZZZH0vXBOG1O4AN6Pkq4oZJfMmcni65pXZYcd3iItb83WAIJ03N+KaldG9OvTxCFcfOXduse7snXFQap4hcBqu/wNaTd8J6QZ9+Y+L/31LJbQU/nUfLxNiYnY1HCUfeYBMEgpY4vRmtKhmObE9JbU6MEBE3Q0YyRuTdzVZSqBP2vpyWTqcbhAy5+SibXVDKezDXteKW7A69WSvtYBPJRMYbN5yK0kubITTc4iaAV/W/lZN06qbkUMIJKOWHyiVkN3EyYvfmFdnTecWeKwzDL9aJs3WlEabuCx74os+lD61Vd2LoCt8uzcv8Hj8emjKyNI9wKNBuSfJLpj8mNk+RWiIMPwFf+vY2BCX59QJIbkmQeGWRKzJEn6VYeH1g9UtGtBphlfy+wQdRPz5fFTfaMbdv5JQGpJ/RQX0AFkoz/UHgOXt+Dz7rAx9aikh0fWQ8QKKfERA301cwCW87VtQKbAEsi5CWszgGp3/H6M8g68E9kLe/r5joCzrd6xy0jEqmIcX4T1cvH9B3xQNwRs2I3SmeQ7+hR9iMB2u1a81HSwP7lrJE/+kjcqCocPkL7Oyf1cyf0lu0H+E0LzWSHm5aRHjp/8H2Dc9UUtAqU4x5hPqqz6/t0wsPfDkCTo7NUQQ425bGb2OGG0xvTBC6iP84p7+QXYYhGBKP+Pu79Q2wpLxfjEnD1WqzBP7tuS/MVHOatNQSus5Xtw1mXzxSuR6eHqWSYPD0JHFb+9+N6OCSA43aKGf52tBVDuK8W1J742XLt X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700016)(82310400026)(921020)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: irvteNfzg0TJS8hN/ADsEN+VbRFXImf5h6qZxZazRoRc+zPb+T0jkF7mT1VMJk6MsEY90785NycEOhwP9ZIR3vJeudTjvbRQJUSgXW7/apSR8OqnaFBKMHDYMb22cnQ816Mf7BquIL48e7tOjHmFT99vjek6hH9RSbPIuxGWBYvxd+CsjIxpFQYj7ajKieFP9Z5nd/84uy9pY3j/ZZTjPdJUAIHOV94eNI0dy3wh84FckDOHRkz0KF879rbx2+TlP2KO/FbGqFeyiZmtBYPI7Cw4DUUY9X3oF4Yx7QBcFhBCuvEVgpj3+jX6s9RfClP7j09mTZJf3RMiKERkp2pqdXI6q2iCPczoabMnGj8kANc/rdFxNPFLtxw0gxj41EGGrWnJ+kUo3EL23VLhwalmE/xx2e2FpXl6j+iE5brPYvGfwrNCWSlqviHeECKFO7Ej X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2026 04:58:06.1305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3bf4c17-545d-4365-965b-08de8e18ee59 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000026C6.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5651 Hello Nikola, On 3/29/2026 5:38 PM, Nikola Z. Ivanov wrote: > This change is provoked by an observed warning after > commit 717b64d58cff ("x86/topo: Replace x86_has_numa_in_package") > when faking numa nodes on intel. > > For example: > > qemu-system-x86_64 \ > -kernel arch/x86/boot/bzImage \ > -append "console=ttyS0 root=/dev/sda debug numa=fake=2" \ > -hda $IMAGES/unstable.img \ > -cpu qemu64,vendor=GenuineIntel \ > -nographic \ > -m 2G \ > -smp 2 \ You can also say: -smp 2,sockets=2 and that fixes the warning but that is not a valid solution? Why? > > Will trigger: > > [ 0.066755][ T0] ------------[ cut here ]------------ > [ 0.066755][ T0] WARNING: arch/x86/kernel/smpboot.c:698 at > set_cpu_sibling_map+0xe41/0x1f90, CPU#1: swapper/1/0 > [ 0.066755][ T0] Call Trace: > [ 0.066755][ T0] > [ 0.066755][ T0] ap_starting+0x9e/0x140 > [ 0.066755][ T0] ? __pfx_ap_starting+0x10/0x10 > [ 0.066755][ T0] ? fpu__init_cpu_xstate+0x5c/0x320 > [ 0.066755][ T0] start_secondary+0x66/0x110 > [ 0.066755][ T0] common_startup_64+0x13e/0x147 > [ 0.066755][ T0] > > smpboot.c suggests that the topology is invalid as > the CPUs are in the same package but different nodes. To me, that looks like a broken topology from a virtualization use case and the user can easily go fix their QEMU cmdlline if they care. I'm pretty sure folks using NUMA emulation in production know what they are doing. > > Fix this by unifying the srat_detect_node function > among amd/intel/hygon and taking the amd/hygon approach > of falling back to LLC when SRAT is not detected. As far as the AMD, Hygon unification goes, I don't mind that but someone has to confirm if nearby_node() holds for all APICID distribution on Intel. > Place the function inside common.c and expose it in topology.h There is no need to make it visible out of arch/x86/kernel/cpu/ Perhaps arch/x86/kernel/cpu/cpu/cpu.h? > > The hygon code is already basically identical to amd > except for the way it obtains the LLC ID. > We can reuse that from the hygon code since we > already have the struct cpuinfo_x86 passed to us. > > Signed-off-by: Nikola Z. Ivanov > --- > This is marked RFC as I lack the context for the reason > why the intel code looks the way it does. I can see > it went through a few changes in the 2008-2010 year range, > which makes be believe that the comment regarding > "not doing AMD heuristics for now" is long overdue. So prior to you patch, If I launch: -smp 4,sockets=2,cores=2 and "numa=fake=2", the srat_detect_node() for an Intel VM maps: CPU#0 -> Node#0 CPU#1 -> Node#1 CPU#2 -> Node#0 CPU#3 -> Node#1 Which resembles Intel baremetal node assignments where the CPUs are interleaved. After your patch, it does: CPU#0 -> Node#0 CPU#1 -> Node#0 CPU#2 -> Node#0 CPU#3 -> Node#0 So despite there being 2 LLCs, the Node assignments all go to Node#0 which may have other unintended consequences. The statement "falling back to LLC when SRAT is not detected." isn't accurate right? We have 2 LLCs and 2 Nodes but topology bits associate both LLCs to the same node. I'm all for unifying the AMD and Hygon's srat_detect_node() but unifying all three for an obviously broken use-case isn't a good motivation. I'll let others comment since they are more familiar with the NUMA emulation bits and maybe all this is acceptable. -- Thanks and Regards, Prateek