@@ -21,25 +21,27 @@ static ssize_t name##_show(struct device *dev, \
21
21
return sysfs_emit(buf, "%d\n", topology_##name(dev->id)); \
22
22
}
23
23
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); \
29
43
}
30
44
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
-
43
45
define_id_show_func (physical_package_id );
44
46
static DEVICE_ATTR_RO (physical_package_id );
45
47
@@ -49,71 +51,80 @@ static DEVICE_ATTR_RO(die_id);
49
51
define_id_show_func (core_id );
50
52
static DEVICE_ATTR_RO (core_id );
51
53
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 );
55
57
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 );
59
61
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 );
63
65
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 );
67
69
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 ) ;
71
73
72
74
#ifdef CONFIG_SCHED_BOOK
73
75
define_id_show_func (book_id );
74
76
static 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 ) ;
78
80
#endif
79
81
80
82
#ifdef CONFIG_SCHED_DRAWER
81
83
define_id_show_func (drawer_id );
82
84
static 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 ) ;
86
88
#endif
87
89
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
+
88
112
static struct attribute * default_attrs [] = {
89
113
& dev_attr_physical_package_id .attr ,
90
114
& dev_attr_die_id .attr ,
91
115
& 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 ,
102
116
#ifdef CONFIG_SCHED_BOOK
103
117
& dev_attr_book_id .attr ,
104
- & dev_attr_book_siblings .attr ,
105
- & dev_attr_book_siblings_list .attr ,
106
118
#endif
107
119
#ifdef CONFIG_SCHED_DRAWER
108
120
& dev_attr_drawer_id .attr ,
109
- & dev_attr_drawer_siblings .attr ,
110
- & dev_attr_drawer_siblings_list .attr ,
111
121
#endif
112
122
NULL
113
123
};
114
124
115
125
static const struct attribute_group topology_attr_group = {
116
126
.attrs = default_attrs ,
127
+ .bin_attrs = bin_attrs ,
117
128
.name = "topology"
118
129
};
119
130
0 commit comments