mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gilad Ben-Yossef <gilad@benyossef.com>
To: Marcelo <marcelo@conectiva.com.br>
Cc: The Usual Suspects <linux-kernel@vger.kernel.org>,
	Patch Trivia <trivial@rustcorp.com.au>
Subject: [PATCH] Add PAGE_CACHE_PAGES
Date: 15 Aug 2002 23:33:00 +0300	[thread overview]
Message-ID: <1029443580.2508.18.camel@gby.benyossef.com> (raw)


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


             reply	other threads:[~2002-08-15 20:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-15 20:33 Gilad Ben-Yossef [this message]
2002-08-15 23:16 ` Hugh Dickins
2002-08-19  3:56 ` Rusty Russell
2002-08-19  8:48   ` Gilad Ben-Yossef

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=1029443580.2508.18.camel@gby.benyossef.com \
    --to=gilad@benyossef.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=trivial@rustcorp.com.au \
    /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

all inboxes | Powered by JetHome®