* [PATCH] sysfs/file: move NULL checks to where they make sense and can occur
@ 2010-03-05 10:46 André Goddard Rosa
2010-03-09 7:38 ` Tejun Heo
0 siblings, 1 reply; 3+ messages in thread
From: André Goddard Rosa @ 2010-03-05 10:46 UTC (permalink / raw)
To: Greg Kroah-Hartman, Alex Chiang, Kenji Kaneshige, Serge Hallyn,
Tejun Heo, linux-kernel
Cc: André Goddard Rosa
... avoiding checking for NULL 2 times in a row when we already have a page.
It decreases code size:
text data bss dec hex filename
4246 48 4136 8430 20ee fs/sysfs/file-BEFORE.o
4214 48 4136 8398 20ce fs/sysfs/file-AFTER.o
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
---
fs/sysfs/file.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index dc30d9e..962b190 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -79,10 +79,11 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
int ret = 0;
ssize_t count;
- if (!buffer->page)
- buffer->page = (char *) get_zeroed_page(GFP_KERNEL);
- if (!buffer->page)
- return -ENOMEM;
+ if (!buffer->page) {
+ buffer->page = (char *)get_zeroed_page(GFP_KERNEL);
+ if (!buffer->page)
+ return -ENOMEM;
+ }
/* need attr_sd for attr and ops, its parent for kobj */
if (!sysfs_get_active_two(attr_sd))
@@ -167,10 +168,11 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t
{
int error;
- if (!buffer->page)
+ if (!buffer->page) {
buffer->page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!buffer->page)
- return -ENOMEM;
+ if (!buffer->page)
+ return -ENOMEM;
+ }
if (count >= PAGE_SIZE)
count = PAGE_SIZE - 1;
--
1.7.0.1.164.gbe2f
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] sysfs/file: move NULL checks to where they make sense and can occur
2010-03-05 10:46 [PATCH] sysfs/file: move NULL checks to where they make sense and can occur André Goddard Rosa
@ 2010-03-09 7:38 ` Tejun Heo
2010-03-09 11:58 ` André Goddard Rosa
0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2010-03-09 7:38 UTC (permalink / raw)
To: André Goddard Rosa
Cc: Greg Kroah-Hartman, Alex Chiang, Kenji Kaneshige, Serge Hallyn,
linux-kernel
Hello,
On 03/05/2010 07:46 PM, André Goddard Rosa wrote:
> ... avoiding checking for NULL 2 times in a row when we already have a page.
>
> It decreases code size:
> text data bss dec hex filename
> 4246 48 4136 8430 20ee fs/sysfs/file-BEFORE.o
> 4214 48 4136 8398 20ce fs/sysfs/file-AFTER.o
>
> Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Nacked-by: Tejun Heo <tj@kernel.org>
For this level of micro optimization to be meaningful, the code path
should be *really* *really* hot, which none of sysfs code pats are.
Whatever is easier to the eyes wins.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sysfs/file: move NULL checks to where they make sense and can occur
2010-03-09 7:38 ` Tejun Heo
@ 2010-03-09 11:58 ` André Goddard Rosa
0 siblings, 0 replies; 3+ messages in thread
From: André Goddard Rosa @ 2010-03-09 11:58 UTC (permalink / raw)
To: Tejun Heo
Cc: Greg Kroah-Hartman, Alex Chiang, Kenji Kaneshige, Serge Hallyn,
linux-kernel
Hello,
> On 03/05/2010 07:46 PM, André Goddard Rosa wrote:
>> ... avoiding checking for NULL 2 times in a row when we already have a page.
>>
>> It decreases code size:
>> text data bss dec hex filename
>> 4246 48 4136 8430 20ee fs/sysfs/file-BEFORE.o
>> 4214 48 4136 8398 20ce fs/sysfs/file-AFTER.o
>>
>> Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
>
> Nacked-by: Tejun Heo <tj@kernel.org>
>
> For this level of micro optimization to be meaningful, the code path
> should be *really* *really* hot, which none of sysfs code pats are.
> Whatever is easier to the eyes wins.
>
Ok Tejun, I understood your point of view.
Thanks,
André
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-09 12:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-05 10:46 [PATCH] sysfs/file: move NULL checks to where they make sense and can occur André Goddard Rosa
2010-03-09 7:38 ` Tejun Heo
2010-03-09 11:58 ` André Goddard Rosa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).