From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754480AbaHFOMq (ORCPT ); Wed, 6 Aug 2014 10:12:46 -0400 Received: from qmta15.emeryville.ca.mail.comcast.net ([76.96.27.228]:50647 "EHLO qmta15.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753931AbaHFOMp (ORCPT ); Wed, 6 Aug 2014 10:12:45 -0400 Date: Wed, 6 Aug 2014 09:12:39 -0500 (CDT) From: Christoph Lameter To: Sasha Levin cc: akpm@linux-foundation.org, Gilad Ben-Yossef , Thomas Gleixner , Tejun Heo , John Stultz , Mike Frysinger , Minchan Kim , Hakan Akkan , Max Krasnyansky , Frederic Weisbecker , "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, hughd@google.com, viresh.kumar@linaro.org, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org Subject: Re: vmstat: On demand vmstat workers V8 In-Reply-To: <53E159F6.7080603@oracle.com> Message-ID: References: <53D31101.8000107@oracle.com> <53DFFD28.2030502@oracle.com> <53E159F6.7080603@oracle.com> Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 5 Aug 2014, Sasha Levin wrote: > I can easily trigger it by cranking up the cpu hotplug code. Just try to > frequently offline and online cpus, it should reproduce quickly. Thats what I thought. The test was done with this fix applied right? Subject: vmstat ondemand: Fix online/offline races Do not allow onlining/offlining while the shepherd task is checking for vmstat threads. On offlining a processor do the right thing cancelling the vmstat worker thread if it exista and also exclude it from the shepherd process checks. Signed-off-by: Christoph Lameter Index: linux/mm/vmstat.c =================================================================== --- linux.orig/mm/vmstat.c 2014-07-30 09:35:54.602662306 -0500 +++ linux/mm/vmstat.c 2014-07-30 09:43:07.109037043 -0500 @@ -1317,6 +1317,7 @@ static void vmstat_shepherd(struct work_ { int cpu; + get_online_cpus(); /* Check processors whose vmstat worker threads have been disabled */ for_each_cpu(cpu, cpu_stat_off) if (need_update(cpu) && @@ -1325,6 +1326,7 @@ static void vmstat_shepherd(struct work_ schedule_delayed_work_on(cpu, &per_cpu(vmstat_work, cpu), __round_jiffies_relative(sysctl_stat_interval, cpu)); + put_online_cpus(); schedule_delayed_work(&shepherd, round_jiffies_relative(sysctl_stat_interval)); @@ -1380,8 +1382,8 @@ static int vmstat_cpuup_callback(struct break; case CPU_DOWN_PREPARE: case CPU_DOWN_PREPARE_FROZEN: - if (!cpumask_test_and_set_cpu(cpu, cpu_stat_off)) - cancel_delayed_work_sync(&per_cpu(vmstat_work, cpu)); + cancel_delayed_work_sync(&per_cpu(vmstat_work, cpu)); + cpumask_clear_cpu(cpu, cpu_stat_off); break; case CPU_DOWN_FAILED: case CPU_DOWN_FAILED_FROZEN: From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qg0-f50.google.com (mail-qg0-f50.google.com [209.85.192.50]) by kanga.kvack.org (Postfix) with ESMTP id 5C78E6B00A0 for ; Wed, 6 Aug 2014 10:12:46 -0400 (EDT) Received: by mail-qg0-f50.google.com with SMTP id q108so2696001qgd.37 for ; Wed, 06 Aug 2014 07:12:46 -0700 (PDT) Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net. [2001:558:fe2d:43:76:96:30:16]) by mx.google.com with ESMTP id hl16si1771727qcb.1.2014.08.06.07.12.45 for ; Wed, 06 Aug 2014 07:12:45 -0700 (PDT) Date: Wed, 6 Aug 2014 09:12:39 -0500 (CDT) From: Christoph Lameter Subject: Re: vmstat: On demand vmstat workers V8 In-Reply-To: <53E159F6.7080603@oracle.com> Message-ID: References: <53D31101.8000107@oracle.com> <53DFFD28.2030502@oracle.com> <53E159F6.7080603@oracle.com> Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Sasha Levin Cc: akpm@linux-foundation.org, Gilad Ben-Yossef , Thomas Gleixner , Tejun Heo , John Stultz , Mike Frysinger , Minchan Kim , Hakan Akkan , Max Krasnyansky , Frederic Weisbecker , "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, hughd@google.com, viresh.kumar@linaro.org, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org On Tue, 5 Aug 2014, Sasha Levin wrote: > I can easily trigger it by cranking up the cpu hotplug code. Just try to > frequently offline and online cpus, it should reproduce quickly. Thats what I thought. The test was done with this fix applied right? Subject: vmstat ondemand: Fix online/offline races Do not allow onlining/offlining while the shepherd task is checking for vmstat threads. On offlining a processor do the right thing cancelling the vmstat worker thread if it exista and also exclude it from the shepherd process checks. Signed-off-by: Christoph Lameter Index: linux/mm/vmstat.c =================================================================== --- linux.orig/mm/vmstat.c 2014-07-30 09:35:54.602662306 -0500 +++ linux/mm/vmstat.c 2014-07-30 09:43:07.109037043 -0500 @@ -1317,6 +1317,7 @@ static void vmstat_shepherd(struct work_ { int cpu; + get_online_cpus(); /* Check processors whose vmstat worker threads have been disabled */ for_each_cpu(cpu, cpu_stat_off) if (need_update(cpu) && @@ -1325,6 +1326,7 @@ static void vmstat_shepherd(struct work_ schedule_delayed_work_on(cpu, &per_cpu(vmstat_work, cpu), __round_jiffies_relative(sysctl_stat_interval, cpu)); + put_online_cpus(); schedule_delayed_work(&shepherd, round_jiffies_relative(sysctl_stat_interval)); @@ -1380,8 +1382,8 @@ static int vmstat_cpuup_callback(struct break; case CPU_DOWN_PREPARE: case CPU_DOWN_PREPARE_FROZEN: - if (!cpumask_test_and_set_cpu(cpu, cpu_stat_off)) - cancel_delayed_work_sync(&per_cpu(vmstat_work, cpu)); + cancel_delayed_work_sync(&per_cpu(vmstat_work, cpu)); + cpumask_clear_cpu(cpu, cpu_stat_off); break; case CPU_DOWN_FAILED: case CPU_DOWN_FAILED_FROZEN: -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org