/* * sysctl - sysctl set/get helpers * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include "built_in.h" #include "sysctl.h" int sysctl_set_int(const char *file, int value) { char path[PATH_MAX]; char str[64]; ssize_t ret; int fd; strncpy(path, SYSCTL_PROC_PATH, PATH_MAX); strncat(path, file, PATH_MAX - sizeof(SYSCTL_PROC_PATH) - 1); fd = open(path, O_WRONLY); if (unlikely(fd < 0)) return -1; ret = snprintf(str, 63, "%d", value); if (ret < 0) { close(fd); return -1; } ret = write(fd, str, strlen(str)); close(fd); return ret <= 0 ? -1 : 0; } int sysctl_get_int(const char *file, int *value) { char path[PATH_MAX]; char str[64]; ssize_t ret; int fd; strncpy(path, SYSCTL_PROC_PATH, PATH_MAX); strncat(path, file, PATH_MAX - sizeof(SYSCTL_PROC_PATH) - 1); fd = open(path, O_RDONLY); if (fd < 0) return -1; ret = read(fd, str, sizeof(str)); if (ret > 0) { *value = atoi(str); ret = 0; } else { ret = -1; } close(fd); return ret; } te-cleanup net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-04-08 14:40:15 +0200
committerThomas Gleixner <tglx@linutronix.de>2016-04-22 09:49:49 +0200
commit3b9d6da67e11ca8f78fde887918983523a36b0fa (patch)
tree00f22715eb1c6b773ac5166e61a545874a0d39f0 /Documentation
parentc3b46c73264b03000d1e18b22f5caf63332547c9 (diff)
cpu/hotplug: Fix rollback during error-out in __cpu_disable()
The recent introduction of the hotplug thread which invokes the callbacks on the plugged cpu, cased the following regression: If takedown_cpu() fails, then we run into several issues: 1) The rollback of the target cpu states is not invoked. That leaves the smp threads and the hotplug thread in disabled state. 2) notify_online() is executed due to a missing skip_onerr flag. That causes that both CPU_DOWN_FAILED and CPU_ONLINE notifications are invoked which confuses quite some notifiers. 3) The CPU_DOWN_FAILED notification is not invoked on the target CPU. That's not an issue per se, but it is inconsistent and in consequence blocks the patches which rely on these states being invoked on the target CPU and not on the controlling cpu. It also does not preserve the strict call order on rollback which is problematic for the ongoing state machine conversion as well. To fix this we add a rollback flag to the remote callback machinery and invoke the rollback including the CPU_DOWN_FAILED notification on the remote cpu. Further mark the notify online state with 'skip_onerr' so we don't get a double invokation. This workaround will go away once we moved the unplug invocation to the target cpu itself. [ tglx: Massaged changelog and moved the CPU_DOWN_FAILED notifiaction to the target cpu ] Fixes: 4cb28ced23c4 ("cpu/hotplug: Create hotplug threads") Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: linux-s390@vger.kernel.org Cc: rt@linutronix.de Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Anna-Maria Gleixner <anna-maria@linutronix.de> Link: http://lkml.kernel.org/r/20160408124015.GA21960@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'Documentation')