linux/fs/nilfs2
Ryusuke Konishi 3358b4aaa8 nilfs2: fix problems of memory allocation in ioctl
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: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-04-07 08:31:16 -07:00
..
alloc.c nilfs2: persistent object allocator 2009-04-07 08:31:13 -07:00
alloc.h nilfs2: persistent object allocator 2009-04-07 08:31:13 -07:00
bmap_union.h nilfs2: integrated block mapping 2009-04-07 08:31:13 -07:00
bmap.c nilfs2: integrated block mapping 2009-04-07 08:31:13 -07:00
bmap.h nilfs2: integrated block mapping 2009-04-07 08:31:13 -07:00
btnode.c nilfs2: B-tree node cache 2009-04-07 08:31:13 -07:00
btnode.h nilfs2: B-tree node cache 2009-04-07 08:31:13 -07:00
btree.c nilfs2: B-tree based block mapping 2009-04-07 08:31:13 -07:00
btree.h nilfs2: B-tree based block mapping 2009-04-07 08:31:13 -07:00
cpfile.c nilfs2: segment usage file 2009-04-07 08:31:14 -07:00
cpfile.h nilfs2: checkpoint file 2009-04-07 08:31:14 -07:00
dat.c nilfs2: disk address translator 2009-04-07 08:31:14 -07:00
dat.h nilfs2: disk address translator 2009-04-07 08:31:14 -07:00
dir.c nilfs2: directory entry operations 2009-04-07 08:31:15 -07:00
direct.c nilfs2: direct block mapping 2009-04-07 08:31:13 -07:00
direct.h nilfs2: direct block mapping 2009-04-07 08:31:13 -07:00
file.c nilfs2: fix missed-sync issue for do_sync_mapping_range() 2009-04-07 08:31:15 -07:00
gcdat.c nilfs2: another dat for garbage collection 2009-04-07 08:31:16 -07:00
gcinode.c nilfs2: block cache for garbage collection 2009-04-07 08:31:16 -07:00
ifile.c nilfs2: inode map file 2009-04-07 08:31:14 -07:00
ifile.h nilfs2: inode map file 2009-04-07 08:31:14 -07:00
inode.c nilfs2: fix missed-sync issue for do_sync_mapping_range() 2009-04-07 08:31:15 -07:00
ioctl.c nilfs2: fix problems of memory allocation in ioctl 2009-04-07 08:31:16 -07:00
Makefile nilfs2: update makefile and Kconfig 2009-04-07 08:31:16 -07:00
mdt.c nilfs2: meta data file 2009-04-07 08:31:13 -07:00
mdt.h nilfs2: meta data file 2009-04-07 08:31:13 -07:00
namei.c nilfs2: pathname operations 2009-04-07 08:31:15 -07:00
nilfs.h
page.c nilfs2: buffer and page operations 2009-04-07 08:31:13 -07:00
page.h nilfs2: buffer and page operations 2009-04-07 08:31:13 -07:00
recovery.c nilfs2: recovery functions 2009-04-07 08:31:16 -07:00
sb.h
segbuf.c nilfs2: segment buffer 2009-04-07 08:31:15 -07:00
segbuf.h nilfs2: segment buffer 2009-04-07 08:31:15 -07:00
seglist.h nilfs2: segment constructor 2009-04-07 08:31:15 -07:00
segment.c nilfs2: fix missed-sync issue for do_sync_mapping_range() 2009-04-07 08:31:15 -07:00
segment.h nilfs2: fix missed-sync issue for do_sync_mapping_range() 2009-04-07 08:31:15 -07:00
sufile.c nilfs2: segment usage file 2009-04-07 08:31:14 -07:00
sufile.h nilfs2: segment usage file 2009-04-07 08:31:14 -07:00
super.c nilfs2: super block operations 2009-04-07 08:31:15 -07:00
the_nilfs.c nilfs2: operations for the_nilfs core object 2009-04-07 08:31:15 -07:00
the_nilfs.h