mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Tejun Heo <htejun@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] sched/kthread: Complain loudly when others violate our flags
Date: Fri, 30 Sep 2011 11:23:02 +0200	[thread overview]
Message-ID: <1317374582.19415.12.camel@twins> (raw)
In-Reply-To: <20110930041424.GH10425@mtj.dyndns.org>




> static void flush_gcwq(struct global_cwq *gcwq)
> {
>         struct work_struct *work, *nw;
>         struct worker *worker, *n;
>         LIST_HEAD(non_affine_works);
> 
>         spin_lock_irq(&gcwq->lock);
>         list_for_each_entry_safe(work, nw, &gcwq->worklist, entry) {
>                 struct workqueue_struct *wq = get_work_cwq(work)->wq;
> 
>                 if (wq->flags & WQ_NON_AFFINE)
>                         list_move(&work->entry, &non_affine_works);
>         }
> 
>         while (!list_empty(&gcwq->worklist)) {
>                 int nr_works = 0;
> 
>                 list_for_each_entry(work, &gcwq->worklist, entry) {
>                         send_mayday(work);
>                         nr_works++;
>                 }
> 
>                 list_for_each_entry(worker, &gcwq->idle_list, entry) {
>                         if (!nr_works--)
>                                 break;
>                         wake_up_process(worker->task);
>                 }
> 
>                 spin_unlock_irq(&gcwq->lock);
> 
>                 if (need_to_create_worker(gcwq)) {
>                         worker = create_worker(gcwq, true);
>                         if (worker)
>                                 start_worker(worker);
>                 }
> 
>                 wait_event_timeout(gcwq->idle_wait,
>                                 gcwq->nr_idle == gcwq->nr_workers, HZ/10);
> 
>                 spin_lock_irq(&gcwq->lock);
>         }

We could probably replace that loop with one of the flush/barrier
thingies, but I got lost and wanted to post something. Using a proper
flush would also get rid of that icky waitqueue.

> 
>         WARN_ON(gcwq->nr_workers != gcwq->nr_idle);
> 
>         list_for_each_entry_safe(worker, n, &gcwq->idle_list, entry)
>                 destroy_worker(worker);
> 
>         WARN_ON(gcwq->nr_workers || gcwq->nr_idle);
> 
>         spin_unlock_irq(&gcwq->lock);
> 
>         gcwq = get_gcwq(get_cpu());
>         spin_lock_irq(&gcwq->lock);
>         list_for_each_entry_safe(work, nw, &non_affine_works, entry) {
>                 list_del_init(&work->entry);
>                 ___queue_work(get_work_cwq(work)->wq, gcwq, work);
>         }
>         spin_unlock_irq(&gcwq->lock);
>         put_cpu();
> }

  parent reply	other threads:[~2011-09-30  9:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 21:17 Steven Rostedt
2011-09-28  0:22 ` Thomas Gleixner
2011-09-30  3:48 ` Tejun Heo
2011-09-30  4:05   ` Steven Rostedt
2011-09-30  4:14     ` Tejun Heo
2011-09-30  8:34       ` Peter Zijlstra
2011-09-30  8:55         ` Tejun Heo
2011-09-30  9:04           ` Peter Zijlstra
2011-10-03  1:15             ` Tejun Heo
2011-10-03 10:20               ` Peter Zijlstra
2011-10-07  1:40                 ` Tejun Heo
2011-10-03 10:33               ` Peter Zijlstra
2011-10-03 13:43                 ` Thomas Gleixner
2011-10-03 10:50               ` Peter Zijlstra
2011-09-30  9:23       ` Peter Zijlstra [this message]
2011-09-30  9:29       ` Peter Zijlstra
2011-09-30  9:27   ` Peter Zijlstra
2011-10-03  1:22     ` Tejun Heo
2011-09-30  3:55 ` Tejun Heo
2011-09-30  4:08   ` Steven Rostedt
2011-09-30  4:28     ` 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=1317374582.19415.12.camel@twins \
    --to=peterz@infradead.org \
    --cc=htejun@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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®