Release 4.14 arch/ia64/kernel/topology.c
/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* This file contains NUMA specific variables and functions which can
* be split away from DISCONTIGMEM and are used on NUMA machines with
* contiguous memory.
* 2002/08/07 Erich Focht <efocht@ess.nec.de>
* Populate cpu entries in sysfs for non-numa systems as well
* Intel Corporation - Ashok Raj
* 02/27/2006 Zhang, Yanmin
* Populate cpu cache entries in sysfs for cpu cache info
*/
#include <linux/cpu.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/node.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/bootmem.h>
#include <linux/nodemask.h>
#include <linux/notifier.h>
#include <linux/export.h>
#include <asm/mmzone.h>
#include <asm/numa.h>
#include <asm/cpu.h>
static struct ia64_cpu *sysfs_cpus;
void arch_fix_phys_package_id(int num, u32 slot)
{
#ifdef CONFIG_SMP
if (cpu_data(num)->socket_id == -1)
cpu_data(num)->socket_id = slot;
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexander Chiang | 37 | 100.00% | 1 | 100.00% |
Total | 37 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(arch_fix_phys_package_id);
#ifdef CONFIG_HOTPLUG_CPU
int __ref arch_register_cpu(int num)
{
#ifdef CONFIG_ACPI
/*
* If CPEI can be re-targeted or if this is not
* CPEI target, then it is hotpluggable
*/
if (can_cpei_retarget() || !is_cpu_cpei_target(num))
sysfs_cpus[num].cpu.hotpluggable = 1;
map_cpu_to_node(num, node_cpuid[num].nid);
#endif
return register_cpu(&sysfs_cpus[num].cpu, num);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Len Brown | 23 | 36.51% | 2 | 28.57% |
Ashok Raj | 19 | 30.16% | 1 | 14.29% |
Kamezawa Hiroyuki | 14 | 22.22% | 1 | 14.29% |
Suresh B. Siddha | 3 | 4.76% | 1 | 14.29% |
Hidetoshi Seto | 3 | 4.76% | 1 | 14.29% |
Lucas De Marchi | 1 | 1.59% | 1 | 14.29% |
Total | 63 | 100.00% | 7 | 100.00% |
EXPORT_SYMBOL(arch_register_cpu);
void __ref arch_unregister_cpu(int num)
{
unregister_cpu(&sysfs_cpus[num].cpu);
#ifdef CONFIG_ACPI
unmap_cpu_from_node(num, cpu_to_node(num));
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Len Brown | 18 | 51.43% | 1 | 33.33% |
Kamezawa Hiroyuki | 11 | 31.43% | 1 | 33.33% |
Robin Holt | 6 | 17.14% | 1 | 33.33% |
Total | 35 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(arch_unregister_cpu);
#else
static int __init arch_register_cpu(int num)
{
return register_cpu(&sysfs_cpus[num].cpu, num);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hidetoshi Seto | 22 | 91.67% | 1 | 50.00% |
Len Brown | 2 | 8.33% | 1 | 50.00% |
Total | 24 | 100.00% | 2 | 100.00% |
#endif /*CONFIG_HOTPLUG_CPU*/
static int __init topology_init(void)
{
int i, err = 0;
#ifdef CONFIG_NUMA
/*
* MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes?
*/
for_each_online_node(i) {
if ((err = register_one_node(i)))
goto out;
}
#endif
sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
if (!sysfs_cpus)
panic("kzalloc in topology_init failed - NR_CPUS too big?");
for_each_present_cpu(i) {
if((err = arch_register_cpu(i)))
goto out;
}
out:
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Len Brown | 77 | 83.70% | 1 | 20.00% |
Yanmin Zhang | 6 | 6.52% | 1 | 20.00% |
Matthew Dobson | 4 | 4.35% | 1 | 20.00% |
Paul Jackson | 4 | 4.35% | 1 | 20.00% |
Yasunori Goto | 1 | 1.09% | 1 | 20.00% |
Total | 92 | 100.00% | 5 | 100.00% |
subsys_initcall(topology_init);
/*
* Export cpu cache information through sysfs
*/
/*
* A bunch of string array to get pretty printing
*/
static const char *cache_types[] = {
"", /* not used */
"Instruction",
"Data",
"Unified" /* unified */
};
static const char *cache_mattrib[]={
"WriteThrough",
"WriteBack",
"", /* reserved */
"" /* reserved */
};
struct cache_info {
pal_cache_config_info_t cci;
cpumask_t shared_cpu_map;
int level;
int type;
struct kobject kobj;
};
struct cpu_cache_info {
struct cache_info *cache_leaves;
int num_cache_leaves;
struct kobject kobj;
};
static struct cpu_cache_info all_cpu_cache_info[NR_CPUS];
#define LEAF_KOBJECT_PTR(x,y) (&all_cpu_cache_info[x].cache_leaves[y])
#ifdef CONFIG_SMP
static void cache_shared_cpu_map_setup(unsigned int cpu,
struct cache_info * this_leaf)
{
pal_cache_shared_info_t csi;
int num_shared, i = 0;
unsigned int j;
if (cpu_data(cpu)->threads_per_core <= 1 &&
cpu_data(cpu)->cores_per_socket <= 1) {
cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map);
return;
}
if (ia64_pal_cache_shared_info(this_leaf->level,
this_leaf->type,
0,
&csi) != PAL_STATUS_SUCCESS)
return;
num_shared = (int) csi.num_shared;
do {
for_each_possible_cpu(j)
if (cpu_data(cpu)->socket_id == cpu_data(j)->socket_id
&& cpu_data(j)->core_id == csi.log1_cid
&& cpu_data(j)->thread_id == csi.log1_tid)
cpumask_set_cpu(j, &this_leaf->shared_cpu_map);
i++;
} while (i < num_shared &&
ia64_pal_cache_shared_info(this_leaf->level,
this_leaf->type,
i,
&csi) == PAL_STATUS_SUCCESS);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 170 | 97.14% | 1 | 33.33% |
Rusty Russell | 4 | 2.29% | 1 | 33.33% |
Andrew Morton | 1 | 0.57% | 1 | 33.33% |
Total | 175 | 100.00% | 3 | 100.00% |
#else
static void cache_shared_cpu_map_setup(unsigned int cpu,
struct cache_info * this_leaf)
{
cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map);
return;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 24 | 92.31% | 1 | 50.00% |
Rusty Russell | 2 | 7.69% | 1 | 50.00% |
Total | 26 | 100.00% | 2 | 100.00% |
#endif
static ssize_t show_coherency_line_size(struct cache_info *this_leaf,
char *buf)
{
return sprintf(buf, "%u\n", 1 << this_leaf->cci.pcci_line_size);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
static ssize_t show_ways_of_associativity(struct cache_info *this_leaf,
char *buf)
{
return sprintf(buf, "%u\n", this_leaf->cci.pcci_assoc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 29 | 100.00% | 1 | 100.00% |
Total | 29 | 100.00% | 1 | 100.00% |
static ssize_t show_attributes(struct cache_info *this_leaf, char *buf)
{
return sprintf(buf,
"%s\n",
cache_mattrib[this_leaf->cci.pcci_cache_attr]);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 32 | 100.00% | 1 | 100.00% |
Total | 32 | 100.00% | 1 | 100.00% |
static ssize_t show_size(struct cache_info *this_leaf, char *buf)
{
return sprintf(buf, "%uK\n", this_leaf->cci.pcci_cache_size / 1024);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
static ssize_t show_number_of_sets(struct cache_info *this_leaf, char *buf)
{
unsigned number_of_sets = this_leaf->cci.pcci_cache_size;
number_of_sets /= this_leaf->cci.pcci_assoc;
number_of_sets /= 1 << this_leaf->cci.pcci_line_size;
return sprintf(buf, "%u\n", number_of_sets);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 52 | 100.00% | 1 | 100.00% |
Total | 52 | 100.00% | 1 | 100.00% |
static ssize_t show_shared_cpu_map(struct cache_info *this_leaf, char *buf)
{
cpumask_t shared_cpu_map;
cpumask_and(&shared_cpu_map,
&this_leaf->shared_cpu_map, cpu_online_mask);
return scnprintf(buf, PAGE_SIZE, "%*pb\n",
cpumask_pr_args(&shared_cpu_map));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 35 | 74.47% | 1 | 25.00% |
Tejun Heo | 7 | 14.89% | 1 | 25.00% |
Srivatsa S. Bhat | 4 | 8.51% | 1 | 25.00% |
Rusty Russell | 1 | 2.13% | 1 | 25.00% |
Total | 47 | 100.00% | 4 | 100.00% |
static ssize_t show_type(struct cache_info *this_leaf, char *buf)
{
int type = this_leaf->type + this_leaf->cci.pcci_unified;
return sprintf(buf, "%s\n", cache_types[type]);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 41 | 100.00% | 1 | 100.00% |
Total | 41 | 100.00% | 1 | 100.00% |
static ssize_t show_level(struct cache_info *this_leaf, char *buf)
{
return sprintf(buf, "%u\n", this_leaf->level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 27 | 100.00% | 1 | 100.00% |
Total | 27 | 100.00% | 1 | 100.00% |
struct cache_attr {
struct attribute attr;
ssize_t (*show)(struct cache_info *, char *);
ssize_t (*store)(struct cache_info *, const char *, size_t count);
};
#ifdef define_one_ro
#undef define_one_ro
#endif
#define define_one_ro(_name) \
static struct cache_attr _name = \
__ATTR(_name, 0444, show_##_name, NULL)
define_one_ro(level);
define_one_ro(type);
define_one_ro(coherency_line_size);
define_one_ro(ways_of_associativity);
define_one_ro(size);
define_one_ro(number_of_sets);
define_one_ro(shared_cpu_map);
define_one_ro(attributes);
static struct attribute * cache_default_attrs[] = {
&type.attr,
&level.attr,
&coherency_line_size.attr,
&ways_of_associativity.attr,
&attributes.attr,
&size.attr,
&number_of_sets.attr,
&shared_cpu_map.attr,
NULL
};
#define to_object(k) container_of(k, struct cache_info, kobj)
#define to_attr(a) container_of(a, struct cache_attr, attr)
static ssize_t ia64_cache_show(struct kobject * kobj, struct attribute * attr, char * buf)
{
struct cache_attr *fattr = to_attr(attr);
struct cache_info *this_leaf = to_object(kobj);
ssize_t ret;
ret = fattr->show ? fattr->show(this_leaf, buf) : 0;
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 62 | 98.41% | 1 | 50.00% |
Tony Luck | 1 | 1.59% | 1 | 50.00% |
Total | 63 | 100.00% | 2 | 100.00% |
static const struct sysfs_ops cache_sysfs_ops = {
.show = ia64_cache_show
};
static struct kobj_type cache_ktype = {
.sysfs_ops = &cache_sysfs_ops,
.default_attrs = cache_default_attrs,
};
static struct kobj_type cache_ktype_percpu_entry = {
.sysfs_ops = &cache_sysfs_ops,
};
static void cpu_cache_sysfs_exit(unsigned int cpu)
{
kfree(all_cpu_cache_info[cpu].cache_leaves);
all_cpu_cache_info[cpu].cache_leaves = NULL;
all_cpu_cache_info[cpu].num_cache_leaves = 0;
memset(&all_cpu_cache_info[cpu].kobj, 0, sizeof(struct kobject));
return;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 58 | 100.00% | 1 | 100.00% |
Total | 58 | 100.00% | 1 | 100.00% |
static int cpu_cache_sysfs_init(unsigned int cpu)
{
unsigned long i, levels, unique_caches;
pal_cache_config_info_t cci;
int j;
long status;
struct cache_info *this_cache;
int num_cache_leaves = 0;
if ((status = ia64_pal_cache_summary(&levels, &unique_caches)) != 0) {
printk(KERN_ERR "ia64_pal_cache_summary=%ld\n", status);
return -1;
}
this_cache=kzalloc(sizeof(struct cache_info)*unique_caches,
GFP_KERNEL);
if (this_cache == NULL)
return -ENOMEM;
for (i=0; i < levels; i++) {
for (j=2; j >0 ; j--) {
if ((status=ia64_pal_cache_config_info(i,j, &cci)) !=
PAL_STATUS_SUCCESS)
continue;
this_cache[num_cache_leaves].cci = cci;
this_cache[num_cache_leaves].level = i + 1;
this_cache[num_cache_leaves].type = j;
cache_shared_cpu_map_setup(cpu,
&this_cache[num_cache_leaves]);
num_cache_leaves ++;
}
}
all_cpu_cache_info[cpu].cache_leaves = this_cache;
all_cpu_cache_info[cpu].num_cache_leaves = num_cache_leaves;
memset(&all_cpu_cache_info[cpu].kobj, 0, sizeof(struct kobject));
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 222 | 98.67% | 1 | 50.00% |
Matthew Wilcox | 3 | 1.33% | 1 | 50.00% |
Total | 225 | 100.00% | 2 | 100.00% |
/* Add cache interface for CPU device */
static int cache_add_dev(unsigned int cpu)
{
struct device *sys_dev = get_cpu_device(cpu);
unsigned long i, j;
struct cache_info *this_object;
int retval = 0;
if (all_cpu_cache_info[cpu].kobj.parent)
return 0;
retval = cpu_cache_sysfs_init(cpu);
if (unlikely(retval < 0))
return retval;
retval = kobject_init_and_add(&all_cpu_cache_info[cpu].kobj,
&cache_ktype_percpu_entry, &sys_dev->kobj,
"%s", "cache");
if (unlikely(retval < 0)) {
cpu_cache_sysfs_exit(cpu);
return retval;
}
for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++) {
this_object = LEAF_KOBJECT_PTR(cpu,i);
retval = kobject_init_and_add(&(this_object->kobj),
&cache_ktype,
&all_cpu_cache_info[cpu].kobj,
"index%1lu", i);
if (unlikely(retval)) {
for (j = 0; j < i; j++) {
kobject_put(&(LEAF_KOBJECT_PTR(cpu,j)->kobj));
}
kobject_put(&all_cpu_cache_info[cpu].kobj);
cpu_cache_sysfs_exit(cpu);
return retval;
}
kobject_uevent(&(this_object->kobj), KOBJ_ADD);
}
kobject_uevent(&all_cpu_cache_info[cpu].kobj, KOBJ_ADD);
return retval;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 176 | 69.02% | 1 | 16.67% |
Greg Kroah-Hartman | 47 | 18.43% | 2 | 33.33% |
Fenghua Yu | 22 | 8.63% | 1 | 16.67% |
Sebastian Andrzej Siewior | 9 | 3.53% | 1 | 16.67% |
Kay Sievers | 1 | 0.39% | 1 | 16.67% |
Total | 255 | 100.00% | 6 | 100.00% |
/* Remove cache interface for CPU device */
static int cache_remove_dev(unsigned int cpu)
{
unsigned long i;
for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++)
kobject_put(&(LEAF_KOBJECT_PTR(cpu,i)->kobj));
if (all_cpu_cache_info[cpu].kobj.parent) {
kobject_put(&all_cpu_cache_info[cpu].kobj);
memset(&all_cpu_cache_info[cpu].kobj,
0,
sizeof(struct kobject));
}
cpu_cache_sysfs_exit(cpu);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 94 | 95.92% | 1 | 33.33% |
Greg Kroah-Hartman | 2 | 2.04% | 1 | 33.33% |
Sebastian Andrzej Siewior | 2 | 2.04% | 1 | 33.33% |
Total | 98 | 100.00% | 3 | 100.00% |
static int __init cache_sysfs_init(void)
{
int ret;
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/topology:online",
cache_add_dev, cache_remove_dev);
WARN_ON(ret < 0);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 18 | 51.43% | 1 | 33.33% |
Sebastian Andrzej Siewior | 14 | 40.00% | 1 | 33.33% |
Satyam Sharma | 3 | 8.57% | 1 | 33.33% |
Total | 35 | 100.00% | 3 | 100.00% |
device_initcall(cache_sysfs_init);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yanmin Zhang | 1426 | 76.46% | 2 | 6.45% |
Len Brown | 164 | 8.79% | 2 | 6.45% |
Greg Kroah-Hartman | 49 | 2.63% | 2 | 6.45% |
Alexander Chiang | 42 | 2.25% | 1 | 3.23% |
Hidetoshi Seto | 36 | 1.93% | 1 | 3.23% |
Kamezawa Hiroyuki | 25 | 1.34% | 1 | 3.23% |
Sebastian Andrzej Siewior | 25 | 1.34% | 1 | 3.23% |
Fenghua Yu | 22 | 1.18% | 1 | 3.23% |
Ashok Raj | 19 | 1.02% | 1 | 3.23% |
Tejun Heo | 10 | 0.54% | 2 | 6.45% |
Rusty Russell | 7 | 0.38% | 2 | 6.45% |
Robin Holt | 6 | 0.32% | 1 | 3.23% |
Paul Jackson | 4 | 0.21% | 1 | 3.23% |
Srivatsa S. Bhat | 4 | 0.21% | 1 | 3.23% |
Matthew Dobson | 4 | 0.21% | 1 | 3.23% |
Satyam Sharma | 3 | 0.16% | 1 | 3.23% |
Matthew Wilcox | 3 | 0.16% | 1 | 3.23% |
Paul Gortmaker | 3 | 0.16% | 1 | 3.23% |
Chris Wedgwood | 3 | 0.16% | 1 | 3.23% |
Suresh B. Siddha | 3 | 0.16% | 1 | 3.23% |
Tony Luck | 2 | 0.11% | 1 | 3.23% |
Emese Revfy | 1 | 0.05% | 1 | 3.23% |
Yasunori Goto | 1 | 0.05% | 1 | 3.23% |
Kay Sievers | 1 | 0.05% | 1 | 3.23% |
Andrew Morton | 1 | 0.05% | 1 | 3.23% |
Lucas De Marchi | 1 | 0.05% | 1 | 3.23% |
Total | 1865 | 100.00% | 31 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.