From: Johannes Berg <johannes@sipsolutions.net>
To: Tejun Heo <tj@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] workqueue: fix cwq->nr_active underflow
Date: Wed, 25 Aug 2010 11:11:41 +0200 [thread overview]
Message-ID: <1282727501.3685.7.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <4C74D9E4.5070403@kernel.org>
On Wed, 2010-08-25 at 10:52 +0200, Tejun Heo wrote:
> cwq->nr_active is used to keep track of how many work items are active
> for the cpu workqueue, where 'active' is defined as either pending on
> global worklist or executing. This is used to implement the
> max_active limit and workqueue freezing. If a work item is queued
> after nr_active has already reached max_active, the work item doesn't
> increment nr_active and is put on the delayed queue and gets activated
> later as previous active work items retire.
>
> try_to_grab_pending() which is used in the cancellation path
> unconditionally decremented nr_active whether the work item being
> cancelled is currently active or delayed, so cancelling a delayed work
> item makes nr_active underflow. This breaks max_active enforcement
> and triggers BUG_ON() in destroy_workqueue() later on.
>
> This patch fixes this bug by adding a flag WORK_STRUCT_DELAYED, which
> is set while a work item in on the delayed list and making
> try_to_grab_pending() decrement nr_active iff the work item is
> currently active.
>
> The addition of the flag enlarges cwq alignment to 256 bytes which is
> getting a bit too large. It's scheduled to be reduced back to 128
> bytes by merging WORK_STRUCT_PENDING and WORK_STRUCT_CWQ in the next
> devel cycle.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> ---
> Johannes, although I don't have your confirmation yet, my simple test
> case confirms the bug and fix, so I'm pushing it out. Please let me
> know if you can confirm the fix.
Thanks Tejun. Come to think of it, since it's an underflow it should be
easier for me to change the BUG_ON into a printk + BUG_ON() to print out
the current value, and then reproduce -- that way I'll know when I hit
the situation, which isn't trivial, and also whether I hit the
underflow. Does that sound like a good thing to try to you?
johannes
next prev parent reply other threads:[~2010-08-25 9:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-25 8:52 [PATCH] workqueue: fix cwq->nr_active underflow Tejun Heo
2010-08-25 9:11 ` Johannes Berg [this message]
2010-08-25 9:12 ` Tejun Heo
2010-08-25 9:20 ` Johannes Berg
2010-08-25 14:25 ` Johannes Berg
2010-08-25 14:21 ` Tejun Heo
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=1282727501.3685.7.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--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