From: Petr Mladek <pmladek@suse.com>
To: Yiwei Zhang <zzyiwei@android.com>
Cc: Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Felix Kuehling <Felix.Kuehling@amd.com>,
Jens Axboe <axboe@kernel.dk>,
"J. Bruce Fields" <bfields@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <frederic@kernel.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
Ilias Stamatis <stamatis.iliass@gmail.com>,
Rob Clark <robdclark@chromium.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Liang Chen <cl@rock-chips.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
kernel-team <kernel-team@android.com>
Subject: Re: [PATCH] kthread: add kthread_mod_pending_delayed_work api
Date: Fri, 19 Feb 2021 11:27:13 +0100 [thread overview]
Message-ID: <YC+SgVZdm5gfSqFg@alley> (raw)
In-Reply-To: <CAKB3++b+n=VWuXZqZqyZJvAf1+Wqogvi07L21GqdRwThSRdf2w@mail.gmail.com>
On Thu 2021-02-18 22:29:24, Yiwei Zhang wrote:
> > 2. User triggered clean up races with the clean up triggered by
> > timeout. You try to handle this scenario by this patch.
> Yes, exactly.
>
> > 3. User does clean up after the clean up has already been done
> > by the timeout.
> This case is well handled. So only (2) has a potential race.
Just to be sure. Does the user work correctly when the clean up work
is done by the timemout before the user wanted to do the clean up?
> Let me clarify a bit more here. The "clean up" is not the clean up
> when a process tears down, but it's actually a "post-work" to cancel
> out an early "pre-work". The "pre-work" enqueues the delayed "post
> work" for the timeout purpose. That pair of operations can repeatedly
> happen.
>
> The racing is currently worked around by refcounting the delayed_work
> container, and the later "post-work" will take care of the work
> deallocation.
>
> I mainly want to reach out to see if we agree that this is a valid API
> to be supported by kthread. Or we extend the existing
> kthread_mod_delayed_work api to take another option to not re-queue if
> the cancel failed.
OK, I could imagine a situation when you want to speed up the delayed
work and avoid this race.
The kthread_worker API has more or less the same semantic as
the workqueue API. It makes it easier to switch between them.
The workqueue API has flush_delayed_work(). It does basically
the same as your code. We should call the function
kthread_worker_flush_delayed_work().
I am personally fine with adding this API. I am going to
comment the original code. Well, there might be a push-back
from other people because there will be no in-tree user.
Best Regards,
Petr
next prev parent reply other threads:[~2021-02-19 10:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-14 0:06 Yiwei Zhang
2021-02-15 13:28 ` Petr Mladek
2021-02-16 9:11 ` Christoph Hellwig
2021-02-16 18:58 ` Yiwei Zhang
2021-02-17 11:14 ` Petr Mladek
2021-02-19 6:29 ` Yiwei Zhang
2021-02-19 10:27 ` Petr Mladek [this message]
2021-02-19 10:30 ` Christoph Hellwig
2021-02-19 10:56 ` Petr Mladek
2021-02-23 0:39 ` Yiwei Zhang
2021-02-23 0:58 ` Yiwei Zhang
2021-02-23 15:52 ` Petr Mladek
2021-02-23 22:29 ` Yiwei Zhang
2021-02-24 9:34 ` Petr Mladek
2021-02-25 22:17 ` Yiwei Zhang
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=YC+SgVZdm5gfSqFg@alley \
--to=pmladek@suse.com \
--cc=Felix.Kuehling@amd.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bfields@redhat.com \
--cc=cl@rock-chips.com \
--cc=frederic@kernel.org \
--cc=hch@infradead.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mtosatti@redhat.com \
--cc=peterz@infradead.org \
--cc=robdclark@chromium.org \
--cc=stamatis.iliass@gmail.com \
--cc=zzyiwei@android.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
all inboxes | Powered by JetHome®