public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add PAGE_CACHE_PAGES
@ 2002-08-15 20:33 Gilad Ben-Yossef
  2002-08-15 23:16 ` Hugh Dickins
  2002-08-19  3:56 ` Rusty Russell
  0 siblings, 2 replies; 4+ messages in thread
From: Gilad Ben-Yossef @ 2002-08-15 20:33 UTC (permalink / raw)
  To: Marcelo; +Cc: The Usual Suspects, Patch Trivia


This patch introduces PAGE_CACHE_PAGES which is the number of pages in a
page cache.

Why?

Thus spake mm/shmem.c:

  idx = (address - vma->vm_start) >> PAGE_CACHE_SHIFT;
  idx += vma->vm_pgoff;

But include/linux/mm.h says:

unsigned long vm_pgoff;         /* Offset (within vm_file) in PAGE_SIZE
                                   units, *not* PAGE_CACHE_SIZE */
and include/linux/pagemap.h adds:

 * The page cache can done in larger chunks than
 * one page, because it allows for more efficient
 * throughput (it can then be mapped into user
 * space in smaller chunks for same flexibility).
 *
 * Or rather, it _will_ be done in larger chunks.

I also found two other places in mm/filemap.c that treat vma->vm_pgoff
as counting in PAGE_CACHE_SIZE units.

This patch only makes sense if PAGE_CACHE_SIZE is a multiple of
PAGE_SIZE but it seems logical to me that they will continue to be so
even when they wont be equel as they are now.

Comments are welcome.

Gilad.



diff -Nur -X /home/gby/dontdiff linux-2.4.19/include/linux/pagemap.h linux/include/linux/pagemap.h
--- linux-2.4.19/include/linux/pagemap.h	Fri Jun 21 01:38:38 2002
+++ linux/include/linux/pagemap.h	Thu Aug 15 21:53:15 2002
@@ -27,6 +27,7 @@
 #define PAGE_CACHE_SIZE		PAGE_SIZE
 #define PAGE_CACHE_MASK		PAGE_MASK
 #define PAGE_CACHE_ALIGN(addr)	(((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK)
+#define PAGE_CACHE_PAGES         (PAGE_CACHE_SIZE / PAGE_SIZE)
 
 #define page_cache_get(x)	get_page(x)
 #define page_cache_release(x)	__free_page(x)
diff -Nur -X /home/gby/dontdiff linux-2.4.19/mm/filemap.c linux/mm/filemap.c
--- linux-2.4.19/mm/filemap.c	Thu Aug 15 21:31:38 2002
+++ linux/mm/filemap.c	Thu Aug 15 21:45:48 2002
@@ -1918,8 +1918,8 @@
 	struct page *page, **hash;
 	unsigned long size, pgoff, endoff;
 
-	pgoff = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) + area->vm_pgoff;
-	endoff = ((area->vm_end - area->vm_start) >> PAGE_CACHE_SHIFT) + area->vm_pgoff;
+	pgoff = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) + (area->vm_pgoff / PAGE_CACHE_PAGES);
+	endoff = ((area->vm_end - area->vm_start) >> PAGE_CACHE_SHIFT) + (area->vm_pgoff / PAGE_CACHE_PAGES);
 
 retry_all:
 	/*
diff -Nur -X /home/gby/dontdiff linux-2.4.19/mm/shmem.c linux/mm/shmem.c
--- linux-2.4.19/mm/shmem.c	Thu Aug 15 21:31:38 2002
+++ linux/mm/shmem.c	Thu Aug 15 21:41:21 2002
@@ -663,7 +663,7 @@
 	struct inode * inode = vma->vm_file->f_dentry->d_inode;
 
 	idx = (address - vma->vm_start) >> PAGE_CACHE_SHIFT;
-	idx += vma->vm_pgoff;
+	idx += (vma->vm_pgoff / PAGE_CACHE_PAGES);
 
 	if (shmem_getpage(inode, idx, &page))
 		return page;


-- 
Gilad Ben-Yossef <gilad@benyossef.com>
http://benyossef.com

"Money talks, bullshit walks and GNU awks."
  -- Shachar "Sun" Shemesh, debt collector for the GNU/Yakuza


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

end of thread, other threads:[~2002-08-19  8:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-15 20:33 [PATCH] Add PAGE_CACHE_PAGES Gilad Ben-Yossef
2002-08-15 23:16 ` Hugh Dickins
2002-08-19  3:56 ` Rusty Russell
2002-08-19  8:48   ` Gilad Ben-Yossef

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