public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: jbarnes@virtuousgeek.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH]  pci: derive nearby CPUs from device's instead of bus' NUMA information
Date: Fri, 17 Apr 2009 18:21:15 +0200	[thread overview]
Message-ID: <20090417162115.GF8253@elte.hu> (raw)
In-Reply-To: <20090417100155.GE16198@alberich.amd.com>


* Andreas Herrmann <andreas.herrmann3@amd.com> wrote:

> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index a7eb1b4..9360f3d 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -74,7 +74,11 @@ static ssize_t local_cpus_show(struct device *dev,
>  	const struct cpumask *mask;
>  	int len;
>  
> +#ifdef CONFIG_NUMA
> +	mask = cpumask_of_node(dev_to_node(dev));
> +#else
>  	mask = cpumask_of_pcibus(to_pci_dev(dev)->bus);
> +#endif
>  	len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
>  	buf[len++] = '\n';
>  	buf[len] = '\0';
> @@ -88,7 +92,11 @@ static ssize_t local_cpulist_show(struct device *dev,
>  	const struct cpumask *mask;
>  	int len;
>  
> +#ifdef CONFIG_NUMA
> +	mask = cpumask_of_node(dev_to_node(dev));
> +#else
>  	mask = cpumask_of_pcibus(to_pci_dev(dev)->bus);
> +#endif

No objections against the change (at all), but this pattern cries 
out for a different, cleaner solution.

Shouldnt there be a cpumask_of_pcidev(dev) helper instead, which 
[recognizing that most PCI devices dont get their node info 
initialized in practice] would do something like:

const struct cpumask * cpumask_of_pcidev(struct pci_dev *dev)
{
	if (dev->numa_node == -1)
		return cpumask_of_pcibus(to_pci_dev(dev)->bus);

	return cpumask_of_node(dev_to_node(dev));
}

? This would work fine in all cases.

Which you could thus use in both cases above, cleanly.

	Ingo

  reply	other threads:[~2009-04-17 16:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-17 10:01 [PATCH] pci: derive nearby CPUs from device's instead of bus' NUMA information Andreas Herrmann
2009-04-17 16:21 ` Ingo Molnar [this message]
2009-04-17 19:26   ` Yinghai Lu
2009-04-20  8:47     ` Andreas Herrmann
2009-04-20 20:03       ` Jesse Barnes
2009-05-07  8:51         ` Andreas Herrmann
2009-05-11 21:54           ` Jesse Barnes
2009-06-09  5:47             ` Andreas Herrmann
2009-04-20 21:23       ` Yinghai Lu
2009-04-21 18:05         ` Andreas Herrmann

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=20090417162115.GF8253@elte.hu \
    --to=mingo@elte.hu \
    --cc=andreas.herrmann3@amd.com \
    --cc=hpa@zytor.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    /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