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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100301145344.GA9815@redhat.com>
Date:	Mon, 1 Mar 2010 15:53:44 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Tejun Heo <tj@...nel.org>
Cc:	torvalds@...ux-foundation.org, mingo@...e.hu, peterz@...radead.org,
	awalls@...ix.net, linux-kernel@...r.kernel.org, jeff@...zik.org,
	akpm@...ux-foundation.org, jens.axboe@...cle.com,
	rusty@...tcorp.com.au, cl@...ux-foundation.org,
	dhowells@...hat.com, arjan@...ux.intel.com, avi@...hat.com,
	johannes@...solutions.net, andi@...stfloor.org
Subject: Re: [PATCH 20/43] workqueue: reimplement work flushing using
	linked works

On 02/26, Tejun Heo wrote:
>
> +static void move_linked_works(struct work_struct *work, struct list_head *head,
> +			      struct work_struct **nextp)
> +{
> ...
> +	work = list_entry(work->entry.prev, struct work_struct, entry);
> +	list_for_each_entry_safe_continue(work, n, NULL, entry) {

list_for_each_entry_safe_from(work) ? It doesn't need to move this
work back.

> @@ -680,7 +734,27 @@ static int worker_thread(void *__worker)
>  		if (kthread_should_stop())
>  			break;
>
> -		run_workqueue(worker);
> +		spin_lock_irq(&cwq->lock);
> +
> +		while (!list_empty(&cwq->worklist)) {
> +			struct work_struct *work =
> +				list_first_entry(&cwq->worklist,
> +						 struct work_struct, entry);
> +
> +			if (likely(!(*work_data_bits(work) &
> +				     WORK_STRUCT_LINKED))) {
> +				/* optimization path, not strictly necessary */
> +				process_one_work(worker, work);
> +				if (unlikely(!list_empty(&worker->scheduled)))
> +					process_scheduled_works(worker);
> +			} else {
> +				move_linked_works(work, &worker->scheduled,
> +						  NULL);
> +				process_scheduled_works(worker);
> +			}
> +		}

So. If the next pending work W doesn't have WORK_STRUCT_LINKED,
it will be executed first, then we flush ->scheduled.

But,

>  static void insert_wq_barrier(struct cpu_workqueue_struct *cwq,
> -			struct wq_barrier *barr, struct list_head *head)
> +			      struct wq_barrier *barr,
> +			      struct work_struct *target, struct worker *worker)
>  {
> ...
> +	/*
> +	 * If @target is currently being executed, schedule the
> +	 * barrier to the worker; otherwise, put it after @target.
> +	 */
> +	if (worker)
> +		head = worker->scheduled.next;

this is the "target == current_work" case,

> -	insert_work(cwq, &barr->work, head, work_color_to_flags(WORK_NO_COLOR));
> +	insert_work(cwq, &barr->work, head,
> +		    work_color_to_flags(WORK_NO_COLOR) | linked);
>  }

and in this case we put this barrier at the head of ->scheduled list.

This means, this barrier will run after that work W, not before it?


Hmm. And what if there are no pending works but ->current_work == target ?
Again, we add the barrier to ->scheduled, but in this case worker_thread()
can't even notice ->scheduled is not empty because it only checks ->worklist?

Well. most probably I just misread this code completely...


insert_wq_barrier() also does:

	unsigned long *bits = work_data_bits(target);
	...
	*bits |= WORK_STRUCT_LINKED;

perhaps this needs atomic_long_set(), although I am not sure this really
matters.

Oleg.

--
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