public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
	Linux Containers <containers@lists.osdl.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCH] vt: Rework the console spawning variables.
Date: Sun, 10 Sep 2006 18:29:42 +0400	[thread overview]
Message-ID: <20060910142942.GA7384@oleg> (raw)
In-Reply-To: <m1mz98fj16.fsf@ebiederm.dsl.xmission.com>

On 09/09, Eric W. Biederman wrote:
> 
> This patch does several things.
> - The variables used are moved into a structure and declared in vt_kern.h
> - A spinlock is added so we don't have SMP races updating the values.
> - Instead of raw pid_t value a struct_pid is used to guard against
>   pid wrap around issues, if the daemon to spawn a new console dies.

I am not arguing against this patch, but it's a pity we can't use 'struct pid'
lockless. What dou you think about this:

	void delayed_free_pid(struct rcu_head *rhp)
	{
		struct pid *pid = container_of(rhp, struct pid, rcu);
		kmem_cache_free(pid_cachep, pid);
	}

	void put_pid_rcu(struct pid *pid)
	{
		if (atomic_dec_and_test(&pid->count))
			// this can happen only if delayed_put_pid()
			// was already fired, we can re-use pid->rcu
			call_rcu(&pid->rcu, delayed_free_pid);
	}

Now,

	update_pid()
	{
		// still needs some locking
		put_pid_rcu(pid);
		pid = get_pid(...);
	}

	use_pid()
	{
		rcu_read_lock();
		do_something(pid);
		rcu_read_unock();
	}

Thoughts?

Oleg.


  reply	other threads:[~2006-09-10 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-10  4:21 [PATCH] vt: Rework the console spawning variables Eric W. Biederman
2006-09-10 14:29 ` Oleg Nesterov [this message]
2006-09-10 20:10   ` Eric W. Biederman
2006-09-10 20:33     ` Oleg Nesterov
2006-09-10 22:56       ` Eric W. Biederman
2006-09-11  1:05         ` Oleg Nesterov
2006-09-11  2:40           ` Eric W. Biederman
2006-09-11  2:59             ` Oleg Nesterov
2006-09-11  5:01               ` Eric W. Biederman

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=20060910142942.GA7384@oleg \
    --to=oleg@tv-sign.ru \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=containers@lists.osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox