LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: "Du, Changbin" <changbin.du@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] workqueue: detect uninitated work_struct and BUG() if true
Date: Mon, 9 Mar 2015 02:22:43 -0400	[thread overview]
Message-ID: <20150309062243.GL13283@htj.duckdns.org> (raw)
In-Reply-To: <0C18FE92A7765D4EB9EE5D38D86A563A01C85B55@SHSMSX103.ccr.corp.intel.com>

On Mon, Mar 09, 2015 at 04:43:11AM +0000, Du, Changbin wrote:
> From cdebb88ac0fb3f900ef28f28ccb4a12159c295db Mon Sep 17 00:00:00 2001
> From: "Du, Changbin" <changbin.du@gmail.com>
> Date: Mon, 9 Mar 2015 12:06:43 +0800
> Subject: [PATCH] workqueue: detect uninitated work_struct and BUG() if true
> 
> Recently I encounter a driver issue that caused by missing initializing
> the work_struct. Then the work never get executed and stay in workqueue
> forever. This take me some time to locate the error. This issue can be
> seen early if detect it when queuing a work.
> 
> Signed-off-by: Du, Changbin <changbin.du@intel.com>
> ---
>  kernel/workqueue.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index f288493..5c1a5bc 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -1295,6 +1295,9 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
>  	 */
>  	WARN_ON_ONCE(!irqs_disabled());
>  
> +	if (!work->func)
> +		BUG();
> +
>  	debug_work_activate(work);

Can't this be part of the debug_work mechanism?  I'm a bit wary of
adding essentially arbitrary checks.  I'd much prefer if it gets gated
by debug config somehow.

Thanks.

-- 
tejun

  reply	other threads:[~2015-03-09  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09  4:43 Du, Changbin
2015-03-09  6:22 ` Tejun Heo [this message]
2015-03-10 13:20   ` Du, Changbin

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=20150309062243.GL13283@htj.duckdns.org \
    --to=tj@kernel.org \
    --cc=changbin.du@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] workqueue: detect uninitated work_struct and BUG() if true' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).