linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH prototype] [8/8] Add mmap_full_slurp support
Date: Tue, 18 Mar 2008 02:09:42 +0100 (CET)	[thread overview]
Message-ID: <20080318010942.64C241B41E1@basil.firstfloor.org> (raw)
In-Reply-To: <20080318209.039112899@firstfloor.org>

This is the non-subtle brother of pbitmaps. Instead of only prefetching
the pages used last time always prefetch complete mmap areas
(subject to the max_ra_chunk limits)

Main advantage is that it works for shared libraries too (but
the prefetching is currently done for all file backed mmaps, 
not just executable mappings)

Disadvantage is that uses far more memory and does a lot of 
unnecessary work.

Still is faster in some circumstances.

Experimental.  Mainly added for comparison. Off by default. 
Probably not a good idea.  

I'm more including it for easier experimentation.

Signed-off-by: Andi Kleen <andi@firstfloor.org>

---
 include/linux/mm.h |    2 ++
 kernel/sysctl.c    |   10 ++++++++++
 mm/mmap.c          |   10 ++++++++++
 3 files changed, 22 insertions(+)

Index: linux/mm/mmap.c
===================================================================
--- linux.orig/mm/mmap.c
+++ linux/mm/mmap.c
@@ -40,6 +40,8 @@
 #define arch_rebalance_pgtables(addr, len)		(addr)
 #endif
 
+int mmap_full_slurp __read_mostly;
+
 static void unmap_region(struct mm_struct *mm,
 		struct vm_area_struct *vma, struct vm_area_struct *prev,
 		unsigned long start, unsigned long end);
@@ -2023,6 +2025,14 @@ out:
 		mm->locked_vm += len >> PAGE_SHIFT;
 		make_pages_present(addr, addr + len);
 	}
+	if (vma->vm_file && mmap_full_slurp) {
+		up_write(&mm->mmap_sem);
+		force_page_cache_readahead(vma->vm_file->f_mapping,
+					   vma->vm_file,
+					   vma->vm_pgoff,
+					   max_sane_readahead(vma_pages(vma)));
+		down_write(&mm->mmap_sem);
+	}
 	return addr;
 }
 
Index: linux/include/linux/mm.h
===================================================================
--- linux.orig/include/linux/mm.h
+++ linux/include/linux/mm.h
@@ -1077,6 +1077,8 @@ extern int do_munmap(struct mm_struct *,
 
 extern unsigned long do_brk(unsigned long, unsigned long);
 
+extern int mmap_full_slurp;
+
 /* filemap.c */
 extern unsigned long page_unuse(struct page *);
 extern void truncate_inode_pages(struct address_space *, loff_t);
Index: linux/kernel/sysctl.c
===================================================================
--- linux.orig/kernel/sysctl.c
+++ linux/kernel/sysctl.c
@@ -909,6 +909,16 @@ static struct ctl_table vm_table[] = {
 		.extra2		= &one_hundred,
 	},
 	{
+		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "mmap_full_slurp",
+		.data		= &mmap_full_slurp,
+		.maxlen 	= sizeof(mmap_full_slurp),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+		.strategy	= &sysctl_intvec,
+		.extra1 	= &zero,
+	},
+	{
 		.procname	= "dirty_writeback_centisecs",
 		.data		= &dirty_writeback_interval,
 		.maxlen		= sizeof(dirty_writeback_interval),

--
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-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2008-03-18  1:09 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-18  1:09 [PATCH prototype] [0/8] Predictive bitmaps for ELF executables Andi Kleen
2008-03-18  1:09 ` [PATCH prototype] [1/8] Give ELF shdr types a name Andi Kleen
2008-03-18  1:09 ` [PATCH prototype] [2/8] Add support to override mmap exec write protection with O_FORCEWRITE Andi Kleen
2008-03-18  1:09 ` [PATCH prototype] [3/8] Make readahead max pinned value a sysctl Andi Kleen
2008-03-18  1:09 ` [PATCH prototype] [4/8] Add readahead function to read-ahead based on a bitmap Andi Kleen
2008-03-18  1:09 ` [PATCH prototype] [5/8] Add ELF constants for pbitmaps Andi Kleen
2008-03-18  1:09 ` [PATCH prototype] [6/8] Core predictive bitmap engine Andi Kleen
2008-03-18  1:09 ` [PATCH prototype] [7/8] Add the sysctls to control pbitmaps Andi Kleen
2008-03-18  1:09 ` Andi Kleen [this message]
2008-03-18  7:36 ` [PATCH prototype] [0/8] Predictive bitmaps for ELF executables Andrew Morton
2008-03-18 14:18   ` Andi Kleen
2008-03-18 16:57     ` Andrew Morton
2008-03-18 17:20       ` Andi Kleen
2008-03-18 17:44         ` Andrew Morton
2008-03-19  8:32           ` Andi Kleen
2008-03-19  9:04             ` Andrew Morton
2008-03-19 22:45               ` Ulrich Drepper
2008-03-19 23:12                 ` Andrew Morton
2008-03-20  0:09                   ` David Miller, Andrew Morton
2008-03-20  9:00                 ` Andi Kleen
2008-03-21 17:15                   ` Ulrich Drepper
2008-03-21 17:26                     ` Andi Kleen
2008-03-22  4:36                       ` Ulrich Drepper
2008-03-22  7:17                         ` Andi Kleen
2008-03-22  7:24                           ` Nicholas Miell
2008-03-22  9:10                             ` Andi Kleen
2008-03-22 10:16                               ` Nicholas Miell
2008-03-22 14:29                                 ` Andi Kleen
2008-03-23 13:25                                   ` Pavel Machek
2008-03-23 17:08                                     ` Andi Kleen
2008-03-24 16:24                                       ` Pavel Machek
2008-03-24  4:20                               ` Ulrich Drepper
2008-03-24  5:16                                 ` Nicholas Miell
2008-03-24  5:26                                   ` Andi Kleen
2008-03-24 19:42                                   ` Ulrich Drepper
2008-03-24 21:47                                     ` Nicholas Miell
2008-03-25  7:54                                     ` Andi Kleen
2008-03-26 18:15                                       ` Ulrich Drepper
2008-03-26 18:54                                         ` Andi Kleen
2008-03-22  4:38                       ` Ulrich Drepper
2008-03-20  0:15               ` Diego Calleja

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=20080318010942.64C241B41E1@basil.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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