public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: WangYuli <wangyuli@uniontech.com>
Cc: chenhuacai@kernel.org, kernel@xen0n.name, rafael@kernel.org,
	lenb@kernel.org, maobibo@loongson.cn, guanwentao@uniontech.com,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	Jonathan.Cameron@huawei.com, dan.j.williams@intel.com,
	alison.schofield@intel.com, rrichter@amd.com,
	bfaccini@nvidia.com, dave.jiang@intel.com, haibo1.xu@intel.com,
	linux-acpi@vger.kernel.org, zhanjun@uniontech.com,
	niecheng1@uniontech.com, chenlinxuan@uniontech.com
Subject: Re: [PATCH] ACPI: NUMA: Move get_numa_distances_cnt() helper to needed location
Date: Thu, 20 Feb 2025 08:10:05 +0200	[thread overview]
Message-ID: <Z7bHPVUH4lAezk0E@kernel.org> (raw)
In-Reply-To: <D87315C93AF20D4E+20250220042037.942802-1-wangyuli@uniontech.com>

Hi,

On Thu, Feb 20, 2025 at 12:20:37PM +0800, WangYuli wrote:
> In LoongArch, get_numa_distances_cnt() was not in use, resulting in
> a compiler warning.
> 
> Serendipitously, drivers/acpi/numa/srat.c appears to be a more
> relevant location for this helper function, hence its relocation.

There's no need for relocation, just drop the unused function.
 
> This commit not only resolves these immediate concerns but also sets
> the groundwork for potential future integration of ACPI related logic
> from other architectures into this driver module.
> 
> Separately, the locality_count member in struct acpi_table_slit is
> typed as u64. Adapt the function type to eliminate potential code
> risks.
> 
> Fix follow errors with clang-18 when W=1e:
> 
> arch/loongarch/kernel/acpi.c:259:28: error: unused function 'get_numa_distances_cnt' [-Werror,-Wunused-function]
>   259 | static inline unsigned int get_numa_distances_cnt(struct acpi_table_slit *slit)
>       |                            ^~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
> 
> Signed-off-by: WangYuli <wangyuli@uniontech.com>
> ---
>  arch/loongarch/kernel/acpi.c |  5 -----
>  drivers/acpi/numa/srat.c     | 13 +++++++++----
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
> index ee471a80763e..90cc9250f121 100644
> --- a/arch/loongarch/kernel/acpi.c
> +++ b/arch/loongarch/kernel/acpi.c
> @@ -256,11 +256,6 @@ static __init int setup_node(int pxm)
>   */
>  unsigned int numa_distance_cnt;
>  
> -static inline unsigned int get_numa_distances_cnt(struct acpi_table_slit *slit)
> -{
> -	return slit->locality_count;
> -}
> -
>  void __init numa_set_distance(int from, int to, int distance)
>  {
>  	if ((u8)distance != distance || (from == to && distance != LOCAL_DISTANCE)) {
> diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
> index 00ac0d7bb8c9..36053ae3dad6 100644
> --- a/drivers/acpi/numa/srat.c
> +++ b/drivers/acpi/numa/srat.c
> @@ -283,6 +283,11 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
>  	}
>  }
>  
> +static inline u64 get_numa_distances_cnt(struct acpi_table_slit *slit)
> +{
> +	return slit->locality_count;
> +}
> +
>  /*
>   * A lot of BIOS fill in 10 (= no distance) everywhere. This messes
>   * up the NUMA heuristics which wants the local node to have a smaller
> @@ -292,7 +297,7 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
>  static int __init slit_valid(struct acpi_table_slit *slit)
>  {
>  	int i, j;
> -	int d = slit->locality_count;
> +	u64 d = get_numa_distances_cnt(slit);
>  	for (i = 0; i < d; i++) {
>  		for (j = 0; j < d; j++) {
>  			u8 val = slit->entry[d*i + j];
> @@ -337,20 +342,20 @@ static int __init acpi_parse_slit(struct acpi_table_header *table)
>  		return -EINVAL;
>  	}
>  
> -	for (i = 0; i < slit->locality_count; i++) {
> +	for (i = 0; i < get_numa_distances_cnt(slit); i++) {
>  		const int from_node = pxm_to_node(i);
>  
>  		if (from_node == NUMA_NO_NODE)
>  			continue;
>  
> -		for (j = 0; j < slit->locality_count; j++) {
> +		for (j = 0; j < get_numa_distances_cnt(slit); j++) {
>  			const int to_node = pxm_to_node(j);
>  
>  			if (to_node == NUMA_NO_NODE)
>  				continue;
>  
>  			numa_set_distance(from_node, to_node,
> -				slit->entry[slit->locality_count * i + j]);
> +				slit->entry[get_numa_distances_cnt(slit) * i + j]);
>  		}
>  	}
>  
> -- 
> 2.47.2
> 

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2025-02-20  6:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20  4:20 [PATCH] ACPI: NUMA: Move get_numa_distances_cnt() helper to needed location WangYuli
2025-02-20  6:10 ` Mike Rapoport [this message]
2025-02-20  6:25   ` WangYuli
2025-02-21 12:45     ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z7bHPVUH4lAezk0E@kernel.org \
    --to=rppt@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=bfaccini@nvidia.com \
    --cc=chenhuacai@kernel.org \
    --cc=chenlinxuan@uniontech.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=guanwentao@uniontech.com \
    --cc=haibo1.xu@intel.com \
    --cc=kernel@xen0n.name \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=maobibo@loongson.cn \
    --cc=niecheng1@uniontech.com \
    --cc=rafael@kernel.org \
    --cc=rrichter@amd.com \
    --cc=wangyuli@uniontech.com \
    --cc=zhanjun@uniontech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox