From: Jason Xing <kerneljasonxing@linux.alibaba.com>
To: hannes@cmpxchg.org, surenb@google.com
Cc: dennis@kernel.org, mingo@redhat.com, axboe@kernel.dk,
lizefan@huawei.com, peterz@infradead.org, tj@kernel.org,
linux-kernel@vger.kernel.org, caspar@linux.alibaba.com,
joseph.qi@linux.alibaba.com
Subject: Re: [PATCH v2] psi: get poll_work to run when calling poll syscall next time
Date: Thu, 15 Aug 2019 09:59:39 +0800 [thread overview]
Message-ID: <3208597b-05d1-2461-729b-c35bd6811188@linux.alibaba.com> (raw)
In-Reply-To: <1564463819-120014-1-git-send-email-kerneljasonxing@linux.alibaba.com>
Hello,
It's been delayed for no reason a couple of days. Any comments and
suggestions on this patch V2 would be appreciated.
Thanks,
Jason
On 2019/7/30 下午1:16, Jason Xing wrote:
> Only when calling the poll syscall the first time can user
> receive POLLPRI correctly. After that, user always fails to
> acquire the event signal.
>
> Reproduce case:
> 1. Get the monitor code in Documentation/accounting/psi.txt
> 2. Run it, and wait for the event triggered.
> 3. Kill and restart the process.
>
> If the user doesn't kill the monitor process, it seems the
> poll_work works fine. After killing and restarting the monitor,
> the poll_work in kernel will never run again due to the wrong
> value of poll_scheduled. Therefore, we should reset the value
> as group_init() does after the last trigger is destroyed.
>
> [PATCH V2]
> In the patch v2, I put the atomic_set(&group->poll_scheduled, 0);
> into the right place.
> Here I quoted from Johannes as the best explaination:
> "The question is why we can end up with poll_scheduled = 1 but the work
> not running (which would reset it to 0). And the answer is because the
> scheduling side sees group->poll_kworker under RCU protection and then
> schedules it, but here we cancel the work and destroy the worker. The
> cancel needs to pair with resetting the poll_scheduled flag."
>
> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
> Reviewed-by: Caspar Zhang <caspar@linux.alibaba.com>
> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> Reviewed-by: Suren Baghdasaryan <surenb@google.com>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
> kernel/sched/psi.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index 7acc632..acdada0 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
> @@ -1131,7 +1131,14 @@ static void psi_trigger_destroy(struct kref *ref)
> * deadlock while waiting for psi_poll_work to acquire trigger_lock
> */
> if (kworker_to_destroy) {
> + /*
> + * After the RCU grace period has expired, the worker
> + * can no longer be found through group->poll_kworker.
> + * But it might have been already scheduled before
> + * that - deschedule it cleanly before destroying it.
> + */
> kthread_cancel_delayed_work_sync(&group->poll_work);
> + atomic_set(&group->poll_scheduled, 0);
> kthread_destroy_worker(kworker_to_destroy);
> }
> kfree(t);
>
prev parent reply other threads:[~2019-08-15 2:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 6:45 [PATCH] " Jason Xing
2019-07-23 10:02 ` Caspar Zhang
2019-07-29 8:12 ` Jason Xing
2019-07-29 15:29 ` Johannes Weiner
2019-07-29 16:27 ` Suren Baghdasaryan
2019-07-30 5:16 ` [PATCH v2] " Jason Xing
2019-08-02 6:20 ` Jason Xing
2019-08-15 1:59 ` Jason Xing [this message]
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=3208597b-05d1-2461-729b-c35bd6811188@linux.alibaba.com \
--to=kerneljasonxing@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=caspar@linux.alibaba.com \
--cc=dennis@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®