Skip to contentSkip to conversation

Read-ahead code

DISCUSSION Luciano A. Stertz 1 participant 2 messages Jul 27, 2004 Memory management

lore
Share & tools
lore
#0 lore raw

I guess I found a bug in the readahead code, kernel 2.6.7.
In filemap_nopage, if the memory area is not marked as sequential
(VM_SEQ_READ isn't set) and the page is not in the page cache, the following code is executed:

1 ra_pages = max_sane_readahead(file->f_ra.ra_pages);
2 if (ra_pages) {
3 long start;
4
5 start = pgoff - ra_pages / 2;
6 if (pgoff < 0)
7 pgoff = 0;
8 do_page_cache_readahead(mapping, file, pgoff, ra_pages);
9 }

Seems that the author wanted to read ra_pages around pgoff. Shouldn't
it be using 'start' instead of 'pgoff' in lines 6 to 8?!? Start is calculated and never used. Instead of reading pages from start to pgoff + ra_pages/2, it's reading ra_pages from pgoff.

Luciano

Signature · 10 lines
Luciano A. Stertz
[email protected]
T&T Engenheiros Associados Ltda
http://www.tteng.com.br-
Fone/Fax (51) 3224 8425
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

Oops, it's already fixed in 2.6.8-rc2, forget it.

Luciano

Quoted 19 lines · Luciano A. Stertz

I guess I found a bug in the readahead code, kernel 2.6.7.
In filemap_nopage, if the memory area is not marked as sequential
(VM_SEQ_READ isn't set) and the page is not in the page cache, the following code is executed:

1 ra_pages = max_sane_readahead(file->f_ra.ra_pages);
2 if (ra_pages) {
3 long start;
4
5 start = pgoff - ra_pages / 2;
6 if (pgoff < 0)
7 pgoff = 0;
8 do_page_cache_readahead(mapping, file, pgoff, ra_pages);
9 }

Seems that the author wanted to read ra_pages around pgoff.
Shouldn't it be using 'start' instead of 'pgoff' in lines 6 to 8?!? Start is calculated and never used. Instead of reading pages from start to pgoff + ra_pages/2, it's reading ra_pages from pgoff.

Luciano

Signature · 10 lines
Luciano A. Stertz
[email protected]
T&T Engenheiros Associados Ltda
http://www.tteng.com.br
Fone/Fax (51) 3224 8425
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>