mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
cpumask: Use topology_core_cpumask()/topology_thread_cpumask()
Impact: reduce stack usage, use new cpumask API. This actually uses topology_core_cpumask() and topology_thread_cpumask(), removing the only users of topology_core_siblings() and topology_thread_siblings() Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Mike Travis <travis@sgi.com> Cc: linux-net-drivers@solarflare.com
This commit is contained in:
parent
7f7ace0cda
commit
fbd59a8d1f
4 changed files with 27 additions and 22 deletions
|
@ -18,11 +18,11 @@ For an architecture to support this feature, it must define some of
|
||||||
these macros in include/asm-XXX/topology.h:
|
these macros in include/asm-XXX/topology.h:
|
||||||
#define topology_physical_package_id(cpu)
|
#define topology_physical_package_id(cpu)
|
||||||
#define topology_core_id(cpu)
|
#define topology_core_id(cpu)
|
||||||
#define topology_thread_siblings(cpu)
|
#define topology_thread_cpumask(cpu)
|
||||||
#define topology_core_siblings(cpu)
|
#define topology_core_cpumask(cpu)
|
||||||
|
|
||||||
The type of **_id is int.
|
The type of **_id is int.
|
||||||
The type of siblings is cpumask_t.
|
The type of siblings is (const) struct cpumask *.
|
||||||
|
|
||||||
To be consistent on all architectures, include/linux/topology.h
|
To be consistent on all architectures, include/linux/topology.h
|
||||||
provides default definitions for any of the above macros that are
|
provides default definitions for any of the above macros that are
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
#include <linux/hardirq.h>
|
#include <linux/hardirq.h>
|
||||||
#include <linux/topology.h>
|
#include <linux/topology.h>
|
||||||
|
|
||||||
#define define_one_ro(_name) \
|
#define define_one_ro_named(_name, _func) \
|
||||||
|
static SYSDEV_ATTR(_name, 0444, _func, NULL)
|
||||||
|
|
||||||
|
#define define_one_ro(_name) \
|
||||||
static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
|
static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
|
||||||
|
|
||||||
#define define_id_show_func(name) \
|
#define define_id_show_func(name) \
|
||||||
|
@ -42,8 +45,8 @@ static ssize_t show_##name(struct sys_device *dev, \
|
||||||
return sprintf(buf, "%d\n", topology_##name(cpu)); \
|
return sprintf(buf, "%d\n", topology_##name(cpu)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(topology_thread_siblings) || defined(topology_core_siblings)
|
#if defined(topology_thread_cpumask) || defined(topology_core_cpumask)
|
||||||
static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
|
static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf)
|
||||||
{
|
{
|
||||||
ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
|
ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
@ -65,7 +68,7 @@ static ssize_t show_##name(struct sys_device *dev, \
|
||||||
struct sysdev_attribute *attr, char *buf) \
|
struct sysdev_attribute *attr, char *buf) \
|
||||||
{ \
|
{ \
|
||||||
unsigned int cpu = dev->id; \
|
unsigned int cpu = dev->id; \
|
||||||
return show_cpumap(0, &(topology_##name(cpu)), buf); \
|
return show_cpumap(0, topology_##name(cpu), buf); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define define_siblings_show_list(name) \
|
#define define_siblings_show_list(name) \
|
||||||
|
@ -74,7 +77,7 @@ static ssize_t show_##name##_list(struct sys_device *dev, \
|
||||||
char *buf) \
|
char *buf) \
|
||||||
{ \
|
{ \
|
||||||
unsigned int cpu = dev->id; \
|
unsigned int cpu = dev->id; \
|
||||||
return show_cpumap(1, &(topology_##name(cpu)), buf); \
|
return show_cpumap(1, topology_##name(cpu), buf); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -82,9 +85,7 @@ static ssize_t show_##name##_list(struct sys_device *dev, \
|
||||||
static ssize_t show_##name(struct sys_device *dev, \
|
static ssize_t show_##name(struct sys_device *dev, \
|
||||||
struct sysdev_attribute *attr, char *buf) \
|
struct sysdev_attribute *attr, char *buf) \
|
||||||
{ \
|
{ \
|
||||||
unsigned int cpu = dev->id; \
|
return show_cpumap(0, topology_##name(dev->id), buf); \
|
||||||
cpumask_t mask = topology_##name(cpu); \
|
|
||||||
return show_cpumap(0, &mask, buf); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define define_siblings_show_list(name) \
|
#define define_siblings_show_list(name) \
|
||||||
|
@ -92,9 +93,7 @@ static ssize_t show_##name##_list(struct sys_device *dev, \
|
||||||
struct sysdev_attribute *attr, \
|
struct sysdev_attribute *attr, \
|
||||||
char *buf) \
|
char *buf) \
|
||||||
{ \
|
{ \
|
||||||
unsigned int cpu = dev->id; \
|
return show_cpumap(1, topology_##name(dev->id), buf); \
|
||||||
cpumask_t mask = topology_##name(cpu); \
|
|
||||||
return show_cpumap(1, &mask, buf); \
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -107,13 +106,13 @@ define_one_ro(physical_package_id);
|
||||||
define_id_show_func(core_id);
|
define_id_show_func(core_id);
|
||||||
define_one_ro(core_id);
|
define_one_ro(core_id);
|
||||||
|
|
||||||
define_siblings_show_func(thread_siblings);
|
define_siblings_show_func(thread_cpumask);
|
||||||
define_one_ro(thread_siblings);
|
define_one_ro_named(thread_siblings, show_thread_cpumask);
|
||||||
define_one_ro(thread_siblings_list);
|
define_one_ro_named(thread_siblings_list, show_thread_cpumask_list);
|
||||||
|
|
||||||
define_siblings_show_func(core_siblings);
|
define_siblings_show_func(core_cpumask);
|
||||||
define_one_ro(core_siblings);
|
define_one_ro_named(core_siblings, show_core_cpumask);
|
||||||
define_one_ro(core_siblings_list);
|
define_one_ro_named(core_siblings_list, show_core_cpumask_list);
|
||||||
|
|
||||||
static struct attribute *default_attrs[] = {
|
static struct attribute *default_attrs[] = {
|
||||||
&attr_physical_package_id.attr,
|
&attr_physical_package_id.attr,
|
||||||
|
|
|
@ -863,8 +863,8 @@ static int efx_wanted_rx_queues(void)
|
||||||
for_each_online_cpu(cpu) {
|
for_each_online_cpu(cpu) {
|
||||||
if (!cpu_isset(cpu, core_mask)) {
|
if (!cpu_isset(cpu, core_mask)) {
|
||||||
++count;
|
++count;
|
||||||
cpus_or(core_mask, core_mask,
|
cpumask_or(&core_mask, &core_mask,
|
||||||
topology_core_siblings(cpu));
|
topology_core_cpumask(cpu));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,5 +193,11 @@ int arch_update_cpu_topology(void);
|
||||||
#ifndef topology_core_siblings
|
#ifndef topology_core_siblings
|
||||||
#define topology_core_siblings(cpu) cpumask_of_cpu(cpu)
|
#define topology_core_siblings(cpu) cpumask_of_cpu(cpu)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef topology_thread_cpumask
|
||||||
|
#define topology_thread_cpumask(cpu) cpumask_of(cpu)
|
||||||
|
#endif
|
||||||
|
#ifndef topology_core_cpumask
|
||||||
|
#define topology_core_cpumask(cpu) cpumask_of(cpu)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _LINUX_TOPOLOGY_H */
|
#endif /* _LINUX_TOPOLOGY_H */
|
||||||
|
|
Loading…
Reference in a new issue