From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (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 7DC25152E0F for ; Tue, 23 Jul 2024 13:30:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721741403; cv=none; b=bCq+LBvlFAhhdG0080s1enGJANd3MItCI5ClfYT5EfLf5HbfbJ2pnufG6gZsQA7+XdC6GqMdl2asFz49NvJkQN/gdea+XTfxM3qjKja8VeqR0BfzXhHy4exYauhV5N8wBWqHobAJa2TUoWxSv6Y4R6pDxE25PVFZqgGuk9sYcdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721741403; c=relaxed/simple; bh=nAOfBO2Y2r3svkakgl+lTAOtJTZk9SFbG5lphbRVNRE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p6Alac5pVAaXMbPx9qMZgO3n84Nkxkrl/sFjxsqjRdCxU56ormYEFxWOuQTtX/2Fw9BkmzBqYL+Ids270vItQDAjEoXjdI/ad3OBaxb3L/8pgHDPhpteyMT2KwGTcbswHV4zU+9n71KjDljYvggMDKRKNLcBblqQawjBIJTHCjU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=BJVuHA4R; arc=none smtp.client-ip=209.85.166.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="BJVuHA4R" Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-816ca307407so188107339f.2 for ; Tue, 23 Jul 2024 06:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1721741400; x=1722346200; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hLXpOJ5NKoFQFTZD98u7pTCjufqwrqSU5zSslcWK47s=; b=BJVuHA4Rea9vuyNPKgbyZXzvHsMHv1nb/0KK197rk5M06WSuN9acSl46a18crZDH39 ScKa+Wv1mlr9jYRCOeem3Gqw0OhQ9yq/M2iQFShQOeHbtDBpj79fQKEnabSTZi+vo2bw 8+a1kyEg4BQR3jmv1C+ysN0ehCSBj6Vv8JYxUeCmDXngJDryemII8zxEkCWD7YXYGRWf Rgsna4YpZWru2HqM9a1VOn3eBM/E2rknORTFMDyLBimOa8LEA5ZePy+B+mJQtpnqfU7k SkXEd5vkuo2lJFQTfXhXmYtEK5GMwQ6LHN6xR/qzTsl3SVBHZZiLeRJqlwm2oLbrEqzj pCvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721741400; x=1722346200; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hLXpOJ5NKoFQFTZD98u7pTCjufqwrqSU5zSslcWK47s=; b=wjSqe/7QPzTsMARwoI28tQcvEiFYonx/Ire815DqFgfsAc/uFEM01mRBZKXfiotCfX R47CDP5WuH8XjW13I8P6KaVPa6uAjoTXjMCHnbFFFEGfh7O1FxAVxLY6u7eJ6kVg+OVA 7UFglf/pqpy1xXieNfBByoJQCPSLWQgBaAKnLJhiCBCjob35OOX5sASDMgmBiEw7P+Hz kP05eN84yXFBZa137e+AhkApKPFrBZWfgvxyMRe0qzrJMQ5rtj/YyWKg4UQGn3pMSEGk I7VXAhe2CPWStZ0juXl4Ln3JdDJQbsOqxpVB/akyn/Bbv75etSD48cLKtw6cy+Ul9T5Z Xlvw== X-Forwarded-Encrypted: i=1; AJvYcCXomG0gkXiNWo4Ml6FnpMU5vWNUlceWcVsNqeRqBBm1fhfnaZ9C/xKR8ZHgFeroyVNKFMdpJfHEAMoTLVSsOB4HtsVKxanXYa0Dp3gR X-Gm-Message-State: AOJu0YyYnEV71PtNYG1CIsk6+jxcmPtqgSGJhwI6Sw4jUqGhfDsfbIMj 8LL2RMZH3h/pAOx+BNOhAWP4W6I291M5hWwSkeOcZPkhbAamAWZPoKIOfn5UGjY= X-Google-Smtp-Source: AGHT+IF80eTqdhOJ79Y+uIGpgNKKtwlWUq1s4pL4fYqejLfcrt2vZMzY19zIDC9qjGAE1kLmyRI9aw== X-Received: by 2002:a05:6602:2dd3:b0:804:9060:c0b8 with SMTP id ca18e2360f4ac-81b362aade3mr1199303039f.15.1721741400383; Tue, 23 Jul 2024 06:30:00 -0700 (PDT) Received: from localhost ([138.199.100.237]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-81bed28605esm197619739f.47.2024.07.23.06.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 06:30:00 -0700 (PDT) Date: Tue, 23 Jul 2024 08:29:57 -0500 From: Andrew Jones To: Haibo Xu Cc: sunilvl@ventanamicro.com, arnd@arndb.de, xiaobo55x@gmail.com, Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Conor Dooley , Andrew Morton , Anup Patel , Charlie Jenkins , Baoquan He , Samuel Holland , Sami Tolvanen , Zong Li , =?utf-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , Alexandre Ghiti , Chen Jiahao , "Russell King (Oracle)" , James Morse , Evan Green , Zhao Ke , Thomas Gleixner , Andy Chiu , Marc Zyngier , Tony Luck , Ard Biesheuvel , Alison Schofield , Dan Williams , Jonathan Cameron , Robert Richter , Yuntao Wang , Dave Jiang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v4 1/4] ACPI: RISCV: Add NUMA support based on SRAT and SLIT Message-ID: <20240723-23811cc47f7863d12b6a78e8@orel> References: <65dbad1fda08a32922c44886e4581e49b4a2fecc.1718268003.git.haibo1.xu@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: <65dbad1fda08a32922c44886e4581e49b4a2fecc.1718268003.git.haibo1.xu@intel.com> On Thu, Jun 13, 2024 at 04:54:33PM GMT, Haibo Xu wrote: > Add acpi_numa.c file to enable parse NUMA information from > ACPI SRAT and SLIT tables. SRAT table provide CPUs(Hart) and > memory nodes to proximity domain mapping, while SLIT table > provide the distance metrics between proximity domains. > > Signed-off-by: Haibo Xu > Reviewed-by: Sunil V L > --- > arch/riscv/include/asm/acpi.h | 15 +++- > arch/riscv/kernel/Makefile | 1 + > arch/riscv/kernel/acpi.c | 5 -- > arch/riscv/kernel/acpi_numa.c | 131 ++++++++++++++++++++++++++++++++++ > arch/riscv/kernel/setup.c | 4 +- > arch/riscv/kernel/smpboot.c | 2 - > include/linux/acpi.h | 6 ++ > 7 files changed, 154 insertions(+), 10 deletions(-) > create mode 100644 arch/riscv/kernel/acpi_numa.c > > diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h > index 7dad0cf9d701..e0a1f84404f3 100644 > --- a/arch/riscv/include/asm/acpi.h > +++ b/arch/riscv/include/asm/acpi.h > @@ -61,11 +61,14 @@ static inline void arch_fix_phys_package_id(int num, u32 slot) { } > > void acpi_init_rintc_map(void); > struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu); > -u32 get_acpi_id_for_cpu(int cpu); > +static inline u32 get_acpi_id_for_cpu(int cpu) > +{ > + return acpi_cpu_get_madt_rintc(cpu)->uid; > +} > + > int acpi_get_riscv_isa(struct acpi_table_header *table, > unsigned int cpu, const char **isa); > > -static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } > void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_size, > u32 *cboz_size, u32 *cbop_size); > #else > @@ -87,4 +90,12 @@ static inline void acpi_get_cbo_block_size(struct acpi_table_header *table, > > #endif /* CONFIG_ACPI */ > > +#ifdef CONFIG_ACPI_NUMA > +int acpi_numa_get_nid(unsigned int cpu); > +void acpi_map_cpus_to_nodes(void); > +#else > +static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } > +static inline void acpi_map_cpus_to_nodes(void) { } > +#endif /* CONFIG_ACPI_NUMA */ > + > #endif /*_ASM_ACPI_H*/ > diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile > index 5b243d46f4b1..1e2afec141b5 100644 > --- a/arch/riscv/kernel/Makefile > +++ b/arch/riscv/kernel/Makefile > @@ -110,3 +110,4 @@ obj-$(CONFIG_COMPAT) += compat_vdso/ > > obj-$(CONFIG_64BIT) += pi/ > obj-$(CONFIG_ACPI) += acpi.o > +obj-$(CONFIG_ACPI_NUMA) += acpi_numa.o > diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c > index e619edc8b0cc..040bdbfea2b4 100644 > --- a/arch/riscv/kernel/acpi.c > +++ b/arch/riscv/kernel/acpi.c > @@ -191,11 +191,6 @@ struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) > return &cpu_madt_rintc[cpu]; > } > > -u32 get_acpi_id_for_cpu(int cpu) > -{ > - return acpi_cpu_get_madt_rintc(cpu)->uid; > -} > - > /* > * __acpi_map_table() will be called before paging_init(), so early_ioremap() > * or early_memremap() should be called here to for ACPI table mapping. > diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c > new file mode 100644 > index 000000000000..0231482d6946 > --- /dev/null > +++ b/arch/riscv/kernel/acpi_numa.c > @@ -0,0 +1,131 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * ACPI 6.6 based NUMA setup for RISCV > + * Lots of code was borrowed from arch/arm64/kernel/acpi_numa.c > + * > + * Copyright 2004 Andi Kleen, SuSE Labs. > + * Copyright (C) 2013-2016, Linaro Ltd. > + * Author: Hanjun Guo > + * Copyright (C) 2024 Intel Corporation. > + * > + * Reads the ACPI SRAT table to figure out what memory belongs to which CPUs. > + * > + * Called from acpi_numa_init while reading the SRAT and SLIT tables. > + * Assumes all memory regions belonging to a single proximity domain > + * are in one chunk. Holes between them will be included in the node. > + */ > + > +#define pr_fmt(fmt) "ACPI: NUMA: " fmt > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +static int acpi_early_node_map[NR_CPUS] __initdata = { NUMA_NO_NODE }; This only sets acpi_early_node_map[0] to NUMA_NO_NODE. Assuming we want to ensure all of them are initialized to NUMA_NO_NODE, then we need static int acpi_early_node_map[NR_CPUS] __initdata = { [0 ... NR_CPUS - 1] = NUMA_NO_NODE }; Thanks, drew