1. 07 4月, 2009 2 次提交
    • R
      nilfs2: fix problems of memory allocation in ioctl · 3358b4aa
      Ryusuke Konishi 提交于
      This is another patch for fixing the following problems of a memory
      copy function in nilfs2 ioctl:
      
      (1) It tries to allocate 128KB size of memory even for small objects.
      
      (2) Though the function repeatedly tries large memory allocations
          while reducing the size, GFP_NOWAIT flag is not specified.
          This increases the possibility of system memory shortage.
      
      (3) During the retries of (2), verbose warnings are printed
          because _GFP_NOWARN flag is not used for the kmalloc calls.
      
      The first patch was still doing large allocations by kmalloc which are
      repeatedly tried while reducing the size.
      
      Andi Kleen told me that using copy_from_user for large memory is not
      good from the viewpoint of preempt latency:
      
       On Fri, 12 Dec 2008 21:24:11 +0100, Andi Kleen <andi@firstfloor.org> wrote:
       > > In the current interface, each data item is copied twice: one is to
       > > the allocated memory from user space (via copy_from_user), and another
       >
       > For such large copies it is better to use multiple smaller (e.g. 4K)
       > copy user, that gives better real time preempt latencies. Each cfu has a
       > cond_resched(), but only one, not multiple times in the inner loop.
      
      He also advised me that:
      
       On Sun, 14 Dec 2008 16:13:27 +0100, Andi Kleen <andi@firstfloor.org> wrote:
       > Better would be if you could go to PAGE_SIZE. order 0 allocations
       > are typically the fastest / least likely to stall.
       >
       > Also in this case it's a good idea to use __get_free_pages()
       > directly, kmalloc tends to be become less efficient at larger
       > sizes.
      
      For the function in question, the size of buffer memory can be reduced
      since the buffer is repeatedly used for a number of small objects.  On
      the other hand, it may incur large preempt latencies for larger buffer
      because a copy_from_user (and a copy_to_user) was applied only once
      each cycle.
      
      With that, this revision uses the order 0 allocations with
      __get_free_pages() to fix the original problems.
      
      Cc: Andi Kleen <andi@firstfloor.org>
      Signed-off-by: NRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3358b4aa
    • K
      nilfs2: ioctl operations · 7942b919
      Koji Sato 提交于
      This adds userland interface implemented with ioctl.
      Signed-off-by: NKoji Sato <sato.koji@lab.ntt.co.jp>
      Signed-off-by: NRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7942b919