lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 1 Jul 2011 18:37:33 +0200
From:	Tejun Heo <tj@...nel.org>
To:	Ben Greear <greearb@...delatech.com>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: workqueue question.

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ