* [PATCH] kobject_add: use constant strings directly as fmt strings
@ 2008-11-19 15:54 crquan
2008-11-19 15:57 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: crquan @ 2008-11-19 15:54 UTC (permalink / raw)
To: Jens Axboe; +Cc: Greg Kroah-Hartman, linux-kernel
From: Cheng Renquan <crquan@gmail.com>
Signed-off-by: Cheng Renquan <crquan@gmail.com>
---
block/blk-sysfs.c | 2 +-
block/elevator.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 21e275d..0b189e9 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -342,7 +342,7 @@ int blk_register_queue(struct gendisk *disk)
return 0;
ret = kobject_add(&q->kobj, kobject_get(&disk_to_dev(disk)->kobj),
- "%s", "queue");
+ "queue");
if (ret < 0)
return ret;
diff --git a/block/elevator.c b/block/elevator.c
index 9ac82dd..9a39f27 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -1005,7 +1005,7 @@ int elv_register_queue(struct request_queue *q)
elevator_t *e = q->elevator;
int error;
- error = kobject_add(&e->kobj, &q->kobj, "%s", "iosched");
+ error = kobject_add(&e->kobj, &q->kobj, "iosched");
if (!error) {
struct elv_fs_entry *attr = e->elevator_type->elevator_attrs;
if (attr) {
--
1.6.0.4.758.g36c05
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] kobject_add: use constant strings directly as fmt strings
2008-11-19 15:54 [PATCH] kobject_add: use constant strings directly as fmt strings crquan
@ 2008-11-19 15:57 ` Greg KH
2008-11-19 16:17 ` rae l
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2008-11-19 15:57 UTC (permalink / raw)
To: crquan; +Cc: Jens Axboe, linux-kernel
On Wed, Nov 19, 2008 at 11:54:19PM +0800, crquan@gmail.com wrote:
> From: Cheng Renquan <crquan@gmail.com>
>
> Signed-off-by: Cheng Renquan <crquan@gmail.com>
> ---
> block/blk-sysfs.c | 2 +-
> block/elevator.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 21e275d..0b189e9 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -342,7 +342,7 @@ int blk_register_queue(struct gendisk *disk)
> return 0;
>
> ret = kobject_add(&q->kobj, kobject_get(&disk_to_dev(disk)->kobj),
> - "%s", "queue");
> + "queue");
Why? What does this change buy us?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kobject_add: use constant strings directly as fmt strings
2008-11-19 15:57 ` Greg KH
@ 2008-11-19 16:17 ` rae l
2008-11-19 17:00 ` Kay Sievers
0 siblings, 1 reply; 5+ messages in thread
From: rae l @ 2008-11-19 16:17 UTC (permalink / raw)
To: Greg KH; +Cc: Jens Axboe, linux-kernel
On Wed, Nov 19, 2008 at 11:57 PM, Greg KH <gregkh@suse.de> wrote:
>> ret = kobject_add(&q->kobj, kobject_get(&disk_to_dev(disk)->kobj),
>> - "%s", "queue");
>> + "queue");
>
> Why? What does this change buy us?
Dropping one parameter makes the function call a little faster, doesn't it?
The results are the same,
so if the string is constant, why not use it directly as the fmt string?
Thanks.
>
> thanks,
>
> greg k-h
--
Cheng Renquan, Shenzhen, China
Lily Tomlin - "The trouble with the rat race is that even if you win,
you're still a rat."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kobject_add: use constant strings directly as fmt strings
2008-11-19 16:17 ` rae l
@ 2008-11-19 17:00 ` Kay Sievers
2008-11-19 17:37 ` rae l
0 siblings, 1 reply; 5+ messages in thread
From: Kay Sievers @ 2008-11-19 17:00 UTC (permalink / raw)
To: rae l; +Cc: Greg KH, Jens Axboe, linux-kernel
On Wed, Nov 19, 2008 at 17:17, rae l <crquan@gmail.com> wrote:
> On Wed, Nov 19, 2008 at 11:57 PM, Greg KH <gregkh@suse.de> wrote:
>>> ret = kobject_add(&q->kobj, kobject_get(&disk_to_dev(disk)->kobj),
>>> - "%s", "queue");
>>> + "queue");
>>
>> Why? What does this change buy us?
>
> Dropping one parameter makes the function call a little faster, doesn't it?
>
> The results are the same,
Not that we should be able to measure it, but it should save some
cycles parsing the format character and retrieving the string pointer
from the stack, yes.
> so if the string is constant, why not use it directly as the fmt string?
It should be fine for strings, where you can be sure they can never
contain a '%', sure.
Thanks,
Kay
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kobject_add: use constant strings directly as fmt strings
2008-11-19 17:00 ` Kay Sievers
@ 2008-11-19 17:37 ` rae l
0 siblings, 0 replies; 5+ messages in thread
From: rae l @ 2008-11-19 17:37 UTC (permalink / raw)
To: Kay Sievers; +Cc: Greg KH, Jens Axboe, linux-kernel
On Thu, Nov 20, 2008 at 1:00 AM, Kay Sievers <kay.sievers@vrfy.org> wrote:
> Not that we should be able to measure it, but it should save some
> cycles parsing the format character and retrieving the string pointer
> from the stack, yes.
I'm sure it does work, one another as:
*** drivers/net/iseries_veth.c:
veth_probe_one[1088] if (0 != kobject_add(&port->kobject,
&dev->dev.kobj, "veth_port"))
>> so if the string is constant, why not use it directly as the fmt string?
>
> It should be fine for strings, where you can be sure they can never
> contain a '%', sure.
And I have searched all places kobject_add called, only these two
places in block/blk-sysfs.c
and block/elevator.c have constant strings. So this patch is the whole
kobject_add constant string
optmization patch.
>
> Thanks,
> Kay
--
Cheng Renquan, Shenzhen, China
Fred Allen - "An associate producer is the only guy in Hollywood who
will associate with a producer."
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-19 17:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-19 15:54 [PATCH] kobject_add: use constant strings directly as fmt strings crquan
2008-11-19 15:57 ` Greg KH
2008-11-19 16:17 ` rae l
2008-11-19 17:00 ` Kay Sievers
2008-11-19 17:37 ` rae l
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.