All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kthread_worker: Add flush delayed work func
@ 2020-11-11  9:13 qiang.zhang
  2020-11-13  0:01 ` Andrew Morton
  2020-11-16 16:23 ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: qiang.zhang @ 2020-11-11  9:13 UTC (permalink / raw)
  To: pmladek, tj; +Cc: akpm, linux-mm, linux-kernel

From: Zqiang <qiang.zhang@windriver.com>

Add 'kthread_flush_delayed_work' func, the principle of
this func is wait for a dwork to finish executing the
last queueing.

Signed-off-by: Zqiang <qiang.zhang@windriver.com>
---
 kernel/kthread.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index a5eceecd4513..1afe399ccd02 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -1045,6 +1045,30 @@ void kthread_flush_work(struct kthread_work *work)
 }
 EXPORT_SYMBOL_GPL(kthread_flush_work);
 
+/*
+ * kthread_flush_delayed_work - flush a kthread_delayed_work
+ * @dwork: dwork to flush
+ *
+ * wait for a dwork to finish executing the last queueing
+ */
+void kthread_flush_delayed_work(struct kthread_delayed_work *dwork)
+{
+	struct kthread_work *work = &dwork->work;
+	struct kthread_worker *worker = work->worker;
+	unsigned long flags;
+
+	if (del_timer_sync(&dwork->timer)) {
+		raw_spin_lock_irqsave(&worker->lock, flags);
+		list_del_init(&work->node);
+		if (!work->canceling)
+			kthread_insert_work(worker, work, &worker->work_list);
+
+		raw_spin_unlock_irqrestore(&worker->lock, flags);
+	}
+	kthread_flush_work(work);
+}
+EXPORT_SYMBOL_GPL(kthread_flush_delayed_work);
+
 /*
  * This function removes the work from the worker queue. Also it makes sure
  * that it won't get queued later via the delayed work's timer.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kthread_worker: Add flush delayed work func
  2020-11-11  9:13 [PATCH] kthread_worker: Add flush delayed work func qiang.zhang
@ 2020-11-13  0:01 ` Andrew Morton
  2020-11-13  8:59   ` 回复: " Zhang, Qiang
  2020-11-16 16:23 ` Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2020-11-13  0:01 UTC (permalink / raw)
  To: qiang.zhang; +Cc: pmladek, tj, linux-mm, linux-kernel

On Wed, 11 Nov 2020 17:13:55 +0800 qiang.zhang@windriver.com wrote:

> Add 'kthread_flush_delayed_work' func, the principle of
> this func is wait for a dwork to finish executing the
> last queueing.

We'd like to see some code which actually uses this new function
please.  Either in this patch or as one or more followup patches.

btw, we call it "function", not "func".  But neither is really needed -
just use () to identify a function.  ie:

: Add kthread_flush_delayed_work().  The principle of this is to wait for
: a dwork to finish executing the last queueing.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* 回复: [PATCH] kthread_worker: Add flush delayed work func
  2020-11-13  0:01 ` Andrew Morton
@ 2020-11-13  8:59   ` Zhang, Qiang
  2020-11-13 10:24     ` Petr Mladek
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Qiang @ 2020-11-13  8:59 UTC (permalink / raw)
  To: Andrew Morton; +Cc: pmladek, tj, linux-mm, linux-kernel, Zhang, Qiang



________________________________________
发件人: Andrew Morton <akpm@linux-foundation.org>
发送时间: 2020年11月13日 8:01
收件人: Zhang, Qiang
抄送: pmladek@suse.com; tj@kernel.org; linux-mm@kvack.org; linux-kernel@vger.kernel.org
主题: Re: [PATCH] kthread_worker: Add flush delayed work func

[Please note this e-mail is from an EXTERNAL e-mail address]

On Wed, 11 Nov 2020 17:13:55 +0800 qiang.zhang@windriver.com wrote:

> Add 'kthread_flush_delayed_work' func, the principle of
> this func is wait for a dwork to finish executing the
> last queueing.
>
>We'd like to see some code which actually uses this new function
>please.  Either in this patch or as one or more followup patches.
>
>btw, we call it "function", not "func".  But neither is really needed -
>just use () to identify a function.  ie:

>: Add kthread_flush_delayed_work().  The principle of this is to wait for
>: a dwork to finish executing the last queueing.

I don't see it being used in the kernel code so far, and I'm not sure if it's going to be used in subsequent scenarios (it like flush_delayed_work in workqueue )or whether it's currently using "kthread_work" some code needs it.

Thanks

Qiang

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 回复: [PATCH] kthread_worker: Add flush delayed work func
  2020-11-13  8:59   ` 回复: " Zhang, Qiang
@ 2020-11-13 10:24     ` Petr Mladek
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Mladek @ 2020-11-13 10:24 UTC (permalink / raw)
  To: Zhang, Qiang; +Cc: Andrew Morton, tj, linux-mm, linux-kernel

On Fri 2020-11-13 08:59:37, Zhang, Qiang wrote:
> 
> 
> ________________________________________
> 发件人: Andrew Morton <akpm@linux-foundation.org>
> 发送时间: 2020年11月13日 8:01
> 收件人: Zhang, Qiang
> 抄送: pmladek@suse.com; tj@kernel.org; linux-mm@kvack.org; linux-kernel@vger.kernel.org
> 主题: Re: [PATCH] kthread_worker: Add flush delayed work func
> 
> [Please note this e-mail is from an EXTERNAL e-mail address]
> 
> On Wed, 11 Nov 2020 17:13:55 +0800 qiang.zhang@windriver.com wrote:
> 
> > Add 'kthread_flush_delayed_work' func, the principle of
> > this func is wait for a dwork to finish executing the
> > last queueing.
> >
> >We'd like to see some code which actually uses this new function
> >please.  Either in this patch or as one or more followup patches.
> >
> >btw, we call it "function", not "func".  But neither is really needed -
> >just use () to identify a function.  ie:
> 
> >: Add kthread_flush_delayed_work().  The principle of this is to wait for
> >: a dwork to finish executing the last queueing.
> 
> I don't see it being used in the kernel code so far, and I'm not sure if it's going to be used in subsequent scenarios (it like flush_delayed_work in workqueue )or whether it's currently using "kthread_work" some code needs it.

I agree with Andrew. It does not make sense to add/maintain new API
when it is not going to be used.

The kthread_worker API is used only when the kthread needs some special
scheduling policy or priority. There always will be only few users
in compare with the workqueues API. It is possible that this function
will never be necessary.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kthread_worker: Add flush delayed work func
  2020-11-11  9:13 [PATCH] kthread_worker: Add flush delayed work func qiang.zhang
  2020-11-13  0:01 ` Andrew Morton
@ 2020-11-16 16:23 ` Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2020-11-16 16:23 UTC (permalink / raw)
  To: qiang.zhang; +Cc: pmladek, tj, akpm, linux-mm, linux-kernel

On Wed, Nov 11, 2020 at 05:13:55PM +0800, qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
> 
> Add 'kthread_flush_delayed_work' func, the principle of
> this func is wait for a dwork to finish executing the
> last queueing.

Who is going to use it?  And why?  Please document this and resend it
together with the series adding the user(s).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-16 16:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11  9:13 [PATCH] kthread_worker: Add flush delayed work func qiang.zhang
2020-11-13  0:01 ` Andrew Morton
2020-11-13  8:59   ` 回复: " Zhang, Qiang
2020-11-13 10:24     ` Petr Mladek
2020-11-16 16:23 ` Christoph Hellwig

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.