All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Suren Baghdasaryan <surenb@google.com>
Cc: gregkh@linuxfoundation.org, tj@kernel.org, lizefan@huawei.com,
	axboe@kernel.dk, dennis@kernel.org, dennisszhou@gmail.com,
	mingo@redhat.com, peterz@infradead.org,
	akpm@linux-foundation.org, corbet@lwn.net,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@android.com
Subject: Re: [PATCH v3 5/5] psi: introduce psi monitor
Date: Mon, 28 Jan 2019 16:26:32 -0500	[thread overview]
Message-ID: <20190128212632.GD1416@cmpxchg.org> (raw)
In-Reply-To: <20190124211518.244221-6-surenb@google.com>

One thought on the v3 delta that I missed earlier:

On Thu, Jan 24, 2019 at 01:15:18PM -0800, Suren Baghdasaryan wrote:
> +/*
> + * psi_update_work represents slowpath accounting part while psi_group_change
> + * represents hotpath part. There are two potential races between them:
> + * 1. Changes to group->polling when slowpath checks for new stall, then hotpath
> + *    records new stall and then slowpath resets group->polling flag. This leads
> + *    to the exit from the polling mode while monitored state is still changing.
> + * 2. Slowpath overwriting an immediate update scheduled from the hotpath with
> + *    a regular update further in the future and missing the immediate update.
> + * Both races are handled with a retry cycle in the slowpath:
> + *
> + *    HOTPATH:                         |    SLOWPATH:
> + *                                     |
> + * A) times[cpu] += delta              | E) delta = times[*]
> + * B) start_poll = (delta[poll_mask] &&|    if delta[poll_mask]:
> + *      cmpxchg(g->polling, 0, 1) == 0)| F)   polling_until = now + grace_period
> + *    if start_poll:                   |    if now > polling_until:
> + * C)   mod_delayed_work(1)            |      if g->polling:

With the polling flag being atomic now, this "if g->polling" line
isn't accurate anymore. Since this diagram is specifically about
memory ordering, this should move the g->polling load up to where
delta is read and then refer to unordered local variables down here.

  reply	other threads:[~2019-01-28 21:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24 21:15 [PATCH v3 0/5] psi: pressure stall monitors v3 Suren Baghdasaryan
2019-01-24 21:15 ` [PATCH v3 1/5] fs: kernfs: add poll file operation Suren Baghdasaryan
2019-01-24 21:15 ` [PATCH v3 2/5] kernel: cgroup: " Suren Baghdasaryan
2019-01-24 21:15 ` [PATCH v3 3/5] psi: introduce state_mask to represent stalled psi states Suren Baghdasaryan
2019-01-28 21:22   ` Johannes Weiner
2019-01-24 21:15 ` [PATCH v3 4/5] psi: rename psi fields in preparation for psi trigger addition Suren Baghdasaryan
2019-01-28 21:23   ` Johannes Weiner
2019-01-24 21:15 ` [PATCH v3 5/5] psi: introduce psi monitor Suren Baghdasaryan
2019-01-28 21:26   ` Johannes Weiner [this message]
2019-01-28 23:53   ` Minchan Kim
2019-01-29  1:52     ` Suren Baghdasaryan
2019-01-29 18:35     ` Johannes Weiner
2019-01-29 10:44   ` Peter Zijlstra
2019-01-29 18:05     ` Suren Baghdasaryan
2019-01-29 12:38   ` Peter Zijlstra
2019-01-29 15:16     ` Peter Zijlstra
2019-01-29 18:25       ` Suren Baghdasaryan
2019-01-29 18:18     ` Suren Baghdasaryan
2019-01-29 18:31       ` Suren Baghdasaryan
2019-01-29 19:08       ` Peter Zijlstra

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=20190128212632.GD1416@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=dennis@kernel.org \
    --cc=dennisszhou@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@android.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.