提交 c5e3b83e 编写于 作者: P Pekka Enberg 提交者: Linus Torvalds

[PATCH] mm: use kmem_cache_zalloc

Convert mm/ to use the new kmem_cache_zalloc allocator.
Signed-off-by: NPekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 40c07ae8
...@@ -1040,12 +1040,11 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, ...@@ -1040,12 +1040,11 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
* specific mapper. the address has already been validated, but * specific mapper. the address has already been validated, but
* not unmapped, but the maps are removed from the list. * not unmapped, but the maps are removed from the list.
*/ */
vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
if (!vma) { if (!vma) {
error = -ENOMEM; error = -ENOMEM;
goto unacct_error; goto unacct_error;
} }
memset(vma, 0, sizeof(*vma));
vma->vm_mm = mm; vma->vm_mm = mm;
vma->vm_start = addr; vma->vm_start = addr;
...@@ -1896,12 +1895,11 @@ unsigned long do_brk(unsigned long addr, unsigned long len) ...@@ -1896,12 +1895,11 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
/* /*
* create a vma struct for an anonymous mapping * create a vma struct for an anonymous mapping
*/ */
vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
if (!vma) { if (!vma) {
vm_unacct_memory(len >> PAGE_SHIFT); vm_unacct_memory(len >> PAGE_SHIFT);
return -ENOMEM; return -ENOMEM;
} }
memset(vma, 0, sizeof(*vma));
vma->vm_mm = mm; vma->vm_mm = mm;
vma->vm_start = addr; vma->vm_start = addr;
......
...@@ -1990,10 +1990,9 @@ kmem_cache_create (const char *name, size_t size, size_t align, ...@@ -1990,10 +1990,9 @@ kmem_cache_create (const char *name, size_t size, size_t align,
align = ralign; align = ralign;
/* Get cache's description obj. */ /* Get cache's description obj. */
cachep = kmem_cache_alloc(&cache_cache, SLAB_KERNEL); cachep = kmem_cache_zalloc(&cache_cache, SLAB_KERNEL);
if (!cachep) if (!cachep)
goto oops; goto oops;
memset(cachep, 0, sizeof(struct kmem_cache));
#if DEBUG #if DEBUG
cachep->obj_size = size; cachep->obj_size = size;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册