From 0008204ffe85d23382d6fd0f971f3f0fbe70bae2 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Fri, 13 Jul 2012 15:45:33 +0200 Subject: s390/idle: fix sequence handling vs cpu hotplug The s390 idle accounting code uses a sequence counter which gets used when the per cpu idle statistics get updated and read. One assumption on read access is that only when the sequence counter is even and did not change while reading all values the result is valid. On cpu hotplug however the per cpu data structure gets initialized via a cpu hotplug notifier on CPU_ONLINE. CPU_ONLINE however is too late, since the onlined cpu is already running and might access the per cpu data. Worst case is that the data structure gets initialized while an idle thread is updating its idle statistics. This will result in an uneven sequence counter after an update. As a result user space tools like top, which access /proc/stat in order to get idle stats, will busy loop waiting for the sequence counter to become even again, which will never happen until the queried cpu will update its idle statistics again. And even then the sequence counter will only have an even value for a couple of cpu cycles. Fix this by moving the initialization of the per cpu idle statistics to cpu_init(). I prefer that solution in favor of changing the notifier to CPU_UP_PREPARE, which would be a different solution to the problem. Cc: stable@vger.kernel.org Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/processor.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/s390/kernel/processor.c') diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c index 6e0073e43f54..07c7bf47d618 100644 --- a/arch/s390/kernel/processor.c +++ b/arch/s390/kernel/processor.c @@ -26,12 +26,14 @@ static DEFINE_PER_CPU(struct cpuid, cpu_id); void __cpuinit cpu_init(void) { struct cpuid *id = &per_cpu(cpu_id, smp_processor_id()); + struct s390_idle_data *idle = &__get_cpu_var(s390_idle); get_cpu_id(id); atomic_inc(&init_mm.mm_count); current->active_mm = &init_mm; BUG_ON(current->mm); enter_lazy_tlb(&init_mm, current); + memset(idle, 0, sizeof(*idle)); } /* -- cgit v1.2.3 From 50bb1f761e420776a4d10798babfc76793d4056c Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Fri, 13 Jul 2012 16:12:04 +0200 Subject: s390/cpu init: use __get_cpu_var instead of per_cpu Just saves a couple of instructions. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/s390/kernel/processor.c') diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c index 07c7bf47d618..0e2887b6d09e 100644 --- a/arch/s390/kernel/processor.c +++ b/arch/s390/kernel/processor.c @@ -25,8 +25,8 @@ static DEFINE_PER_CPU(struct cpuid, cpu_id); */ void __cpuinit cpu_init(void) { - struct cpuid *id = &per_cpu(cpu_id, smp_processor_id()); struct s390_idle_data *idle = &__get_cpu_var(s390_idle); + struct cpuid *id = &__get_cpu_var(cpu_id); get_cpu_id(id); atomic_inc(&init_mm.mm_count); -- cgit v1.2.3 From a53c8fab3f87c995c30ac226a03af95361243144 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Fri, 20 Jul 2012 11:15:04 +0200 Subject: s390/comments: unify copyright messages and remove file names Remove the file name from the comment at top of many files. In most cases the file name was wrong anyway, so it's rather pointless. Also unify the IBM copyright statement. We did have a lot of sightly different statements and wanted to change them one after another whenever a file gets touched. However that never happened. Instead people start to take the old/"wrong" statements to use as a template for new files. So unify all of them in one go. Signed-off-by: Heiko Carstens --- arch/s390/kernel/processor.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'arch/s390/kernel/processor.c') diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c index 0e2887b6d09e..572d4c9cb33b 100644 --- a/arch/s390/kernel/processor.c +++ b/arch/s390/kernel/processor.c @@ -1,6 +1,4 @@ /* - * arch/s390/kernel/processor.c - * * Copyright IBM Corp. 2008 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) */ -- cgit v1.2.3