Skip to content

Commit 9dd333e

Browse files
tobias-huschleVasily Gorbik
authored andcommitted
s390/topology: Add sysctl handler for polarization
Provide an additional path to set the polarization of the system, such that a user no longer relies on the sysfs interface only and is able configure the polarization for every reboot via sysctl control files. The new sysctl can be set as follows: - s390.polarization=0 for horizontal polarization - s390.polarization=1 for vertical polarization Acked-by: Heiko Carstens <[email protected]> Tested-by: Mete Durlu <[email protected]> Signed-off-by: Tobias Huschle <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 307b675 commit 9dd333e

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

arch/s390/kernel/topology.c

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,25 @@ void topology_expect_change(void)
376376

377377
static int cpu_management;
378378

379+
static int set_polarization(int polarization)
380+
{
381+
int rc = 0;
382+
383+
cpus_read_lock();
384+
mutex_lock(&smp_cpu_state_mutex);
385+
if (cpu_management == polarization)
386+
goto out;
387+
rc = topology_set_cpu_management(polarization);
388+
if (rc)
389+
goto out;
390+
cpu_management = polarization;
391+
topology_expect_change();
392+
out:
393+
mutex_unlock(&smp_cpu_state_mutex);
394+
cpus_read_unlock();
395+
return rc;
396+
}
397+
379398
static ssize_t dispatching_show(struct device *dev,
380399
struct device_attribute *attr,
381400
char *buf)
@@ -400,19 +419,7 @@ static ssize_t dispatching_store(struct device *dev,
400419
return -EINVAL;
401420
if (val != 0 && val != 1)
402421
return -EINVAL;
403-
rc = 0;
404-
cpus_read_lock();
405-
mutex_lock(&smp_cpu_state_mutex);
406-
if (cpu_management == val)
407-
goto out;
408-
rc = topology_set_cpu_management(val);
409-
if (rc)
410-
goto out;
411-
cpu_management = val;
412-
topology_expect_change();
413-
out:
414-
mutex_unlock(&smp_cpu_state_mutex);
415-
cpus_read_unlock();
422+
rc = set_polarization(val);
416423
return rc ? rc : count;
417424
}
418425
static DEVICE_ATTR_RW(dispatching);
@@ -624,12 +631,37 @@ static int topology_ctl_handler(const struct ctl_table *ctl, int write,
624631
return rc;
625632
}
626633

634+
static int polarization_ctl_handler(const struct ctl_table *ctl, int write,
635+
void *buffer, size_t *lenp, loff_t *ppos)
636+
{
637+
int polarization;
638+
int rc;
639+
struct ctl_table ctl_entry = {
640+
.procname = ctl->procname,
641+
.data = &polarization,
642+
.maxlen = sizeof(int),
643+
.extra1 = SYSCTL_ZERO,
644+
.extra2 = SYSCTL_ONE,
645+
};
646+
647+
polarization = cpu_management;
648+
rc = proc_douintvec_minmax(&ctl_entry, write, buffer, lenp, ppos);
649+
if (rc < 0 || !write)
650+
return rc;
651+
return set_polarization(polarization);
652+
}
653+
627654
static struct ctl_table topology_ctl_table[] = {
628655
{
629656
.procname = "topology",
630657
.mode = 0644,
631658
.proc_handler = topology_ctl_handler,
632659
},
660+
{
661+
.procname = "polarization",
662+
.mode = 0644,
663+
.proc_handler = polarization_ctl_handler,
664+
},
633665
};
634666

635667
static int __init topology_init(void)

0 commit comments

Comments
 (0)