2010-12-07 02:14:06

by Steven Rostedt

[permalink] [raw]
Subject: [RFC][PATCH 05/10] mm: Remove likely() from grab_cache_page_write_begin()

From: Steven Rostedt <[email protected]>

Running the annotated branch profiler on a box doing average work
(firefox, evolution, xchat, distcc farm), the likely() used in
grab_cache_page_write_begin() was incorrect most of the time:

correct incorrect % Function File Line
------- --------- - -------- ---- ----
1924262 71332401 97 grab_cache_page_write_begin filemap.c 2206

Adding a trace_printk() and running the function tracer limited to
just this function I can see:

gconfd-2-2696 [000] 4467.268935: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=7
gconfd-2-2696 [000] 4467.268946: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268947: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=8
gconfd-2-2696 [000] 4467.268959: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268960: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=9
gconfd-2-2696 [000] 4467.268972: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268973: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=10
gconfd-2-2696 [000] 4467.268991: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268992: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=11
gconfd-2-2696 [000] 4467.269005: grab_cache_page_write_begin <-ext3_write_begin

Which shows that a lot of calls from ext3_write_begin will result in
the page returned by "find_lock_page" will be NULL.

Cc: Nick Piggin <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
mm/filemap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index ea89840..d557fe7 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2218,7 +2218,7 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
gfp_notmask = __GFP_FS;
repeat:
page = find_lock_page(mapping, index);
- if (likely(page))
+ if (page)
return page;

page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask);
--
1.7.2.3


2010-12-07 02:24:13

by Steven Rostedt

[permalink] [raw]
Subject: Re: [RFC][PATCH 05/10] mm: Remove likely() from grab_cache_page_write_begin()

[ Resending to Nick's real email address ]

From: Steven Rostedt <[email protected]>

Running the annotated branch profiler on a box doing average work
(firefox, evolution, xchat, distcc farm), the likely() used in
grab_cache_page_write_begin() was incorrect most of the time:

correct incorrect % Function File Line
------- --------- - -------- ---- ----
1924262 71332401 97 grab_cache_page_write_begin filemap.c 2206

Adding a trace_printk() and running the function tracer limited to
just this function I can see:

gconfd-2-2696 [000] 4467.268935: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=7
gconfd-2-2696 [000] 4467.268946: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268947: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=8
gconfd-2-2696 [000] 4467.268959: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268960: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=9
gconfd-2-2696 [000] 4467.268972: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268973: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=10
gconfd-2-2696 [000] 4467.268991: grab_cache_page_write_begin <-ext3_write_begin
gconfd-2-2696 [000] 4467.268992: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=11
gconfd-2-2696 [000] 4467.269005: grab_cache_page_write_begin <-ext3_write_begin

Which shows that a lot of calls from ext3_write_begin will result in
the page returned by "find_lock_page" will be NULL.

Cc: Nick Piggin <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
mm/filemap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index ea89840..d557fe7 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2218,7 +2218,7 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
gfp_notmask = __GFP_FS;
repeat:
page = find_lock_page(mapping, index);
- if (likely(page))
+ if (page)
return page;

page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask);

2010-12-07 06:57:07

by Nick Piggin

[permalink] [raw]
Subject: Re: [RFC][PATCH 05/10] mm: Remove likely() from grab_cache_page_write_begin()

On Mon, Dec 06, 2010 at 09:24:10PM -0500, Steven Rostedt wrote:
> [ Resending to Nick's real email address ]
>
> From: Steven Rostedt <[email protected]>
>
> Running the annotated branch profiler on a box doing average work
> (firefox, evolution, xchat, distcc farm), the likely() used in
> grab_cache_page_write_begin() was incorrect most of the time:
>
> correct incorrect % Function File Line
> ------- --------- - -------- ---- ----
> 1924262 71332401 97 grab_cache_page_write_begin filemap.c 2206
>
> Adding a trace_printk() and running the function tracer limited to
> just this function I can see:
>
> gconfd-2-2696 [000] 4467.268935: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=7
> gconfd-2-2696 [000] 4467.268946: grab_cache_page_write_begin <-ext3_write_begin
> gconfd-2-2696 [000] 4467.268947: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=8
> gconfd-2-2696 [000] 4467.268959: grab_cache_page_write_begin <-ext3_write_begin
> gconfd-2-2696 [000] 4467.268960: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=9
> gconfd-2-2696 [000] 4467.268972: grab_cache_page_write_begin <-ext3_write_begin
> gconfd-2-2696 [000] 4467.268973: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=10
> gconfd-2-2696 [000] 4467.268991: grab_cache_page_write_begin <-ext3_write_begin
> gconfd-2-2696 [000] 4467.268992: grab_cache_page_write_begin: page= (null) mapping=ffff8800676a9460 index=11
> gconfd-2-2696 [000] 4467.269005: grab_cache_page_write_begin <-ext3_write_begin
>
> Which shows that a lot of calls from ext3_write_begin will result in
> the page returned by "find_lock_page" will be NULL.
>
> Cc: Nick Piggin <[email protected]>

Looks good,

Acked-by: Nick Piggin <[email protected]>