1. 28 5月, 2010 2 次提交
  2. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  3. 17 1月, 2010 2 次提交
    • D
      nommu: fix shared mmap after truncate shrinkage problems · 7e660872
      David Howells 提交于
      Fix a problem in NOMMU mmap with ramfs whereby a shared mmap can happen
      over the end of a truncation.  The problem is that
      ramfs_nommu_check_mappings() checks that the reduced file size against the
      VMA tree, but not the vm_region tree.
      
      The following sequence of events can cause the problem:
      
      	fd = open("/tmp/x", O_RDWR|O_TRUNC|O_CREAT, 0600);
      	ftruncate(fd, 32 * 1024);
      	a = mmap(NULL, 32 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
      	b = mmap(NULL, 16 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
      	munmap(a, 32 * 1024);
      	ftruncate(fd, 16 * 1024);
      	c = mmap(NULL, 32 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
      
      Mapping 'a' creates a vm_region covering 32KB of the file.  Mapping 'b'
      sees that the vm_region from 'a' is covering the region it wants and so
      shares it, pinning it in memory.
      
      Mapping 'a' then goes away and the file is truncated to the end of VMA
      'b'.  However, the region allocated by 'a' is still in effect, and has
      _not_ been reduced.
      
      Mapping 'c' is then created, and because there's a vm_region covering the
      desired region, get_unmapped_area() is _not_ called to repeat the check,
      and the mapping is granted, even though the pages from the latter half of
      the mapping have been discarded.
      
      However:
      
      	d = mmap(NULL, 16 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
      
      Mapping 'd' should work, and should end up sharing the region allocated by
      'a'.
      
      To deal with this, we shrink the vm_region struct during the truncation,
      lest do_mmap_pgoff() take it as licence to share the full region
      automatically without calling the get_unmapped_area() file op again.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Cc: Greg Ungerer <gerg@snapgear.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7e660872
    • D
      nommu: fix race between ramfs truncation and shared mmap · 81759b5b
      David Howells 提交于
      Fix the race between the truncation of a ramfs file and an attempt to make
      a shared mmap of region of that file.
      
      The problem is that do_mmap_pgoff() calls f_op->get_unmapped_area() to
      verify that the file region is made of contiguous pages and to find its
      base address - but there isn't any locking to guarantee this region until
      vma_prio_tree_insert() is called by add_vma_to_mm().
      
      Note that moving the functionality into f_op->mmap() doesn't help as that
      is also called before vma_prio_tree_insert().
      
      Instead make ramfs_nommu_check_mappings() grab nommu_region_sem whilst it
      does its checks.  This means that this function will wait whilst mmaps
      take place.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Cc: Greg Ungerer <gerg@snapgear.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      81759b5b
  4. 18 12月, 2009 1 次提交
  5. 24 9月, 2009 1 次提交
  6. 30 7月, 2009 1 次提交
  7. 01 4月, 2009 1 次提交
  8. 26 3月, 2009 1 次提交
  9. 15 3月, 2009 2 次提交
  10. 08 1月, 2009 1 次提交
    • D
      NOMMU: Fix cleanup handling in ramfs_nommu_get_umapped_area() · 0e8f989a
      David Howells 提交于
      Fix cleanup handling in ramfs_nommu_get_umapped_area() by only freeing the
      number of pages that find_get_pages() said it had returned (nr) rather than
      attempting to free the number of pages we asked for (lpages) - thus avoiding
      the situation whereby put_page() may be handed NULL pointers if
      find_get_pages() returned fewer pages that were requested.
      
      Also avoid a warning about nr being uninitialised and the need for an
      if-statement in the cleanup path by using appropriate gotos.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      0e8f989a
  11. 20 10月, 2008 1 次提交
    • R
      vmscan: split LRU lists into anon & file sets · 4f98a2fe
      Rik van Riel 提交于
      Split the LRU lists in two, one set for pages that are backed by real file
      systems ("file") and one for pages that are backed by memory and swap
      ("anon").  The latter includes tmpfs.
      
      The advantage of doing this is that the VM will not have to scan over lots
      of anonymous pages (which we generally do not want to swap out), just to
      find the page cache pages that it should evict.
      
      This patch has the infrastructure and a basic policy to balance how much
      we scan the anon lists and how much we scan the file lists.  The big
      policy changes are in separate patches.
      
      [lee.schermerhorn@hp.com: collect lru meminfo statistics from correct offset]
      [kosaki.motohiro@jp.fujitsu.com: prevent incorrect oom under split_lru]
      [kosaki.motohiro@jp.fujitsu.com: fix pagevec_move_tail() doesn't treat unevictable page]
      [hugh@veritas.com: memcg swapbacked pages active]
      [hugh@veritas.com: splitlru: BDI_CAP_SWAP_BACKED]
      [akpm@linux-foundation.org: fix /proc/vmstat units]
      [nishimura@mxp.nes.nec.co.jp: memcg: fix handling of shmem migration]
      [kosaki.motohiro@jp.fujitsu.com: adjust Quicklists field of /proc/meminfo]
      [kosaki.motohiro@jp.fujitsu.com: fix style issue of get_scan_ratio()]
      Signed-off-by: NRik van Riel <riel@redhat.com>
      Signed-off-by: NLee Schermerhorn <Lee.Schermerhorn@hp.com>
      Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Signed-off-by: NHugh Dickins <hugh@veritas.com>
      Signed-off-by: NDaisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4f98a2fe
  12. 03 10月, 2008 1 次提交
  13. 04 7月, 2008 1 次提交
  14. 17 10月, 2007 1 次提交
  15. 01 8月, 2007 1 次提交
  16. 10 7月, 2007 1 次提交
  17. 08 6月, 2007 1 次提交
  18. 31 5月, 2007 1 次提交
  19. 09 5月, 2007 1 次提交
  20. 13 2月, 2007 1 次提交
  21. 12 2月, 2007 1 次提交
  22. 31 12月, 2006 1 次提交
  23. 09 12月, 2006 1 次提交
  24. 01 10月, 2006 1 次提交
  25. 11 7月, 2006 1 次提交
    • D
      [PATCH] NOMMU: Fix execution off of ramfs with mmap() · 21ff8216
      David Howells 提交于
      Fix execution through the FDPIC binfmt of programs stored on ramfs by
      preventing the ramfs mmap() returning successfully on a private mapping of
      a ramfs file.  This causes NOMMU mmap to make a copy of the mapped portion
      of the file and map that instead.
      
      This could be improved by granting direct mapping access to read-only
      private mappings for which the data is stored on a contiguous run of pages.
       However, this is only likely to be the case if the file was extended with
      truncate before being written.
      
      ramfs is left to map the file directly for shared mappings so that SYSV IPC
      and POSIX shared memory both still work.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Cc: Hugh Dickins <hugh@veritas.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      21ff8216
  26. 29 6月, 2006 1 次提交
  27. 29 3月, 2006 1 次提交
  28. 22 3月, 2006 1 次提交
  29. 07 1月, 2006 1 次提交
    • D
      [PATCH] NOMMU: Provide shared-writable mmap support on ramfs · 642fb4d1
      David Howells 提交于
      The attached patch makes ramfs support shared-writable mmaps by:
      
       (1) Attempting to perform a contiguous block allocation to the requested size
           when truncate attempts to increase the file from zero size, such as
           happens when:
      
      	fd = shm_open("/file/on/ramfs", ...):
      	ftruncate(fd, size_requested);
      	addr = mmap(NULL, subsize, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED,
      		    fd, offset);
      
       (2) Permitting any shared-writable mapping over any contiguous set of extant
           pages. get_unmapped_area() will return the address into the actual ramfs
           pages. The mapping may start anywhere and be of any size, but may not go
           over the end of file. Multiple mappings may overlap in any way.
      
       (3) Not permitting a file to be shrunk if it would truncate any shared
           mappings (private mappings are copied).
      
      Thus this patch provides support for POSIX shared memory on NOMMU kernels,
      with certain limitations such as there being a large enough block of pages
      available to support the allocation and it only working on directly mappable
      filesystems.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      642fb4d1