linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: torvalds@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>, Mel Gorman <mel@skynet.ie>
Cc: William Lee Irwin III <wli@holomorphy.com>, David Chinner <dgc@sgi.com>
Cc: Jens Axboe <jens.axboe@oracle.com>, Badari Pulavarty <pbadari@gmail.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>,
	Fengguang Wu <fengguang.wu@gmail.com>
Cc: swin wang <wangswin@gmail.com>, totty.lu@gmail.com, hugh@veritas.com
Cc: joern@lazybastard.org
Subject: [27/41] Large page order operations, zeroing and flushing
Date: Mon, 10 Sep 2007 23:04:17 -0700	[thread overview]
Message-ID: <20070911060431.829995993@sgi.com> (raw)
In-Reply-To: 20070911060349.993975297@sgi.com

[-- Attachment #1: 0027-Compound-page-zeroing-and-flushing.patch --]
[-- Type: text/plain, Size: 5959 bytes --]

We may have to zero and flush higher order pages. Implement
clear_mapping_page and flush_mapping_page to do that job. Replace
the flushing and clearing at some key locations for the pagecache.

In some places it is necesssary to determine the page order in use
from the page struct since no mapping is available. Add a series of
page_cache_page_xx functions:

page_cache_head(page)		-> Determine head page from a tail page
page_cache_base_pages(page)		-> Number of base pages of a page
page_cache_page_order(page)	-> Determine page order of a page
page_cache_page_size(page)	-> Determine page size of a page
page_cache_page_shift(page)	-> Determine page shif of a page

Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
 fs/libfs.c              |    4 +--
 fs/reiserfs/file.c      |    2 -
 include/linux/pagemap.h |   58 +++++++++++++++++++++++++++++++++++++++++++++---
 mm/filemap.c            |    4 +--
 mm/filemap_xip.c        |    4 +--
 5 files changed, 62 insertions(+), 10 deletions(-)

Index: linux-2.6/include/linux/pagemap.h
===================================================================
--- linux-2.6.orig/include/linux/pagemap.h	2007-09-10 22:20:33.000000000 -0700
+++ linux-2.6/include/linux/pagemap.h	2007-09-10 22:37:25.000000000 -0700
@@ -91,6 +91,31 @@ static inline unsigned int page_cache_of
 	return pos & ~PAGE_MASK;
 }
 
+static inline struct page *page_cache_head(struct page *page)
+{
+	return page;
+}
+
+static inline int page_cache_base_pages(struct page *page)
+{
+	return 1;
+}
+
+static inline unsigned long page_cache_page_order(struct page *page)
+{
+	return 0;
+}
+
+static inline unsigned long page_cache_page_size(struct page *page)
+{
+	return PAGE_SIZE;
+}
+
+static inline unsigned long page_cache_page_shift(struct page *page)
+{
+	return PAGE_SHIFT;
+}
+
 static inline pgoff_t page_cache_index(struct address_space *a,
 		loff_t pos)
 {
@@ -263,6 +288,33 @@ static inline void wait_on_page_writebac
 extern void end_page_writeback(struct page *page);
 
 /*
+ * Clear a higher order page
+ */
+static inline void clear_mapping_page(struct page *page)
+{
+	int nr_pages = page_cache_base_pages(page);
+	int i;
+
+	for (i = 0; i < nr_pages; i++)
+		clear_highpage(page + i);
+}
+
+/*
+ * Primitive support for flushing higher order pages.
+ *
+ * A bit stupid: On many platforms flushing the first page
+ * will flush any TLB starting there
+ */
+static inline void flush_mapping_page(struct page *page)
+{
+	int nr_pages = page_cache_base_pages(page);
+	int i;
+
+	for (i = 0; i < nr_pages; i++)
+		flush_dcache_page(page + i);
+}
+
+/*
  * Zeroing of segments of a page
  */
 static inline void zero_user_segments(struct page *page,
@@ -271,8 +323,8 @@ static inline void zero_user_segments(st
 {
 	void *kaddr = kmap_atomic(page, KM_USER0);
 
-	BUG_ON(end1 > PAGE_SIZE ||
-		end2 > PAGE_SIZE);
+	BUG_ON(end1 > page_cache_page_size(page) ||
+		end2 > page_cache_page_size(page));
 
 	if (end1 > start1)
 		memset(kaddr + start1, 0, end1 - start1);
@@ -281,7 +333,7 @@ static inline void zero_user_segments(st
 		memset(kaddr + start2, 0, end2 - start2);
 
 	kunmap_atomic(kaddr, KM_USER0);
-	flush_dcache_page(page);
+	flush_mapping_page(page);
 }
 
 static inline void zero_user_segment(struct page *page,
Index: linux-2.6/fs/libfs.c
===================================================================
--- linux-2.6.orig/fs/libfs.c	2007-09-10 22:20:33.000000000 -0700
+++ linux-2.6/fs/libfs.c	2007-09-10 22:37:05.000000000 -0700
@@ -330,8 +330,8 @@ int simple_rename(struct inode *old_dir,
 
 int simple_readpage(struct file *file, struct page *page)
 {
-	clear_highpage(page);
-	flush_dcache_page(page);
+	clear_mapping_page(page);
+	flush_mapping_page(page);
 	SetPageUptodate(page);
 	unlock_page(page);
 	return 0;
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c	2007-09-10 22:20:33.000000000 -0700
+++ linux-2.6/mm/filemap.c	2007-09-10 22:37:17.000000000 -0700
@@ -941,7 +941,7 @@ page_ok:
 		 * before reading the page on the kernel side.
 		 */
 		if (mapping_writably_mapped(mapping))
-			flush_dcache_page(page);
+			flush_mapping_page(page);
 
 		/*
 		 * When a sequential read accesses a page several times,
@@ -1932,7 +1932,7 @@ generic_file_buffered_write(struct kiocb
 		else
 			copied = filemap_copy_from_user_iovec(page, offset,
 						cur_iov, iov_base, bytes);
-		flush_dcache_page(page);
+		flush_mapping_page(page);
 		status = a_ops->commit_write(file, page, offset, offset+bytes);
 		if (status == AOP_TRUNCATED_PAGE) {
 			page_cache_release(page);
Index: linux-2.6/mm/filemap_xip.c
===================================================================
--- linux-2.6.orig/mm/filemap_xip.c	2007-09-10 22:20:33.000000000 -0700
+++ linux-2.6/mm/filemap_xip.c	2007-09-10 22:23:32.000000000 -0700
@@ -104,7 +104,7 @@ do_xip_mapping_read(struct address_space
 		 * before reading the page on the kernel side.
 		 */
 		if (mapping_writably_mapped(mapping))
-			flush_dcache_page(page);
+			flush_mapping_page(page);
 
 		/*
 		 * Ok, we have the page, so now we can copy it to user space...
@@ -320,7 +320,7 @@ __xip_file_write(struct file *filp, cons
 		}
 
 		copied = filemap_copy_from_user(page, offset, buf, bytes);
-		flush_dcache_page(page);
+		flush_mapping_page(page);
 		if (likely(copied > 0)) {
 			status = copied;
 
Index: linux-2.6/fs/reiserfs/file.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/file.c	2007-09-10 22:20:33.000000000 -0700
+++ linux-2.6/fs/reiserfs/file.c	2007-09-10 22:23:32.000000000 -0700
@@ -748,7 +748,7 @@ static int reiserfs_copy_from_user_to_fi
 		page_fault = __copy_from_user(page_address(page) + offset, buf, count);
 					// Copy the data.
 		/* Flush processor's dcache for this page */
-		flush_dcache_page(page);
+		flush_mapping_page(page);
 		kunmap(page);
 		buf += count;
 		write_bytes -= count;

-- 

  parent reply	other threads:[~2007-09-11  6:04 UTC|newest]

Thread overview: 187+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-11  6:03 [00/41] Large Blocksize Support V7 (adds memmap support) Christoph Lameter
2007-09-10 18:52 ` Nick Piggin
2007-09-11 12:05   ` Andrea Arcangeli
2007-09-11 20:03     ` Christoph Lameter
2007-09-11 12:12   ` Jörn Engel
2007-09-10 21:13     ` Nick Piggin
2007-09-11 16:02       ` Goswin von Brederlow
2007-09-11 20:07     ` Christoph Lameter
2007-09-11 20:29       ` Jörn Engel
2007-09-11 20:41         ` Christoph Lameter
2007-09-11 23:26           ` Andrea Arcangeli
2007-09-12  0:04             ` Christoph Lameter
2007-09-12  8:20               ` Andrea Arcangeli
2007-09-15  8:44     ` Andrew Morton
2007-09-15 12:14       ` Goswin von Brederlow
2007-09-15 15:51         ` Andrea Arcangeli
2007-09-15 20:14           ` Goswin von Brederlow
2007-09-15 22:30             ` Andrea Arcangeli
2007-09-16 13:54               ` Goswin von Brederlow
2007-09-16 15:08                 ` Andrea Arcangeli
2007-09-16 21:08                   ` Mel Gorman
2007-09-16 22:48                     ` Goswin von Brederlow
2007-09-17  9:30                       ` Mel Gorman
2007-09-16 17:46               ` Jörn Engel
2007-09-16 18:15                 ` Linus Torvalds
2007-09-16 18:21                   ` Jörn Engel
2007-09-16 18:44                     ` Linus Torvalds
2007-09-16 22:51                       ` Goswin von Brederlow
2007-09-23 17:44                       ` Jörn Engel
2007-09-16 22:06                 ` Goswin von Brederlow
2007-09-16 22:40                   ` Jörn Engel
2007-09-16 18:15           ` Mel Gorman
2007-09-16 18:50             ` Andrea Arcangeli
2007-09-16 20:54               ` Mel Gorman
2007-09-16 21:31                 ` Andrea Arcangeli
2007-09-17 10:13                   ` Mel Gorman
2007-09-23  5:50                     ` Goswin von Brederlow
2007-09-16 22:56               ` Goswin von Brederlow
2007-09-18 19:31                 ` Andrea Arcangeli
2007-09-23  6:56                   ` Goswin von Brederlow
2007-09-24 15:39                     ` Andrea Arcangeli
2007-09-16 18:13         ` Mel Gorman
2007-09-16  9:03           ` Nick Piggin
2007-09-17 22:00             ` Christoph Lameter
2007-09-18  0:11               ` Nick Piggin
2007-09-18 20:36                 ` Christoph Lameter
2007-09-18 10:00               ` Mel Gorman
2007-09-18 10:49                 ` Jörn Engel
2007-09-18 12:31                 ` David Chinner
2007-09-16 21:58           ` Goswin von Brederlow
2007-09-17 10:03             ` Mel Gorman
2007-09-23  6:22               ` Goswin von Brederlow
2007-09-24 12:32                 ` Kyle Moffett
2007-09-16 17:53       ` Jörn Engel
2007-09-16 21:31         ` Mel Gorman
2007-09-17 22:03         ` Christoph Lameter
2007-09-11 15:36   ` Mel Gorman
2007-09-11  1:44     ` Nick Piggin
2007-09-11 20:11       ` Christoph Lameter
2007-09-11  4:53         ` Nick Piggin
2007-09-11 20:42           ` Christoph Lameter
2007-09-11  5:30             ` Nick Piggin
2007-09-11 21:41               ` Christoph Lameter
2007-09-11  6:06                 ` Nick Piggin
2007-09-11 21:52                   ` Christoph Lameter
2007-09-11 18:07                     ` Nick Piggin
2007-09-12 23:06                       ` Christoph Lameter
2007-09-13 20:51                         ` Nick Piggin
2007-09-14 17:52                           ` Christoph Lameter
2007-09-16  8:22                             ` Nick Piggin
2007-09-17 22:05                               ` Christoph Lameter
2007-09-18  0:10                                 ` Nick Piggin
2007-09-18 20:42                                   ` Christoph Lameter
2007-09-17 11:10                         ` Bernd Schmidt
2007-09-17 22:10                           ` Christoph Lameter
2007-09-14 16:10                       ` Goswin von Brederlow
2007-09-14 17:42                         ` Mel Gorman
2007-09-15  0:31                           ` Goswin von Brederlow
2007-09-16 21:16                             ` Mel Gorman
2007-09-16 22:38                               ` Goswin von Brederlow
2007-09-17  8:57                                 ` Mel Gorman
2007-09-23  6:49                                   ` Goswin von Brederlow
2007-09-11 20:53       ` Mel Gorman
2007-09-11  6:00         ` Nick Piggin
2007-09-11 21:48           ` Christoph Lameter
2007-09-11  6:17             ` Nick Piggin
2007-09-12  0:00               ` Christoph Lameter
2007-09-12  2:46                 ` Nick Piggin
2007-09-12 23:17                   ` Christoph Lameter
2007-09-13  9:40                     ` Mel Gorman
2007-09-14  2:38                       ` Christoph Lameter
2007-09-13 21:20                     ` Nick Piggin
2007-09-14 18:08                       ` Christoph Lameter
2007-09-14 18:15                         ` Christoph Lameter
2007-09-15  0:33                           ` Goswin von Brederlow
2007-09-16  8:53                         ` Nick Piggin
2007-09-17 22:21                           ` Christoph Lameter
2007-09-18  1:16                             ` Nick Piggin
2007-09-18 18:30                               ` Linus Torvalds
2007-09-18 17:53                                 ` Nick Piggin
2007-09-18 19:18                                 ` Andrea Arcangeli
2007-09-18 19:44                                   ` Linus Torvalds
2007-09-19  0:58                                     ` Nathan Scott
2007-09-19  1:06                                       ` Linus Torvalds
2007-09-19  2:45                                         ` Nathan Scott
2007-09-19  5:09                                         ` David Chinner
2007-09-19  9:41                                           ` Alex Tomas
2007-09-19 14:04                                           ` Andrea Arcangeli
2007-09-20  1:38                                             ` David Chinner
2007-09-20 14:54                                               ` Andrea Arcangeli
2007-09-20 18:11                                                 ` Christoph Lameter
2007-09-20 18:07                                               ` Christoph Lameter
2007-09-21 20:41                                                 ` Hugh Dickins
2007-09-24 21:13                                                   ` Christoph Lameter
2007-09-28  2:46                                               ` Nick Piggin
2007-09-19  3:41                                     ` Rene Herman
2007-09-19  3:50                                       ` Linus Torvalds
2007-09-19  4:26                                         ` Rene Herman
2007-09-19  4:33                                           ` Linus Torvalds
2007-09-19  4:56                                             ` Rene Herman
2007-09-11 21:54             ` Mel Gorman
2007-09-12 14:29             ` Martin J. Bligh
2007-09-12  1:49           ` David Chinner
2007-09-11 15:27             ` Nick Piggin
2007-09-13  1:49               ` David Chinner
2007-09-12 17:23                 ` Nick Piggin
2007-09-13 13:03                   ` David Chinner
2007-09-13  2:01                     ` Nick Piggin
2007-09-13 20:48                       ` Nick Piggin
2007-09-17  4:07                         ` David Chinner
2007-09-16 21:13                           ` Nick Piggin
2007-09-12  2:01             ` Nick Piggin
2007-09-11 21:35         ` Christoph Lameter
2007-09-11 16:47     ` Andrea Arcangeli
2007-09-11 18:31       ` Mel Gorman
2007-09-11  2:26         ` Nick Piggin
2007-09-11 18:25           ` Maxim Levitsky
2007-09-11  3:05             ` Nick Piggin
2007-09-11 21:03           ` Mel Gorman
2007-09-11 19:20         ` Andrea Arcangeli
2007-09-11 20:19           ` Jörn Engel
2007-09-11 20:13       ` Christoph Lameter
2007-09-11 20:01   ` Christoph Lameter
2007-09-11  4:43     ` Nick Piggin
2007-09-11  5:17     ` Nick Piggin
2007-09-11 21:27       ` Mel Gorman
2007-09-11  6:03 ` [01/41] Pagecache zeroing: zero_user_segment, zero_user_segments and zero_user Christoph Lameter
2007-09-11  6:03 ` [02/41] Define functions for page cache handling Christoph Lameter
2007-09-11  6:03 ` [03/41] Use page_cache_xxx functions in mm/filemap.c Christoph Lameter
2007-09-11  6:03 ` [04/41] Use page_cache_xxx in mm/page-writeback.c Christoph Lameter
2007-09-11  6:03 ` [05/41] Use page_cache_xxx in mm/truncate.c Christoph Lameter
2007-09-11  6:03 ` [06/41] Use page_cache_xxx in mm/rmap.c Christoph Lameter
2007-09-11  6:03 ` [07/41] Use page_cache_xxx in mm/filemap_xip.c Christoph Lameter
2007-09-11  6:03 ` [08/41] Use page_cache_xxx in mm/migrate.c Christoph Lameter
2007-09-11  6:03 ` [09/41] Use page_cache_xxx in fs/libfs.c Christoph Lameter
2007-09-11  6:04 ` [10/41] Use page_cache_xxx in fs/sync Christoph Lameter
2007-09-11  6:04 ` [11/41] Use page_cache_xxx in fs/buffer.c Christoph Lameter
2007-09-11  6:04 ` [12/41] Use page_cache_xxx in mm/mpage.c Christoph Lameter
2007-09-11  6:04 ` [13/41] Use page_cache_xxx in mm/fadvise.c Christoph Lameter
2007-09-11  6:04 ` [14/41] Use page_cache_xxx in fs/splice.c Christoph Lameter
2007-09-11  6:04 ` [15/41] Use page_cache_xxx in ext2 Christoph Lameter
2007-09-11  6:04 ` [16/41] Use page_cache_xxx in fs/ext3 Christoph Lameter
2007-09-11  6:04 ` [17/41] Use page_cache_xxx in fs/ext4 Christoph Lameter
2007-09-11  6:04 ` [18/41] Use page_cache_xxx in fs/reiserfs Christoph Lameter
2007-09-11  6:04 ` [19/41] Use page_cache_xxx for fs/xfs Christoph Lameter
2007-09-11  6:04 ` [20/41] Use page_cache_xxx in drivers/block/rd.c Christoph Lameter
2007-09-11  6:04 ` [21/41] compound pages: Better PageHead/PageTail handling Christoph Lameter
2007-09-11  6:04 ` [22/41] compound pages: Add new support functions Christoph Lameter
2007-09-11  6:04 ` [23/41] compound pages: vmstat support Christoph Lameter
2007-09-11  6:04 ` [24/41] compound pages: Use new compound vmstat functions in SLUB Christoph Lameter
2007-09-11  6:04 ` [25/41] compound pages: Allow use of get_page_unless_zero with compound pages Christoph Lameter
2007-09-11  6:04 ` [26/41] compound pages: Allow freeing of compound pages via pagevec Christoph Lameter
2007-09-11  6:04 ` Christoph Lameter [this message]
2007-09-11  6:04 ` [28/41] Futex: Fix PAGE SIZE assumption Christoph Lameter
2007-09-11  6:04 ` [29/41] Fix up reclaim counters Christoph Lameter
2007-09-11  6:04 ` [30/41] Add VM_BUG_ONs to check for correct page order Christoph Lameter
2007-09-11  6:04 ` [31/41] Large Blocksize: Core piece Christoph Lameter
2007-09-11  6:04 ` [32/41] Readahead changes to support large blocksize Christoph Lameter
2007-09-11  6:04 ` [33/41] Large blocksize support in ramfs Christoph Lameter
2007-09-11  6:04 ` [34/41] Large blocksize support for XFS Christoph Lameter
2007-09-11  6:04 ` [35/41] Reiserfs: Fix up mapping_set_gfp_mask() Christoph Lameter
2007-09-11  6:04 ` [36/41] 64k block size support for Ext2/3/4 Christoph Lameter
2007-09-11  6:04 ` [37/41] ext2: fix rec_len overflow for 64KB block size Christoph Lameter
2007-09-11  6:04 ` [38/41] ext3: fix rec_len overflow with " Christoph Lameter
2007-09-11  6:04 ` [39/41] ext4: fix rec_len overflow for " Christoph Lameter
2007-09-11  6:04 ` [40/41] Do not use f_mapping in simple_prepare_write() Christoph Lameter
2007-09-11  6:04 ` [41/41] Mmap support using pte PAGE_SIZE mappings Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070911060431.829995993@sgi.com \
    --to=clameter@sgi.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).