From: Emese Revfy <re.emese@gmail.com>
To: Greg KH <gregkh@suse.de>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
linux-kernel@vger.kernel.org, rientjes@google.com,
cl@linux-foundation.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, rjw@sisk.pl, rusty@rustcorp.com.au,
Arjan van de Ven <arjan@infradead.org>
Subject: Re: [PATCH 1/1] Constify struct kset_uevent_ops for 2.6.33-rc2
Date: Thu, 31 Dec 2009 14:52:51 +0100 [thread overview]
Message-ID: <4B3CACB3.8020901@gmail.com> (raw)
In-Reply-To: <20091231044039.GB27927@suse.de>
From: Emese Revfy <re.emese@gmail.com>
Constify struct kset_uevent_ops.
This is part of the ops structure constification
effort started by Arjan van de Ven et al.
Benefits of this constification:
* prevents modification of data that is shared
(referenced) by many other structure instances
at runtime
* detects/prevents accidental (but not intentional)
modification attempts on archs that enforce
read-only kernel data at runtime
* potentially better optimized code as the compiler
can assume that the const data cannot be changed
* the compiler/linker move const data into .rodata
and therefore exclude them from false sharing
Signed-off-by: Emese Revfy <re.emese@gmail.com>
---
drivers/base/bus.c | 2 +-
drivers/base/core.c | 2 +-
drivers/base/memory.c | 2 +-
fs/gfs2/sys.c | 2 +-
include/linux/kobject.h | 10 +++++-----
kernel/params.c | 2 +-
lib/kobject.c | 4 ++--
lib/kobject_uevent.c | 2 +-
mm/slub.c | 2 +-
9 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index c0c5a43..2afe599 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj)
return 0;
}
-static struct kset_uevent_ops bus_uevent_ops = {
+static const struct kset_uevent_ops bus_uevent_ops = {
.filter = bus_uevent_filter,
};
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 2820257..82bd3ff 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -252,7 +252,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
return retval;
}
-static struct kset_uevent_ops device_uevent_ops = {
+static const struct kset_uevent_ops device_uevent_ops = {
.filter = dev_uevent_filter,
.name = dev_uevent_name,
.uevent = dev_uevent,
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index d7d77d4..0bcf8c2 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uev
return retval;
}
-static struct kset_uevent_ops memory_uevent_ops = {
+static const struct kset_uevent_ops memory_uevent_ops = {
.name = memory_uevent_name,
.uevent = memory_uevent,
};
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 0dc3462..9be733e 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -576,7 +576,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
return 0;
}
-static struct kset_uevent_ops gfs2_uevent_ops = {
+static const struct kset_uevent_ops gfs2_uevent_ops = {
.uevent = gfs2_uevent,
};
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 58ae8e0..57a1eaa 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -118,9 +118,9 @@ struct kobj_uevent_env {
};
struct kset_uevent_ops {
- int (*filter)(struct kset *kset, struct kobject *kobj);
- const char *(*name)(struct kset *kset, struct kobject *kobj);
- int (*uevent)(struct kset *kset, struct kobject *kobj,
+ int (* const filter)(struct kset *kset, struct kobject *kobj);
+ const char *(* const name)(struct kset *kset, struct kobject *kobj);
+ int (* const uevent)(struct kset *kset, struct kobject *kobj,
struct kobj_uevent_env *env);
};
@@ -155,14 +155,14 @@ struct kset {
struct list_head list;
spinlock_t list_lock;
struct kobject kobj;
- struct kset_uevent_ops *uevent_ops;
+ const struct kset_uevent_ops *uevent_ops;
};
extern void kset_init(struct kset *kset);
extern int __must_check kset_register(struct kset *kset);
extern void kset_unregister(struct kset *kset);
extern struct kset * __must_check kset_create_and_add(const char *name,
- struct kset_uevent_ops *u,
+ const struct kset_uevent_ops *u,
struct kobject *parent_kobj);
static inline struct kset *to_kset(struct kobject *kobj)
diff --git a/kernel/params.c b/kernel/params.c
index cf1b691..ac5de7d 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -737,7 +737,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
return 0;
}
-static struct kset_uevent_ops module_uevent_ops = {
+static const struct kset_uevent_ops module_uevent_ops = {
.filter = uevent_filter,
};
diff --git a/lib/kobject.c b/lib/kobject.c
index b512b74..cecf5a0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -789,7 +789,7 @@ static struct kobj_type kset_ktype = {
* If the kset was not able to be created, NULL will be returned.
*/
static struct kset *kset_create(const char *name,
- struct kset_uevent_ops *uevent_ops,
+ const struct kset_uevent_ops *uevent_ops,
struct kobject *parent_kobj)
{
struct kset *kset;
@@ -832,7 +832,7 @@ static struct kset *kset_create(const char *name,
* If the kset was not able to be created, NULL will be returned.
*/
struct kset *kset_create_and_add(const char *name,
- struct kset_uevent_ops *uevent_ops,
+ const struct kset_uevent_ops *uevent_ops,
struct kobject *parent_kobj)
{
struct kset *kset;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 920a3ca..c9d3a3e 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -95,7 +95,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
const char *subsystem;
struct kobject *top_kobj;
struct kset *kset;
- struct kset_uevent_ops *uevent_ops;
+ const struct kset_uevent_ops *uevent_ops;
u64 seq;
int i = 0;
int retval = 0;
diff --git a/mm/slub.c b/mm/slub.c
index 8d71aaf..02b5a83 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4538,7 +4538,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
return 0;
}
-static struct kset_uevent_ops slab_uevent_ops = {
+static const struct kset_uevent_ops slab_uevent_ops = {
.filter = uevent_filter,
};
next prev parent reply other threads:[~2009-12-31 13:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-14 0:00 [PATCH 0/4] Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2 re.emese
2009-12-14 0:00 ` [PATCH 1/4] " re.emese
2009-12-14 0:00 ` [PATCH 1/1] Constify struct kgdb_io " re.emese
2009-12-14 0:00 ` [PATCH 2/4] Constify struct kset_uevent_ops " re.emese
2009-12-14 10:22 ` Steven Whitehouse
2009-12-14 0:00 ` [PATCH 3/4] " re.emese
2009-12-25 11:31 ` Pekka Enberg
2009-12-26 0:38 ` Emese Revfy
2009-12-28 20:46 ` David Rientjes
2009-12-29 20:50 ` Emese Revfy
2009-12-29 20:51 ` Pekka Enberg
2009-12-29 7:24 ` Pekka Enberg
2009-12-29 20:58 ` [PATCH 1/1] Constify struct kset_uevent_ops for 2.6.33-rc2 Emese Revfy
2009-12-30 0:11 ` Greg KH
2009-12-31 0:16 ` Emese Revfy
2009-12-31 4:40 ` Greg KH
2009-12-31 13:52 ` Emese Revfy [this message]
2009-12-14 0:00 ` [PATCH 4/4] Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2 re.emese
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=4B3CACB3.8020901@gmail.com \
--to=re.emese@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=cl@linux-foundation.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=rientjes@google.com \
--cc=rjw@sisk.pl \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.