@@ -21,25 +21,27 @@ static ssize_t name##_show(struct device *dev, \
2121 return sysfs_emit(buf, "%d\n", topology_##name(dev->id)); \
2222}
2323
24- #define define_siblings_show_map (name , mask ) \
25- static ssize_t name##_show(struct device *dev, \
26- struct device_attribute *attr, char *buf) \
27- { \
28- return cpumap_print_to_pagebuf(false, buf, topology_##mask(dev->id));\
24+ #define define_siblings_read_func (name , mask ) \
25+ static ssize_t name##_read(struct file *file, struct kobject *kobj, \
26+ struct bin_attribute *attr, char *buf, \
27+ loff_t off, size_t count) \
28+ { \
29+ struct device *dev = kobj_to_dev(kobj); \
30+ \
31+ return cpumap_print_bitmask_to_buf(buf, topology_##mask(dev->id), \
32+ off, count); \
33+ } \
34+ \
35+ static ssize_t name##_list_read(struct file *file, struct kobject *kobj, \
36+ struct bin_attribute *attr, char *buf, \
37+ loff_t off, size_t count) \
38+ { \
39+ struct device *dev = kobj_to_dev(kobj); \
40+ \
41+ return cpumap_print_list_to_buf(buf, topology_##mask(dev->id), \
42+ off, count); \
2943}
3044
31- #define define_siblings_show_list (name , mask ) \
32- static ssize_t name##_list_show(struct device *dev, \
33- struct device_attribute *attr, \
34- char *buf) \
35- { \
36- return cpumap_print_to_pagebuf(true, buf, topology_##mask(dev->id));\
37- }
38-
39- #define define_siblings_show_func (name , mask ) \
40- define_siblings_show_map(name, mask); \
41- define_siblings_show_list(name, mask)
42-
4345define_id_show_func (physical_package_id );
4446static DEVICE_ATTR_RO (physical_package_id );
4547
@@ -49,71 +51,80 @@ static DEVICE_ATTR_RO(die_id);
4951define_id_show_func (core_id );
5052static DEVICE_ATTR_RO (core_id );
5153
52- define_siblings_show_func (thread_siblings , sibling_cpumask );
53- static DEVICE_ATTR_RO (thread_siblings );
54- static DEVICE_ATTR_RO (thread_siblings_list );
54+ define_siblings_read_func (thread_siblings , sibling_cpumask );
55+ static BIN_ATTR_RO (thread_siblings , 0 ) ;
56+ static BIN_ATTR_RO (thread_siblings_list , 0 );
5557
56- define_siblings_show_func (core_cpus , sibling_cpumask );
57- static DEVICE_ATTR_RO (core_cpus );
58- static DEVICE_ATTR_RO (core_cpus_list );
58+ define_siblings_read_func (core_cpus , sibling_cpumask );
59+ static BIN_ATTR_RO (core_cpus , 0 ) ;
60+ static BIN_ATTR_RO (core_cpus_list , 0 );
5961
60- define_siblings_show_func (core_siblings , core_cpumask );
61- static DEVICE_ATTR_RO (core_siblings );
62- static DEVICE_ATTR_RO (core_siblings_list );
62+ define_siblings_read_func (core_siblings , core_cpumask );
63+ static BIN_ATTR_RO (core_siblings , 0 ) ;
64+ static BIN_ATTR_RO (core_siblings_list , 0 );
6365
64- define_siblings_show_func (die_cpus , die_cpumask );
65- static DEVICE_ATTR_RO (die_cpus );
66- static DEVICE_ATTR_RO (die_cpus_list );
66+ define_siblings_read_func (die_cpus , die_cpumask );
67+ static BIN_ATTR_RO (die_cpus , 0 ) ;
68+ static BIN_ATTR_RO (die_cpus_list , 0 );
6769
68- define_siblings_show_func (package_cpus , core_cpumask );
69- static DEVICE_ATTR_RO (package_cpus );
70- static DEVICE_ATTR_RO (package_cpus_list );
70+ define_siblings_read_func (package_cpus , core_cpumask );
71+ static BIN_ATTR_RO (package_cpus , 0 ) ;
72+ static BIN_ATTR_RO (package_cpus_list , 0 ) ;
7173
7274#ifdef CONFIG_SCHED_BOOK
7375define_id_show_func (book_id );
7476static DEVICE_ATTR_RO (book_id );
75- define_siblings_show_func (book_siblings , book_cpumask );
76- static DEVICE_ATTR_RO (book_siblings );
77- static DEVICE_ATTR_RO (book_siblings_list );
77+ define_siblings_read_func (book_siblings , book_cpumask );
78+ static BIN_ATTR_RO (book_siblings , 0 ) ;
79+ static BIN_ATTR_RO (book_siblings_list , 0 ) ;
7880#endif
7981
8082#ifdef CONFIG_SCHED_DRAWER
8183define_id_show_func (drawer_id );
8284static DEVICE_ATTR_RO (drawer_id );
83- define_siblings_show_func (drawer_siblings , drawer_cpumask );
84- static DEVICE_ATTR_RO (drawer_siblings );
85- static DEVICE_ATTR_RO (drawer_siblings_list );
85+ define_siblings_read_func (drawer_siblings , drawer_cpumask );
86+ static BIN_ATTR_RO (drawer_siblings , 0 ) ;
87+ static BIN_ATTR_RO (drawer_siblings_list , 0 ) ;
8688#endif
8789
90+ static struct bin_attribute * bin_attrs [] = {
91+ & bin_attr_core_cpus ,
92+ & bin_attr_core_cpus_list ,
93+ & bin_attr_thread_siblings ,
94+ & bin_attr_thread_siblings_list ,
95+ & bin_attr_core_siblings ,
96+ & bin_attr_core_siblings_list ,
97+ & bin_attr_die_cpus ,
98+ & bin_attr_die_cpus_list ,
99+ & bin_attr_package_cpus ,
100+ & bin_attr_package_cpus_list ,
101+ #ifdef CONFIG_SCHED_BOOK
102+ & bin_attr_book_siblings ,
103+ & bin_attr_book_siblings_list ,
104+ #endif
105+ #ifdef CONFIG_SCHED_DRAWER
106+ & bin_attr_drawer_siblings ,
107+ & bin_attr_drawer_siblings_list ,
108+ #endif
109+ NULL
110+ };
111+
88112static struct attribute * default_attrs [] = {
89113 & dev_attr_physical_package_id .attr ,
90114 & dev_attr_die_id .attr ,
91115 & dev_attr_core_id .attr ,
92- & dev_attr_thread_siblings .attr ,
93- & dev_attr_thread_siblings_list .attr ,
94- & dev_attr_core_cpus .attr ,
95- & dev_attr_core_cpus_list .attr ,
96- & dev_attr_core_siblings .attr ,
97- & dev_attr_core_siblings_list .attr ,
98- & dev_attr_die_cpus .attr ,
99- & dev_attr_die_cpus_list .attr ,
100- & dev_attr_package_cpus .attr ,
101- & dev_attr_package_cpus_list .attr ,
102116#ifdef CONFIG_SCHED_BOOK
103117 & dev_attr_book_id .attr ,
104- & dev_attr_book_siblings .attr ,
105- & dev_attr_book_siblings_list .attr ,
106118#endif
107119#ifdef CONFIG_SCHED_DRAWER
108120 & dev_attr_drawer_id .attr ,
109- & dev_attr_drawer_siblings .attr ,
110- & dev_attr_drawer_siblings_list .attr ,
111121#endif
112122 NULL
113123};
114124
115125static const struct attribute_group topology_attr_group = {
116126 .attrs = default_attrs ,
127+ .bin_attrs = bin_attrs ,
117128 .name = "topology"
118129};
119130
0 commit comments