All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: Tejun Heo <tj@kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: workqueue question.
Date: Wed, 29 Jun 2011 09:02:29 -0700	[thread overview]
Message-ID: <4E0B4C95.6080409@candelatech.com> (raw)
In-Reply-To: <20110629084329.GI3386@htj.dyndns.org>

On 06/29/2011 01:43 AM, Tejun Heo wrote:
> Hello,
>
> On Tue, Jun 28, 2011 at 11:56:39AM -0700, Ben Greear wrote:
>> Is it OK to call INIT_WORK(&foo, bar)
>> if we are currently being called by the work-queue
>> using foo?
>
> Yes, but if flush_work*() races with it, flushing can finish before
> execution is complete.

It appears that the code just wants to (re)add itself to the
work queue with a different callback method:

static void rpc_final_put_task(struct rpc_task *task,
		struct workqueue_struct *q)
{
	if (q != NULL) {
		INIT_WORK(&task->u.tk_work, rpc_async_release);
		queue_work(q, &task->u.tk_work);
	} else
		rpc_free_task(task);
}

My debugging leads me to believe that the rpc_async_release
is (very rarely) called on a task object that has already been logically
freed.

Is there a better way to queue this up that might have less chance
of some strange race?

>
>> Also, is it valid to free the memory containing foo
>> in a workqueue callback?
>
> Yeap.

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?

I tried doing a cancel, but that caused recursive locking issues.

I'd like to call this right before freeing the object and BUG_ON()
if the object is actually still on on a work-queue.

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


  reply	other threads:[~2011-06-29 16:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-28 18:56 workqueue question Ben Greear
2011-06-29  8:43 ` Tejun Heo
2011-06-29 16:02   ` Ben Greear [this message]
2011-06-30 10:00     ` Tejun Heo
2011-06-30 17:18       ` Ben Greear
2011-07-01 16:37         ` 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=4E0B4C95.6080409@candelatech.com \
    --to=greearb@candelatech.com \
    --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 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.