From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Pavel Emelyanov <xemul@openvz.org>
Cc: Andrew Morton <akpm@osdl.org>, Cedric Le Goater <clg@fr.ibm.com>,
Serge Hallyn <serue@us.ibm.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
devel@openvz.org
Subject: Re: [PATCH] Make initializer for statically declared krefs
Date: Mon, 1 Oct 2007 08:19:21 -0500 [thread overview]
Message-ID: <20071001131921.GA30599@sergelap.austin.ibm.com> (raw)
In-Reply-To: <4700CB8C.7030007@openvz.org>
Quoting Pavel Emelyanov (xemul@openvz.org):
> Since the struct kref already has the _get, _put and _init
> routines, this seems useful to have an initializer for those
> statically declared (like for atomic_t or spinlock_t).
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Sure.
Acked-by: Serge Hallyn <serue@us.ibm.com>
> ---
>
> diff --git a/include/linux/kref.h b/include/linux/kref.h
> index 6fee353..a84c582 100644
> --- a/include/linux/kref.h
> +++ b/include/linux/kref.h
> @@ -24,6 +24,8 @@ struct kref {
> atomic_t refcount;
> };
>
> +#define INIT_KREF(count) { .refcount = ATOMIC_INIT(count), }
> +
> void kref_init(struct kref *kref);
> void kref_get(struct kref *kref);
> int kref_put(struct kref *kref, void (*release) (struct kref *kref));
> diff --git a/init/version.c b/init/version.c
> index 9d17d70..53d2ca7 100644
> --- a/init/version.c
> +++ b/init/version.c
> @@ -19,9 +19,7 @@
> int version_string(LINUX_VERSION_CODE);
>
> struct uts_namespace init_uts_ns = {
> - .kref = {
> - .refcount = ATOMIC_INIT(2),
> - },
> + .kref = INIT_KREF(2),
> .name = {
> .sysname = UTS_SYSNAME,
> .nodename = UTS_NODENAME,
> diff --git a/ipc/util.c b/ipc/util.c
> index fd29246..526aa14 100644
> --- a/ipc/util.c
> +++ b/ipc/util.c
> @@ -45,9 +45,7 @@ struct ipc_proc_iface {
> };
>
> struct ipc_namespace init_ipc_ns = {
> - .kref = {
> - .refcount = ATOMIC_INIT(2),
> - },
> + .kref = INIT_KREF(2),
> };
>
> static struct ipc_namespace *clone_ipc_ns(struct ipc_namespace *old_ns)
> diff --git a/kernel/pid.c b/kernel/pid.c
> index d7388d7..e9d3ff1 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -69,9 +69,7 @@ static inline int mk_pid(struct pid_name
> * the scheme scales to up to 4 million PIDs, runtime.
> */
> struct pid_namespace init_pid_ns = {
> - .kref = {
> - .refcount = ATOMIC_INIT(2),
> - },
> + .kref = INIT_KREF(2),
> .pidmap = {
> [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
> },
> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
> index 7af90fc..33d21e0 100644
> --- a/kernel/user_namespace.c
> +++ b/kernel/user_namespace.c
> @@ -11,9 +11,7 @@
> #include <linux/user_namespace.h>
>
> struct user_namespace init_user_ns = {
> - .kref = {
> - .refcount = ATOMIC_INIT(2),
> - },
> + .kref = INIT_KREF(2),
> .root_user = &root_user,
> };
prev parent reply other threads:[~2007-10-01 13:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-01 10:27 Pavel Emelyanov
2007-10-01 13:19 ` Serge E. Hallyn [this message]
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=20071001131921.GA30599@sergelap.austin.ibm.com \
--to=serue@us.ibm.com \
--cc=akpm@osdl.org \
--cc=clg@fr.ibm.com \
--cc=devel@openvz.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xemul@openvz.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
all inboxes | Powered by JetHome®