From: Tejun Heo <tj@kernel.org>
To: Ben Greear <greearb@candelatech.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: workqueue question.
Date: Fri, 1 Jul 2011 18:37:33 +0200 [thread overview]
Message-ID: <20110701163733.GZ3386@htj.dyndns.org> (raw)
In-Reply-To: <4E0CAFFC.4000902@candelatech.com>
Hello,
On Thu, Jun 30, 2011 at 10:18:52AM -0700, Ben Greear wrote:
> >>Is there a method that can be called from a workqueue callback
> >>to verify that the item has not been re-added to the work-queue?
> >
> >Can you be a bit more specific? Are you saying that queue_work() and
> >INIT_WORK() may race?
>
> No, I don't think that is racing. Basically, when I'm about
> to logically free (put back into mempool) the task struct, I
> would like to add a sanity check to make sure it's not currently
> scheduled on a work queue. If it were, that would explain the
> backtraces I was seeing from slub memory debugging logic and
> I'd be closer to understanding the problem.
Ah, okay. When a work is in pending state, work_pending() is always
true; however, whether a work item is currently being executed is a
bit more complicated. You'll need to implement a function which looks
similar to the following.
bool is_work_executing(work)
{
for_each_gcwq_cpu(cpu) {
gcwq = get_gcwq(cpu);
lock gcwq;
if (find_worker_executing_work(gcwq, work)) {
unlock gcwq;
return true;
}
unlock gcwq;
}
return false;
}
But I would recommend watching workqueue tracing points first.
$ grep workqueue /sys/kernel/debug/tracing/available_events
workqueue:workqueue_queue_work
workqueue:workqueue_activate_work
workqueue:workqueue_execute_start
workqueue:workqueue_execute_end
You should be able to tell which work is doing what on which CPU.
Thanks.
--
tejun
prev parent reply other threads:[~2011-07-01 16:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-28 18:56 Ben Greear
2011-06-29 8:43 ` Tejun Heo
2011-06-29 16:02 ` Ben Greear
2011-06-30 10:00 ` Tejun Heo
2011-06-30 17:18 ` Ben Greear
2011-07-01 16:37 ` Tejun Heo [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=20110701163733.GZ3386@htj.dyndns.org \
--to=tj@kernel.org \
--cc=greearb@candelatech.com \
--cc=linux-kernel@vger.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®