Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751329AbbLUNIw (ORCPT ); Mon, 21 Dec 2015 08:08:52 -0500 Received: from resqmta-ch2-02v.sys.comcast.net ([69.252.207.34]:44399 "EHLO resqmta-ch2-02v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbbLUNIu (ORCPT ); Mon, 21 Dec 2015 08:08:50 -0500 Date: Mon, 21 Dec 2015 07:08:49 -0600 (CST) From: Christoph Lameter X-X-Sender: cl@east.gentwo.org To: Sasha Levin cc: Michal Hocko , LKML , "linux-mm@kvack.org" Subject: Re: mm, vmstat: kernel BUG at mm/vmstat.c:1408! In-Reply-To: <5674A5C3.1050504@oracle.com> Message-ID: References: <5674A5C3.1050504@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 Content-Length: 1518 Lines: 46 On Fri, 18 Dec 2015, Sasha Levin wrote: > [ 531.164630] RIP vmstat_update (mm/vmstat.c:1408) Hmmm.. Yes we need to fold the diffs first before disabling the timer otherwise the shepherd task may intervene. Does this patch fix it? Subject: quiet_vmstat: Avoid race with shepherd by folding counters first We need to fold the counters first otherwise the shepherd task may remotely reactivate the vmstat worker. This also avoids the strange loop. Nothing can really increase the counters at that point since we are in the cpu idle loop. So folding the counters once is enough. Cancelling work that does not exist is fine too so just avoid the branches completely. Signed-off-by: Christoph Lameter Index: linux/mm/vmstat.c =================================================================== --- linux.orig/mm/vmstat.c +++ linux/mm/vmstat.c @@ -1419,11 +1419,9 @@ void quiet_vmstat(void) if (system_state != SYSTEM_RUNNING) return; - do { - if (!cpumask_test_and_set_cpu(smp_processor_id(), cpu_stat_off)) - cancel_delayed_work(this_cpu_ptr(&vmstat_work)); - - } while (refresh_cpu_vm_stats(false)); + refresh_cpu_vm_stats(false); + cancel_delayed_work(this_cpu_ptr(&vmstat_work)); + cpumask_set_cpu(smp_processor_id(), cpu_stat_off); } /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/