mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Gautham R Shenoy <ego@in.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Rusty Russel <rusty@rustcorp.com.au>,
	Srivatsa Vaddagiri <vatsa@in.ibm.com>,
	Dipankar Sarma <dipankar@in.ibm.com>, Ingo Molnar <mingo@elte.hu>,
	Paul E McKenney <paulmck@us.ibm.com>,
	Richard Gooch <rgooch@atnf.csiro.au>,
	Tigran Aivazian <tigran@aivazian.fs.co.uk>,
	Shoahua Li <shaohua.li@linux.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Nathan Lynch <ntl@pobox.com>, Paul Jackson <pj@sgi.com>,
	Christoph Lameter <clameter@sgi.com>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Akinobu Mita <akinobu.mita@gmail.com>
Subject: Re: [RFC PATCH 1/3] cpu-hotplug: Refcount Based Cpu Hotplug implementation
Date: Thu, 15 Nov 2007 20:12:17 +0300	[thread overview]
Message-ID: <20071115171217.GA144@tv-sign.ru> (raw)
In-Reply-To: <20071115135108.GA15462@in.ibm.com>

On 11/15, Gautham R Shenoy wrote:
>
> +static struct {
> +	struct task_struct *active_writer;
> +	struct mutex lock; /* Synchronizes accesses to refcount, */
> +	/*
> +	 * Also blocks the new readers during
> +	 * an ongoing cpu hotplug operation.
> +	 */
> +	int refcount;
> +	wait_queue_head_t writer_queue;
> +} cpu_hotplug;
> ...
>  void unlock_cpu_hotplug(void)
>  {
> -	WARN_ON(recursive != current);
> -	if (recursive_depth) {
> -		recursive_depth--;
> +	if (cpu_hotplug.active_writer == current)
>  		return;
> -	}
> -	recursive = NULL;
> -	mutex_unlock(&cpu_bitmask_lock);
> +	mutex_lock(&cpu_hotplug.lock);
> +	cpu_hotplug.refcount--;
> +
> +	if (unlikely(writer_exists()) && !cpu_hotplug.refcount)
> +		wake_up(&cpu_hotplug.writer_queue);
> +
> +	mutex_unlock(&cpu_hotplug.lock);
> +
>  }
> ...
> +static void cpu_hotplug_begin(void)
> +{
> +	DECLARE_WAITQUEUE(wait, current);
> +
> +	mutex_lock(&cpu_hotplug.lock);
> +
> +	cpu_hotplug.active_writer = current;
> +	add_wait_queue_exclusive(&cpu_hotplug.writer_queue, &wait);
> +	while (cpu_hotplug.refcount) {
> +		set_current_state(TASK_UNINTERRUPTIBLE);
> +		mutex_unlock(&cpu_hotplug.lock);
> +		schedule();
> +		mutex_lock(&cpu_hotplug.lock);
> +	}
> +	remove_wait_queue_locked(&cpu_hotplug.writer_queue, &wait);
> +}

Perhaps we can simplify this a little bit? I don't think we really need
cpu_hotplug.writer_queue, afaics we can just do

	void unlock_cpu_hotplug(void)
	{
		if (cpu_hotplug.active_writer == current)
			return;
		mutex_lock(&cpu_hotplug.lock);
		if (!--cpu_hotplug.refcount && cpu_hotplug.active_writer)
			wake_up_process(cpu_hotplug.active_writer);
		mutex_unlock(&cpu_hotplug.lock);

	}

	static void cpu_hotplug_begin(void)
	{
		mutex_lock(&cpu_hotplug.lock);
		cpu_hotplug.active_writer = current;

		while (cpu_hotplug.refcount) {
			__set_current_state(TASK_UNINTERRUPTIBLE);
			mutex_unlock(&cpu_hotplug.lock);
			schedule();
			mutex_lock(&cpu_hotplug.lock);
		}
	}

(not that it matters, we can do this later even if I am right)

Oleg.


  parent reply	other threads:[~2007-11-15 17:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-15 13:49 [RFC PATCH 0/3] Refcount Based Cpu Hotplug V3 Gautham R Shenoy
2007-11-15 13:51 ` [RFC PATCH 1/3] cpu-hotplug: Refcount Based Cpu Hotplug implementation Gautham R Shenoy
2007-11-15 14:15   ` Ingo Molnar
2007-11-15 15:25     ` Ingo Molnar
2007-11-15 16:05       ` Ingo Molnar
2007-11-20 10:55         ` Gautham R Shenoy
2007-11-15 17:12   ` Oleg Nesterov [this message]
2007-11-15 13:52 ` [RFC PATCH 2/3] cpu-hotplug: Replace lock_cpu_hotplug() with get_online_cpus() Gautham R Shenoy
2007-11-15 15:37   ` Ralf Baechle DL5RB
2007-11-15 13:53 ` [RFC PATCH 3/3] cpu-hotplug: Replace per-subsystem mutexes " Gautham R Shenoy
2007-11-15 16:36   ` Oleg Nesterov
2007-11-15 18:26   ` Christoph Lameter
2007-11-15 14:13 ` [RFC PATCH 0/3] Refcount Based Cpu Hotplug V3 Ingo Molnar
2007-11-15 18:27 ` Christoph Lameter

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=20071115171217.GA144@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=dipankar@in.ibm.com \
    --cc=ego@in.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=ntl@pobox.com \
    --cc=paulmck@us.ibm.com \
    --cc=penberg@cs.helsinki.fi \
    --cc=pj@sgi.com \
    --cc=ralf@linux-mips.org \
    --cc=rgooch@atnf.csiro.au \
    --cc=rusty@rustcorp.com.au \
    --cc=shaohua.li@linux.com \
    --cc=tigran@aivazian.fs.co.uk \
    --cc=torvalds@linux-foundation.org \
    --cc=vatsa@in.ibm.com \
    /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®