linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* possible brw_page optimization
@ 2000-01-21 20:21 Chuck Lever
  2000-01-26 13:01 ` Stephen C. Tweedie
  0 siblings, 1 reply; 6+ messages in thread
From: Chuck Lever @ 2000-01-21 20:21 UTC (permalink / raw)
  To: linux-mm

i've been exploring swap compaction and encryption, and found that
brw_page wants to break pages into buffer-sized pieces in order to
schedule I/O.  the logic wants to eliminate unnecessary I/O requests, so
it checks each buffer to see if it is up to date; it doesn't schedule
reads for buffers that are already up to date.  all buffers are scheduled
unconditionally during a write request.

for compaction or encryption, all buffers must be read in order to get the
whole page and decrypt or decompress it, so i'd like to make
brw_page(READ) read all buffers for a page unconditionally, just like
brw_page(WRITE).  at first, i thought a simple flag could request this
change in behavior.

however, looking at brw_page's callers, brw_page(READ) in 2.3.39+ is only
invoked on fresh pages, so i can't see where it's possible to not read all
the buffers for a page in brw_page.  seems like the following is a
potential common case optimization of brw_page, with no loss of
performance.

what issues am i missing?

int brw_page(int rw, struct page *page, kdev_t dev, int b[], int size)
{
	struct buffer_head *head, *bh, *arr[MAX_BUF_PER_PAGE];
	int block, nr = 0;

	/*
	 * We pretty much rely on the page lock for this, because
	 * create_page_buffers() might sleep.
	 */
	if (!page->buffers)
		create_page_buffers(rw, page, dev, b, size);

	head = page->buffers;
	bh = head;
	do {
		arr[nr++] = bh;
		atomic_inc(&bh->b_count);

		if (rw == WRITE ) {
			block = *(b++);
			if (!bh->b_blocknr)
				bh->b_blocknr = block;

			set_bit(BH_Uptodate, &bh->b_state);
			set_bit(BH_Dirty, &bh->b_state);
		}

		bh = bh->b_this_page;
	} while (bh != head);

	ll_rw_block(rw, nr, arr);
	if (rw == READ)
		++current->maj_flt;

	return 0;
}

	- Chuck Lever
--
corporate:	<chuckl@netscape.com>
personal:	<chucklever@netscape.net> or <cel@monkey.org>

The Linux Scalability project:
	http://www.citi.umich.edu/projects/linux-scalability/

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-01-27 19:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-21 20:21 possible brw_page optimization Chuck Lever
2000-01-26 13:01 ` Stephen C. Tweedie
2000-01-26 16:02   ` Chuck Lever
2000-01-26 23:24     ` Stephen C. Tweedie
2000-01-27 18:50       ` Chuck Lever
2000-01-27 19:52         ` Stephen C. Tweedie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox