linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shiraz Hashim <shiraz.linux.kernel@gmail.com>
To: Christoph Lameter <cl@linux.com>
Cc: Michal Hocko <mhocko@kernel.org>,
	Sasha Levin <sasha.levin@oracle.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: mm, vmstat: kernel BUG at mm/vmstat.c:1408!
Date: Fri, 22 Jan 2016 16:30:22 +0530	[thread overview]
Message-ID: <CAPub149DrtF8tVPauiZttAa9FBVqjJvsi=JXx=UosUtsWcyNDg@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1601211130580.7741@east.gentwo.org>

On Thu, Jan 21, 2016 at 11:08 PM, Christoph Lameter <cl@linux.com> 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 <cl@linux.com>
>
> 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
<enter idle>                                    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

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2016-01-22 11:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-19  0:33 Sasha Levin
2015-12-21 13:08 ` Christoph Lameter
2015-12-21 20:28   ` Sasha Levin
2015-12-21 21:07     ` Sasha Levin
2015-12-21 21:14       ` Christoph Lameter
2015-12-22 17:21         ` Christoph Lameter
2015-12-24 20:14         ` Sasha Levin
2015-12-29 17:01           ` Christoph Lameter
2015-12-29 17:18             ` Christoph Lameter
2016-01-04 18:05           ` Christoph Lameter
2016-01-04 18:46             ` Sasha Levin
2016-01-12 11:31   ` Shiraz Hashim
2016-01-12 12:23     ` Christoph Lameter
2016-01-12 12:27       ` Shiraz Hashim
2016-01-13 11:36       ` Shiraz Hashim
2016-01-13 12:32         ` Shiraz Hashim
2016-01-14 21:06         ` Sasha Levin
2016-01-20 14:37 ` Michal Hocko
2016-01-20 14:56   ` Sasha Levin
2016-01-20 15:10     ` Michal Hocko
2016-01-20 15:20       ` Christoph Lameter
2016-01-20 15:49         ` Sasha Levin
2016-01-20 15:55           ` Christoph Lameter
2016-01-20 21:28             ` Michal Hocko
2016-01-20 21:57               ` Christoph Lameter
2016-01-21  8:24                 ` Michal Hocko
2016-01-21 15:45                   ` Christoph Lameter
2016-01-21 16:51                     ` Michal Hocko
2016-01-21 17:38                       ` Christoph Lameter
2016-01-22 11:00                         ` Shiraz Hashim [this message]
2016-01-22 14:04                         ` Michal Hocko
2016-01-22 16:07                           ` Christoph Lameter
2016-01-22 16:12                             ` Michal Hocko
2016-01-22 16:46                               ` Christoph Lameter
2016-01-22 17:12                                 ` Michal Hocko
2016-01-24 16:57                                 ` Linus Torvalds
2016-01-20 15:14   ` Christoph Lameter
2016-01-20 15:20     ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPub149DrtF8tVPauiZttAa9FBVqjJvsi=JXx=UosUtsWcyNDg@mail.gmail.com' \
    --to=shiraz.linux.kernel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=sasha.levin@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox