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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FCD6C48BC4 for ; Tue, 20 Feb 2024 11:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XwZtFs50jLDuM5IFRqsE3fcT50A/yzVLKAATxHqaGr8=; b=Nj9cMbvX6aXjLj S2hdxrNeNFHMC0SClaFrx1oS01KMVeMZdc0s8a80Tfg5SWMpEP0PBq2RkuUQFk9fXnUOxt+Kh9Pyj 5UQ9EUDQ+xMunAJ0XpO+qOqtTbwzQ9ippxBgrkp6EqOGVtM6R33H/FOTmPgMB/Ib5pFCin2iBjJtB yO4sg34mTznhjOTsRVUCJpjtETF0TgAQhXp1HafAJtQw1vq49HN+0nngeuxSU1/TGYrayaXSawGmF 6LF/G3pQD2QoJW6DBnIEe6OoDG0Ay1s7s5ts2MJAI5TjbTUskS4LpwjKvkGbxuUy3zn+Ypg+o01mm xOZyf7VtOyQAFkMrsn+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcOQk-0000000EU5i-1r9K; Tue, 20 Feb 2024 11:36:58 +0000 Received: from out30-118.freemail.mail.aliyun.com ([115.124.30.118]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcOQZ-0000000EU0r-2hYB for linux-arm-kernel@lists.infradead.org; Tue, 20 Feb 2024 11:36:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1708429002; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=Cz1c5ISGmBdsxneLIlZx/BdFlZMirzknWzhxQibv2VY=; b=UofdqXuI6nkEmwXltS+FKRj1DC75RDwPH5Uvga8bofe49+90Y8SzA801eLvkooEmM//nGt8HhdU2qRqYqbonAOmTm8IfH07FvTq7FETrIYp7tBMm5jnlQjNuX1qAeRy/zdgMnJPj4bASXYD6ZN4Azc6EIT50Zp1h+1hTe5pMHAg= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R701e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=rongwei.wang@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0W0wabbT_1708428963; Received: from localhost.localdomain(mailfrom:rongwei.wang@linux.alibaba.com fp:SMTPD_---0W0wabbT_1708428963) by smtp.aliyun-inc.com; Tue, 20 Feb 2024 19:36:40 +0800 From: Rongwei Wang To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, gregkh@linuxfoundation.org, rafael@kernel.org, pierre.gondois@arm.com, mingo@redhat.com, dave.hansen@linux.intel.com, luto@kernel.org, teng.ma@linux.alibaba.com Subject: [PATCH v1 0/2] support NUMA emulation for genertic arch Date: Tue, 20 Feb 2024 19:36:00 +0800 Message-Id: <20240220113602.6943-1-rongwei.wang@linux.alibaba.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20231012024842.99703-1-rongwei.wang@linux.alibaba.com> References: <20231012024842.99703-1-rongwei.wang@linux.alibaba.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_033648_227059_5982EE7C X-CRM114-Status: GOOD ( 12.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A brief introduction ==================== The NUMA emulation can fake more node base on a single node system, e.g. one node system: [root@localhost ~]# numactl -H available: 1 nodes (0) node 0 cpus: 0 1 2 3 4 5 6 7 node 0 size: 31788 MB node 0 free: 31446 MB node distances: node 0 0: 10 add numa=fake=2 (fake 2 node on each origin node): [root@localhost ~]# numactl -H available: 2 nodes (0-1) node 0 cpus: 0 1 2 3 4 5 6 7 node 0 size: 15806 MB node 0 free: 15451 MB node 1 cpus: 0 1 2 3 4 5 6 7 node 1 size: 16029 MB node 1 free: 15989 MB node distances: node 0 1 0: 10 10 1: 10 10 As above shown, a new node has been faked. As cpus, the realization of x86 NUMA emulation is kept. Maybe each node should has 4 cores is better (not sure, next to do if so). Why do this =========== It seems has following reasons: (1) In x86 host, apply NUMA emulation can fake more nodes environment to test or verify some performance stuff, but arm64 only has one method that modify ACPI table to do this. It's troublesome more or less. (2) Reduce competition for some locks. Here an example we found: will-it-scale/tlb_flush1_processes -t 96 -s 10, it shows obvious hotspot on lruvec->lock when test in single environment. What's more, The performance improved greatly if test in two more nodes system. The data shows below (more is better): --------------------------------------------------------------------- threads/process | 1 | 12 | 24 | 48 | 96 --------------------------------------------------------------------- one node | 14 1122 | 110 5372 | 111 2615 | 79 7084 | 72 4516 --------------------------------------------------------------------- numa=fake=2 | 14 1168 | 144 4848 | 215 9070 | 157 0412 | 142 3968 --------------------------------------------------------------------- | For concurrency 12, no lruvec->lock hotspot. For 24, hotspot | one node has 24% hotspot on lruvec->lock, but | two nodes env hasn't. --------------------------------------------------------------------- As for risks (e.g. numa balance...), they need to be discussed here. Lastly, it seems not a good choice to realize x86 and other genertic archs separately. But it can indeed avoid some architecture related APIs adjustments and alleviate future maintenance. The previous RFC link see [1]. Any advice are welcome, Thanks! Change log ========== RFC v1 -> v1 * add new CONFIG_NUMA_FAKE for genertic archs. * keep x86 implementation, realize numa emulation in driver/base/ for genertic arch, e.g, arm64. [1] RFC v1: https://patchwork.kernel.org/project/linux-arm-kernel/cover/20231012024842.99703-1-rongwei.wang@linux.alibaba.com/ Rongwei Wang (2): arch_numa: remove __init for early_cpu_to_node numa: introduce numa emulation for genertic arch drivers/base/Kconfig | 9 + drivers/base/Makefile | 1 + drivers/base/arch_numa.c | 32 +- drivers/base/numa_emulation.c | 909 ++++++++++++++++++++++++++++++++++ drivers/base/numa_emulation.h | 41 ++ include/asm-generic/numa.h | 2 +- 6 files changed, 992 insertions(+), 2 deletions(-) create mode 100644 drivers/base/numa_emulation.c create mode 100644 drivers/base/numa_emulation.h -- 2.32.0.3.gf3a3e56d6 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel