From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753123AbcAVLA3 (ORCPT ); Fri, 22 Jan 2016 06:00:29 -0500 Received: from mail-ig0-f195.google.com ([209.85.213.195]:35414 "EHLO mail-ig0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752643AbcAVLAX (ORCPT ); Fri, 22 Jan 2016 06:00:23 -0500 MIME-Version: 1.0 In-Reply-To: References: <20160120143719.GF14187@dhcp22.suse.cz> <569FA01A.4070200@oracle.com> <20160120151007.GG14187@dhcp22.suse.cz> <569FAC90.5030407@oracle.com> <20160120212806.GA26965@dhcp22.suse.cz> <20160121082402.GA29520@dhcp22.suse.cz> <20160121165148.GF29520@dhcp22.suse.cz> Date: Fri, 22 Jan 2016 16:30:22 +0530 Message-ID: Subject: Re: mm, vmstat: kernel BUG at mm/vmstat.c:1408! From: Shiraz Hashim To: Christoph Lameter Cc: Michal Hocko , Sasha Levin , LKML , "linux-mm@kvack.org" , Andrew Morton Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2016 at 11:08 PM, Christoph Lameter wrote: > Subject: vmstat: Queue work before clearing cpu_stat_off > > There is a race between vmstat_shepherd and quiet_vmstat() because > the responsibility for checking for counter updates changes depending > on the state of teh bit in cpu_stat_off. So queue the work before > changing state of the bit in vmstat_shepherd. That way quiet_vmstat > is guaranteed to remove the work request when clearing the bit and the > bug in vmstat_update wont trigger anymore. > > Signed-off-by: Christoph Lameter > > Index: linux/mm/vmstat.c > =================================================================== > --- linux.orig/mm/vmstat.c > +++ linux/mm/vmstat.c > @@ -1480,12 +1480,14 @@ static void vmstat_shepherd(struct work_ > get_online_cpus(); > /* Check processors whose vmstat worker threads have been disabled */ > for_each_cpu(cpu, cpu_stat_off) > - if (need_update(cpu) && > - cpumask_test_and_clear_cpu(cpu, cpu_stat_off)) > + if (need_update(cpu)) { > > queue_delayed_work_on(cpu, vmstat_wq, > &per_cpu(vmstat_work, cpu), 0); > > + cpumask_clear_cpu(smp_processor_id(), cpu_stat_off); > + } > + > put_online_cpus(); > > schedule_delayed_work(&shepherd, This can alternatively lead to following where vmstat may not be scheduled for cpu when it is back from idle. CPU0: CPU1: vmstat_shepherd queue_delayed_work_on(CPU0) quiet_vmstat cancel_delayed_work cpumask_test_and_set_cpu (0->1) cpumask_clear_cpu(CPU0) (1->0) -- regards Shiraz Hashim