Skip to content

Commit 441cc6f

Browse files
NickJackolsonVasily Gorbik
authored andcommitted
s390/hiperdispatch: Add hiperdispatch debug attributes
Add two attributes for debug purposes. They can be found under; /sys/devices/system/cpu/hiperdispatch/ * hd_stime_threshold : allows user to adjust steal time threshold * hd_delay_factor : allows user to adjust delay factor of hiperdispatch work (after topology updates, delayed work is always delayed extra by this factor) hd_stime_threshold can have values between 0-100 as it represents a percentage value. hd_delay_factor can have values greater than 1. It is multiplied with the default delay to achieve a longer interval, pushing back the next hiperdispatch adjustment after a topology update. Ex: if delay interval is 250ms and the delay factor is 4; delayed interval is now 1000ms(1sec). After each capacity adjustment or topology change, work has a delayed interval of 1 sec for one interval. Acked-by: Vasily Gorbik <[email protected]> Signed-off-by: Mete Durlu <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent b9271a5 commit 441cc6f

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

arch/s390/kernel/hiperdispatch.c

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
*/
4747

4848
#include <linux/cpumask.h>
49+
#include <linux/device.h>
4950
#include <linux/kernel_stat.h>
51+
#include <linux/kstrtox.h>
5052
#include <linux/ktime.h>
5153
#include <linux/sysctl.h>
5254
#include <linux/workqueue.h>
@@ -71,6 +73,8 @@ static int hd_online_cores; /* Current online CORE count */
7173

7274
static unsigned long hd_previous_steal; /* Previous iteration's CPU steal timer total */
7375

76+
static unsigned int hd_steal_threshold = HD_STEAL_THRESHOLD;
77+
static unsigned int hd_delay_factor = HD_DELAY_FACTOR;
7478
static int hd_enabled;
7579

7680
static void hd_capacity_work_fn(struct work_struct *work);
@@ -151,7 +155,7 @@ int hd_enable_hiperdispatch(void)
151155
return 0;
152156
if (hd_online_cores <= hd_entitled_cores)
153157
return 0;
154-
mod_delayed_work(system_wq, &hd_capacity_work, HD_DELAY_INTERVAL * HD_DELAY_FACTOR);
158+
mod_delayed_work(system_wq, &hd_capacity_work, HD_DELAY_INTERVAL * hd_delay_factor);
155159
hd_update_capacities();
156160
return 1;
157161
}
@@ -214,7 +218,7 @@ static void hd_capacity_work_fn(struct work_struct *work)
214218
return;
215219
}
216220
steal_percentage = hd_steal_avg(hd_calculate_steal_percentage());
217-
if (steal_percentage < HD_STEAL_THRESHOLD)
221+
if (steal_percentage < hd_steal_threshold)
218222
new_cores = hd_online_cores;
219223
else
220224
new_cores = hd_entitled_cores;
@@ -260,6 +264,81 @@ static struct ctl_table hiperdispatch_ctl_table[] = {
260264
},
261265
};
262266

267+
static ssize_t hd_steal_threshold_show(struct device *dev,
268+
struct device_attribute *attr,
269+
char *buf)
270+
{
271+
return sysfs_emit(buf, "%u\n", hd_steal_threshold);
272+
}
273+
274+
static ssize_t hd_steal_threshold_store(struct device *dev,
275+
struct device_attribute *attr,
276+
const char *buf,
277+
size_t count)
278+
{
279+
unsigned int val;
280+
int rc;
281+
282+
rc = kstrtouint(buf, 0, &val);
283+
if (rc)
284+
return rc;
285+
if (val > 100)
286+
return -ERANGE;
287+
hd_steal_threshold = val;
288+
return count;
289+
}
290+
291+
static DEVICE_ATTR_RW(hd_steal_threshold);
292+
293+
static ssize_t hd_delay_factor_show(struct device *dev,
294+
struct device_attribute *attr,
295+
char *buf)
296+
{
297+
return sysfs_emit(buf, "%u\n", hd_delay_factor);
298+
}
299+
300+
static ssize_t hd_delay_factor_store(struct device *dev,
301+
struct device_attribute *attr,
302+
const char *buf,
303+
size_t count)
304+
{
305+
unsigned int val;
306+
int rc;
307+
308+
rc = kstrtouint(buf, 0, &val);
309+
if (rc)
310+
return rc;
311+
if (!val)
312+
return -ERANGE;
313+
hd_delay_factor = val;
314+
return count;
315+
}
316+
317+
static DEVICE_ATTR_RW(hd_delay_factor);
318+
319+
static struct attribute *hd_attrs[] = {
320+
&dev_attr_hd_steal_threshold.attr,
321+
&dev_attr_hd_delay_factor.attr,
322+
NULL,
323+
};
324+
325+
static const struct attribute_group hd_attr_group = {
326+
.name = "hiperdispatch",
327+
.attrs = hd_attrs,
328+
};
329+
330+
static void __init hd_create_attributes(void)
331+
{
332+
struct device *dev;
333+
334+
dev = bus_get_dev_root(&cpu_subsys);
335+
if (!dev)
336+
return;
337+
if (sysfs_create_group(&dev->kobj, &hd_attr_group))
338+
pr_warn("Unable to create hiperdispatch attribute group\n");
339+
put_device(dev);
340+
}
341+
263342
static int __init hd_init(void)
264343
{
265344
if (IS_ENABLED(CONFIG_HIPERDISPATCH_ON)) {
@@ -268,6 +347,7 @@ static int __init hd_init(void)
268347
}
269348
if (!register_sysctl("s390", hiperdispatch_ctl_table))
270349
pr_warn("Failed to register s390.hiperdispatch sysctl attribute\n");
350+
hd_create_attributes();
271351
return 0;
272352
}
273353
late_initcall(hd_init);

0 commit comments

Comments
 (0)