page cgroup: using vzalloc instead of vmalloc
Subsystems (4)
PATCH 1/4 page cgroup: using vzalloc instead of vmalloc
--- mm/page_cgroup.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
mm/page_cgroup.c +1 -2
@@ -513,11 +513,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) length =DIV_ROUND_UP (max_pages,SC_PER_PAGE ); array_size = length *sizeof (void *); - array =vmalloc (array_size); + array =vzalloc (array_size);if (!array) goto nomem; -memset (array,0 , array_size); ctrl = &swap_cgroup_ctrl[type];mutex_lock (&swap_cgroup_mutex); ctrl->length = length;
Signature · 9 lines
1.6.3.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/4 frontswap: using vzalloc instead of vmalloc
This patch also add checking whether alloc frontswap_map memory failed.
--- mm/swapfile.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
mm/swapfile.c +3 -3
@@ -2124,9 +2124,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) }/* frontswap enabled? set up bit-per-page map for frontswap */ if (frontswap_enabled) { - frontswap_map =vmalloc (maxpages /sizeof (long )); -if (frontswap_map) -memset (frontswap_map,0 , maxpages /sizeof (long )); + frontswap_map =vzalloc (maxpages /sizeof (long )); +if (!frontswap_map) + goto bad_swap; }if (p->bdev) {
Signature · 9 lines
1.6.3.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/4 sparse: using kzalloc to clean up code
This patch using kzalloc to clean up sparse_index_alloc() and __GFP_ZERO to clean up __kmalloc_section_memmap().
--- mm/sparse.c | 24 +++++++----------------- 1 files changed, 7 insertions(+), 17 deletions(-)
mm/sparse.c +7 -17
@@ -65,15 +65,12 @@ static struct mem_section noinline __init_refok *sparse_index_alloc(int nid)if (slab_is_available ()) {if (node_state (nid,N_HIGH_MEMORY )) - section =kmalloc_node (array_size,GFP_KERNEL , nid); + section =kzalloc_node (array_size,GFP_KERNEL , nid);else - section =kmalloc (array_size,GFP_KERNEL ); + section =kzalloc (array_size,GFP_KERNEL ); }else section =alloc_bootmem_node (NODE_DATA (nid), array_size); -if (section) -memset (section,0 , array_size); -return section; }
@@ -636,19 +633,12 @@ static struct page *__kmalloc_section_memmap(unsigned long nr_pages)struct page *page, *ret;unsigned long memmap_size =sizeof (struct page ) * nr_pages; - page =alloc_pages (GFP_KERNEL |__GFP_NOWARN,get_order (memmap_size)); + page =alloc_pages (GFP_KERNEL |__GFP_NOWARN|__GFP_ZERO, +get_order (memmap_size));if (page) - goto got_map_page; - - ret =vmalloc (memmap_size); -if (ret) - goto got_map_ptr; - -return NULL ; -got_map_page: - ret = (struct page *)pfn_to_kaddr (page_to_pfn (page)); -got_map_ptr: -memset (ret,0 , memmap_size); + ret = (struct page *)pfn_to_kaddr (page_to_pfn (page)); +else + ret =vzalloc (memmap_size);return ret; }
Signature · 9 lines
1.6.3.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/4 percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc
Currently pcpu_mem_alloc() is implemented always return zeroed memory. So rename it to make user like pcpu_get_pages_and_bitmap() know don't reinit it.
--- mm/percpu-vm.c | 5 ++--- mm/percpu.c | 17 +++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-)
mm/percpu-vm.c +2 -3
@@ -50,14 +50,13 @@ static struct page **pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk,if (!pages || !bitmap) {if (may_alloc && !pages) - pages =pcpu_mem_alloc (pages_size); + pages =pcpu_mem_zalloc (pages_size);if (may_alloc && !bitmap) - bitmap =pcpu_mem_alloc (bitmap_size); + bitmap =pcpu_mem_zalloc (bitmap_size);if (!pages || !bitmap)return NULL ; } -memset (pages,0 , pages_size);bitmap_copy (bitmap, chunk->populated, pcpu_unit_pages); *bitmapp = bitmap;
mm/percpu.c +9 -8
@@ -273,11 +273,11 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk, (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end)))/** -* pcpu_mem_alloc - allocate memory +* pcpu_mem_zalloc - allocate memory * @size: bytes to allocate * * Allocate @size bytes. If @size is smaller than PAGE_SIZE, -* kzalloc() is used; otherwise, vmalloc() is used. The returned +* kzalloc() is used; otherwise, vzalloc() is used. The returned * memory is always zeroed. * * CONTEXT:
@@ -286,7 +286,7 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk,* RETURNS: * Pointer to the allocated area on success, NULL on failure. */ -static void *pcpu_mem_alloc (size_t size) +static void *pcpu_mem_zalloc (size_t size) {if (WARN_ON_ONCE (!slab_is_available ()))return NULL ;
@@ -302,7 +302,7 @@ static void *pcpu_mem_alloc(size_t size)* @ptr: memory to free * @size: size of the area * -* Free @ptr. @ptr should have been allocated using pcpu_mem_alloc(). +* Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc(). */ static void pcpu_mem_free (void *ptr,size_t size) {
@@ -384,7 +384,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)size_t old_size =0 , new_size = new_alloc *sizeof (new[0 ]);unsigned long flags; - new =pcpu_mem_alloc (new_size); + new =pcpu_mem_zalloc (new_size);if (!new)return -ENOMEM ;
@@ -604,11 +604,12 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void) {struct pcpu_chunk *chunk; - chunk =pcpu_mem_alloc (pcpu_chunk_struct_size); + chunk =pcpu_mem_zalloc (pcpu_chunk_struct_size);if (!chunk)return NULL ; - chunk->map =pcpu_mem_alloc (PCPU_DFL_MAP_ALLOC *sizeof (chunk->map[0 ])); + chunk->map =pcpu_mem_zalloc (PCPU_DFL_MAP_ALLOC * +sizeof (chunk->map[0 ]));if (!chunk->map) {kfree (chunk);return NULL ;
@@ -1889,7 +1890,7 @@ void __init percpu_init_late(void)BUILD_BUG_ON (size >PAGE_SIZE ); - map =pcpu_mem_alloc (size); + map =pcpu_mem_zalloc (size);BUG_ON (!map);spin_lock_irqsave (&pcpu_lock, flags);
Signature · 9 lines
1.6.3.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc
Quoted 4 lines · Bob Liu
Currently
pcpu_mem_alloc()is implemented always return zeroed memory. So rename it to make user likepcpu_get_pages_and_bitmap()know don't reinit it.Signed-off-by Bob Liu <[email protected]>
Quoted 99 lines
---
mm/percpu-vm.c | 5 ++---
mm/percpu.c | 17 +++++++++--------2 files changed, 11 insertions(+), 11 deletions(-)mm/percpu-vm.c +2
-3@@ -50,14 +50,13 @@ static struct page **pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk, if (!pages || !bitmap) { if (may_alloc && !pages) - pages = pcpu_mem_alloc(pages_size); + pages = pcpu_mem_zalloc(pages_size); if (may_alloc && !bitmap) - bitmap = pcpu_mem_alloc(bitmap_size); + bitmap = pcpu_mem_zalloc(bitmap_size); if (!pages || !bitmap) return NULL; } - memset(pages, 0, pages_size); bitmap_copy(bitmap, chunk->populated, pcpu_unit_pages); *bitmapp = bitmap;mm/percpu.c +9
-9@@ -273,11 +273,11 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk, (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end))) /** -* pcpu_mem_alloc - allocate memory +* pcpu_mem_zalloc - allocate memory * @size: bytes to allocate * * Allocate @size bytes. If @size is smaller than PAGE_SIZE, -* kzalloc() is used; otherwise, vmalloc() is used. The returned +* kzalloc() is used; otherwise, vzalloc() is used. The returned * memory is always zeroed. * * CONTEXT: @@ -286,7 +286,7 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk,* RETURNS: * Pointer to the allocated area on success, NULL on failure. */ -static void *pcpu_mem_alloc (size_t size) +static void *pcpu_mem_zalloc (size_t size) { if (WARN_ON_ONCE(!slab_is_available())) return NULL;@@ -302,7 +302,7 @@ static void *pcpu_mem_alloc(size_t size)* @ptr: memory to free * @size: size of the area * -* Free @ptr. @ptr should have been allocated using pcpu_mem_alloc(). +* Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc(). */ static void pcpu_mem_free(void *ptr, size_t size) {@@ -384,7 +384,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc) size_t old_size = 0, new_size = new_alloc * sizeof(new[0]); unsigned long flags; - new = pcpu_mem_alloc(new_size); + new = pcpu_mem_zalloc(new_size); if (!new) return -ENOMEM;@@ -604,11 +604,12 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void) { struct pcpu_chunk *chunk; - chunk = pcpu_mem_alloc(pcpu_chunk_struct_size); + chunk = pcpu_mem_zalloc(pcpu_chunk_struct_size); if (!chunk) return NULL; - chunk->map = pcpu_mem_alloc(PCPU_DFL_MAP_ALLOC * sizeof(chunk->map[0])); + chunk->map = pcpu_mem_zalloc(PCPU_DFL_MAP_ALLOC * + sizeof(chunk->map[0])); if (!chunk->map) { kfree(chunk); return NULL;@@ -1889,7 +1890,7 @@ void __init percpu_init_late(void) BUILD_BUG_ON(size > PAGE_SIZE); - map = pcpu_mem_alloc(size); + map = pcpu_mem_zalloc(size); BUG_ON(!map); spin_lock_irqsave(&pcpu_lock, flags); --1.6.3.3
Quoted 7 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc
In reply to Bob LiuQuoted 2 lines · Bob Liu
Currently
pcpu_mem_alloc()is implemented always return zeroed memory. So rename it to make user likepcpu_get_pages_and_bitmap()know don't reinit it.
Makes sense. It fits better with internal kzalloc and vzalloc usage.
Quoted 1 line
Signed-off-by Bob Liu <[email protected]>
Quoted 105 lines
--- mm/percpu-vm.c | 5 ++--- mm/percpu.c | 17 +++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-)mm/percpu-vm.c +2
-3@@ -50,14 +50,13 @@ static struct page **pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk,if (!pages || !bitmap) {if (may_alloc && !pages) - pages =pcpu_mem_alloc (pages_size); + pages =pcpu_mem_zalloc (pages_size);if (may_alloc && !bitmap) - bitmap =pcpu_mem_alloc (bitmap_size); + bitmap =pcpu_mem_zalloc (bitmap_size);if (!pages || !bitmap)return NULL ; } -memset (pages,0 , pages_size);bitmap_copy (bitmap, chunk->populated, pcpu_unit_pages); *bitmapp = bitmap;mm/percpu.c +9
-8@@ -273,11 +273,11 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk, (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end)))/** -* pcpu_mem_alloc - allocate memory +* pcpu_mem_zalloc - allocate memory * @size: bytes to allocate * * Allocate @size bytes. If @size is smaller than PAGE_SIZE, -* kzalloc() is used; otherwise, vmalloc() is used. The returned +* kzalloc() is used; otherwise, vzalloc() is used. The returned * memory is always zeroed. * * CONTEXT: @@ -286,7 +286,7 @@ static void __maybe_unused pcpu_next_pop(struct pcpu_chunk *chunk,* RETURNS: * Pointer to the allocated area on success, NULL on failure. */ -static void *pcpu_mem_alloc (size_t size) +static void *pcpu_mem_zalloc (size_t size) {if (WARN_ON_ONCE (!slab_is_available ()))return NULL ;@@ -302,7 +302,7 @@ static void *pcpu_mem_alloc(size_t size)* @ptr: memory to free * @size: size of the area * -* Free @ptr. @ptr should have been allocated using pcpu_mem_alloc(). +* Free @ptr. @ptr should have been allocated using pcpu_mem_zalloc(). */ static void pcpu_mem_free (void *ptr,size_t size) {@@ -384,7 +384,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)size_t old_size =0 , new_size = new_alloc *sizeof (new[0 ]);unsigned long flags; - new =pcpu_mem_alloc (new_size); + new =pcpu_mem_zalloc (new_size);if (!new)return -ENOMEM ;@@ -604,11 +604,12 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void) {struct pcpu_chunk *chunk; - chunk =pcpu_mem_alloc (pcpu_chunk_struct_size); + chunk =pcpu_mem_zalloc (pcpu_chunk_struct_size);if (!chunk)return NULL ; - chunk->map =pcpu_mem_alloc (PCPU_DFL_MAP_ALLOC *sizeof (chunk->map[0 ])); + chunk->map =pcpu_mem_zalloc (PCPU_DFL_MAP_ALLOC * +sizeof (chunk->map[0 ]));if (!chunk->map) {kfree (chunk);return NULL ;@@ -1889,7 +1890,7 @@ void __init percpu_init_late(void)BUILD_BUG_ON (size >PAGE_SIZE ); - map =pcpu_mem_alloc (size); + map =pcpu_mem_zalloc (size);BUG_ON (!map);spin_lock_irqsave (&pcpu_lock, flags);Signature · 9 lines
1.6.3.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc
In reply to Bob LiuQuoted 4 lines · Bob Liu
Currently
pcpu_mem_alloc()is implemented always return zeroed memory. So rename it to make user likepcpu_get_pages_and_bitmap()know don't reinit it.Signed-off-by Bob Liu <[email protected]>
applied to percpu#for-3.2, thanks.
Signature · 8 lines
tejun -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/4] sparse: using kzalloc to clean up code
In reply to Bob LiuQuoted 24 lines · Bob Liu
This patch using kzalloc to clean up
sparse_index_alloc()and__GFP_ZEROto clean up__kmalloc_section_memmap().Signed-off-by Bob Liu <[email protected]>---
mm/sparse.c | 24 +++++++-----------------1 files changed, 7 insertions(+), 17 deletions(-)mm/sparse.c +1
-1@@ -65,15 +65,12 @@ static struct mem_section noinline __init_refok *sparse_index_alloc(int nid) if (slab_is_available()) { if (node_state(nid, N_HIGH_MEMORY)) - section = kmalloc_node(array_size, GFP_KERNEL, nid); + section = kzalloc_node(array_size, GFP_KERNEL, nid);else
- section =kmalloc(array_size, GFP_KERNEL);
+ section =kzalloc(array_size, GFP_KERNEL); } else
section =alloc_bootmem_node(NODE_DATA(nid), array_size);
Quoted 3 lines
- if (section)
-memset(section, 0, array_size);
-
You now broke the alloc_bootmem_node() path.
Quoted 32 lines
return section;
}mm/sparse.c +5
-13@@ -636,19 +633,12 @@ static struct page *__kmalloc_section_memmap(unsigned long nr_pages) struct page *page, *ret; unsigned long memmap_size = sizeof(struct page) * nr_pages; - page = alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(memmap_size)); + page = alloc_pages(GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO, + get_order(memmap_size)); if (page) - goto got_map_page; - - ret = vmalloc(memmap_size); - if (ret) - goto got_map_ptr; - - return NULL; -got_map_page: - ret = (struct page *)pfn_to_kaddr(page_to_pfn(page)); -got_map_ptr: - memset(ret, 0, memmap_size); + ret = (struct page *)pfn_to_kaddr(page_to_pfn(page)); + else + ret = vzalloc(memmap_size); return ret; } --1.6.3.3
Quoted 7 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/4] sparse: using kzalloc to clean up code
Quoted 25 lines · Pekka Enberg
Quoted 24 lines · Bob Liu
This patch using kzalloc to clean up
sparse_index_alloc()and__GFP_ZEROto clean up__kmalloc_section_memmap().Signed-off-by Bob Liu <[email protected]>---
mm/sparse.c | 24 +++++++-----------------1 files changed, 7 insertions(+), 17 deletions(-)mm/sparse.c +1
-1@@ -65,15 +65,12 @@ static struct mem_section noinline __init_refok *sparse_index_alloc(int nid) if (slab_is_available()) { if (node_state(nid, N_HIGH_MEMORY)) - section = kmalloc_node(array_size, GFP_KERNEL, nid); + section = kzalloc_node(array_size, GFP_KERNEL, nid);else
- section =kmalloc(array_size, GFP_KERNEL);
+ section =kzalloc(array_size, GFP_KERNEL); } else
section =alloc_bootmem_node(NODE_DATA(nid), array_size);
Quoted 6 lines
Quoted 3 lines
- if (section)
-memset(section, 0, array_size);
-You now broke the
alloc_bootmem_node()path.
Yes.
But In my opinion, the alloc_bootmem_node() will also return zeroed memory. I saw it has used kzalloc or memset() but i'm not pretty sure. CC'd [email protected],[email protected]
Thanks for your review.
Quoted 40 lines
Quoted 39 lines
return section;
}mm/sparse.c +5
-13@@ -636,19 +633,12 @@ static struct page *__kmalloc_section_memmap(unsigned long nr_pages) struct page *page, *ret; unsigned long memmap_size = sizeof(struct page) * nr_pages; - page = alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(memmap_size)); + page = alloc_pages(GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO, + get_order(memmap_size)); if (page) - goto got_map_page; - - ret = vmalloc(memmap_size); - if (ret) - goto got_map_ptr; - - return NULL; -got_map_page: - ret = (struct page *)pfn_to_kaddr(page_to_pfn(page)); -got_map_ptr: - memset(ret, 0, memmap_size); + ret = (struct page *)pfn_to_kaddr(page_to_pfn(page)); + else + ret = vzalloc(memmap_size); return ret; } --1.6.3.3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 9 lines
Regards, --Bob -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/4] sparse: using kzalloc to clean up code
Quoted 33 lines · Bob Liu
Quoted 25 lines · Pekka Enberg
Quoted 24 lines · Bob Liu
This patch using kzalloc to clean up
sparse_index_alloc()and__GFP_ZEROto clean up__kmalloc_section_memmap().Signed-off-by Bob Liu <[email protected]>--- mm/sparse.c | 24 +++++++----------------- 1 files changed, 7 insertions(+), 17 deletions(-)mm/sparse.c +2
-2@@ -65,15 +65,12 @@ static struct mem_section noinline __init_refok *sparse_index_alloc(int nid)if (slab_is_available ()) {if (node_state (nid,N_HIGH_MEMORY )) - section =kmalloc_node (array_size,GFP_KERNEL , nid); + section =kzalloc_node (array_size,GFP_KERNEL , nid);else - section =kmalloc (array_size,GFP_KERNEL ); + section =kzalloc (array_size,GFP_KERNEL ); }else section =alloc_bootmem_node (NODE_DATA (nid), array_size);Quoted 6 lines
mm/sparse.c static struct mem_section noinline __init_refok *sparse_index_alloc(int nid) · line 76
Quoted 3 lines
mm/sparse.c +0
-3-if (section) -memset (section,0 , array_size); -You now broke the
alloc_bootmem_node()path.
Quoted 4 lines
Yes.
But In my opinion, thealloc_bootmem_node()will also return zeroed memory. I saw it has used kzalloc ormemset()but i'm not pretty sure. CC'd [email protected],[email protected]
You are right, bootmem always returns zeroed memory. But it deserves mentioning in the changelog.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/4] sparse: using kzalloc to clean up code
In reply to Bob LiuQuoted 4 lines · Bob Liu
This patch using kzalloc to clean up
sparse_index_alloc()and__GFP_ZEROto clean up__kmalloc_section_memmap().Signed-off-by Bob Liu <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Pekka Enberg
Reviewed-byRe: [PATCH 3/4] sparse: using kzalloc to clean up code
Quoted 7 lines · Johannes Weiner
Quoted 4 lines · Bob Liu
This patch using kzalloc to clean up
sparse_index_alloc()and__GFP_ZEROto clean up__kmalloc_section_memmap().Signed-off-by Bob Liu <[email protected]>Acked-by Johannes Weiner <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/4] sparse: using kzalloc to clean up code
In reply to Bob LiuQuoted 4 lines · Bob Liu
This patch using kzalloc to clean up
sparse_index_alloc()and__GFP_ZEROto clean up__kmalloc_section_memmap().Signed-off-by Bob Liu <[email protected]>
looks good.
Quoted 61 lines
--- mm/sparse.c | 24 +++++++----------------- 1 files changed, 7 insertions(+), 17 deletions(-)mm/sparse.c +7
-17@@ -65,15 +65,12 @@ static struct mem_section noinline __init_refok *sparse_index_alloc(int nid)if (slab_is_available ()) {if (node_state (nid,N_HIGH_MEMORY )) - section =kmalloc_node (array_size,GFP_KERNEL , nid); + section =kzalloc_node (array_size,GFP_KERNEL , nid);else - section =kmalloc (array_size,GFP_KERNEL ); + section =kzalloc (array_size,GFP_KERNEL ); }else section =alloc_bootmem_node (NODE_DATA (nid), array_size); -if (section) -memset (section,0 , array_size); -return section; }@@ -636,19 +633,12 @@ static struct page *__kmalloc_section_memmap(unsigned long nr_pages)struct page *page, *ret;unsigned long memmap_size =sizeof (struct page ) * nr_pages; - page =alloc_pages (GFP_KERNEL |__GFP_NOWARN,get_order (memmap_size)); + page =alloc_pages (GFP_KERNEL |__GFP_NOWARN|__GFP_ZERO, +get_order (memmap_size));if (page) - goto got_map_page; - - ret =vmalloc (memmap_size); -if (ret) - goto got_map_ptr; - -return NULL ; -got_map_page: - ret = (struct page *)pfn_to_kaddr (page_to_pfn (page)); -got_map_ptr: -memset (ret,0 , memmap_size); + ret = (struct page *)pfn_to_kaddr (page_to_pfn (page)); +else + ret =vzalloc (memmap_size);return ret; }Signature · 9 lines
1.6.3.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
In reply to Bob LiuQuoted 13 lines · Bob Liu
This patch also add checking whether alloc
frontswap_mapmemory failed.Signed-off-by Bob Liu <[email protected]>--- mm/swapfile.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)mm/swapfile.c +0
-0
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 2129
Quoted 9 lines
mm/swapfile.c +3
-3@@ -2124,9 +2124,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) }/* frontswap enabled? set up bit-per-page map for frontswap */ if (frontswap_enabled) { - frontswap_map =vmalloc (maxpages /sizeof (long )); -if (frontswap_map) -memset (frontswap_map,0 , maxpages /sizeof (long )); + frontswap_map =vzalloc (maxpages /sizeof (long )); +if (!frontswap_map) + goto bad_swap;
vzalloc part looks good but shouldn't we disable frontswap rather than fail?
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Bob Liu
This patch also add checking whether alloc
frontswap_mapmemory failed.Signed-off-by Bob Liu <[email protected]>--- mm/swapfile.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)mm/swapfile.c +0
-1@@ -2124,9 +2124,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) }/* frontswap enabled? set up bit-per-page map for frontswap */ if (frontswap_enabled) { - frontswap_map =vmalloc (maxpages /sizeof (long ));
Quoted 8 lines
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 2129
Quoted 5 lines
mm/swapfile.c +3
-2-if (frontswap_map) -memset (frontswap_map,0 , maxpages /sizeof (long )); + frontswap_map =vzalloc (maxpages /sizeof (long )); +if (!frontswap_map) + goto bad_swap;vzalloc part looks good but shouldn't we disable frontswap rather than fail?
Silently dropping explicitely enabled features is not a good idea, IMO. But from a quick look, this seems to be actually happening as frontswap's bitmap tests check for whether there is even a bitmap allocated and it should essentially never do anything for real if there isn't.
How about printing a warning as to why the swapon fails and give the admin a choice to disable it on her own?
It's outside this patch's scope, though, just as changing the behaviour to fail swapon is.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 28 lines · Johannes Weiner
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Bob Liu
This patch also add checking whether alloc
frontswap_mapmemory failed.Signed-off-by Bob Liu <[email protected]>--- mm/swapfile.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)mm/swapfile.c +0
-1@@ -2124,9 +2124,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) }/* frontswap enabled? set up bit-per-page map for frontswap */ if (frontswap_enabled) { - frontswap_map =vmalloc (maxpages /sizeof (long ));Quoted 8 lines
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 2129
Quoted 5 lines
mm/swapfile.c +3
-2-if (frontswap_map) -memset (frontswap_map,0 , maxpages /sizeof (long )); + frontswap_map =vzalloc (maxpages /sizeof (long )); +if (!frontswap_map) + goto bad_swap;vzalloc part looks good but shouldn't we disable frontswap rather than fail?
Quoted 2 lines
Silently dropping explicitely enabled features is not a good idea, IMO.
Sure, I didn't mean silently. It should be a big fat warning that there is not enough memory to enable the feature.
Quoted 4 lines
But from a quick look, this seems to be actually happening as frontswap's bitmap tests check for whether there is even a bitmap allocated and it should essentially never do anything for real if there isn't.
Yes, that was my impression as well. I wasn't 100% sure about that though, because there are many places which check frontswap_enabled and do not check the map. I though that disabling the feature should be safer.
Quoted 2 lines
How about printing a warning as to why the swapon fails and give the admin a choice to disable it on her own?
I am not that familiar with the code but drivers/staging/zcache/zcache.c says:
/*
* zcache initialization
* NOTE FOR NOW zcache MUST BE PROVIDED AS A KERNEL BOOT PARAMETER OR
* NOTHING HAPPENS!
*/
Is there something admin can do about it?
Quoted 3 lines
It's outside this patch's scope, though, just as changing the behaviour to fail swapon is.
Agreed. The patch should just use vzalloc and the allocation failure should be handled separately - if needed at all.
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
RE: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 60 lines
From: Michal Hocko [mailto:[email protected]]
Sent: Thursday, August 04, 2011 3:00 AM
Subject: Re: [PATCH 2/4] frontswap: using vzalloc instead of vmallocQuoted 28 lines · Johannes Weiner
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Bob Liu
This patch also add checking whether alloc
frontswap_mapmemory failed.Signed-off-by Bob Liu <[email protected]>--- mm/swapfile.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)mm/swapfile.c +0
-1@@ -2124,9 +2124,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) }/* frontswap enabled? set up bit-per-page map for frontswap */ if (frontswap_enabled) { - frontswap_map =vmalloc (maxpages /sizeof (long ));Quoted 8 lines
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 2129
Quoted 5 lines
mm/swapfile.c +3
-2-if (frontswap_map) -memset (frontswap_map,0 , maxpages /sizeof (long )); + frontswap_map =vzalloc (maxpages /sizeof (long )); +if (!frontswap_map) + goto bad_swap;vzalloc part looks good but shouldn't we disable frontswap rather than fail?
Quoted 2 lines
Silently dropping explicitely enabled features is not a good idea, IMO.
Sure, I didn't mean silently. It should be a big fat warning that there is not enough memory to enable the feature.
Quoted 4 lines
But from a quick look, this seems to be actually happening as frontswap's bitmap tests check for whether there is even a bitmap allocated and it should essentially never do anything for real if there isn't.
Yes, that was my impression as well. I wasn't 100% sure about that though, because there are many places which check
frontswap_enabledand do not check the map. I though that disabling the feature should be safer.Quoted 2 lines
How about printing a warning as to why the swapon fails and give the admin a choice to disable it on her own?
I am not that familiar with the code but
drivers/staging/zcache/zcache.csays:
/*
* zcache initialization
* NOTE FOR NOW zcache MUST BE PROVIDED AS A KERNEL BOOT PARAMETER OR
* NOTHING HAPPENS!
*/
Quoted 8 lines
Is there something admin can do about it?
Quoted 3 lines
It's outside this patch's scope, though, just as changing the behaviour to fail swapon is.
Agreed. The patch should just use vzalloc and the allocation failure should be handled separately - if needed at all.
Agreed here too. The frontswap_enabled flag is global (enabling frontswap across all frontswap devices) whereas failure to allocate the frontswap_map will disable frontswap for only one swap device. And since frontswap is strictly a performance enhancement, there's no reason to fail the swapon for the entire swap device.
I am fairly sure that the failed allocation is handled gracefully through the remainder of the frontswap code, but will re-audit to confirm. A warning might be nice though.
In any case:
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 2127
Quoted 4 lines
mm/swapfile.c +1
-3- frontswap_map =vmalloc (maxpages /sizeof (long )); -if (frontswap_map) -memset (frontswap_map,0 , maxpages /sizeof (long )); + frontswap_map =vzalloc (maxpages /sizeof (long ));
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 2129
Quoted 2 lines
mm/swapfile.c +2
-0+if (!frontswap_map) + goto bad_swap;
NAK
Dan
Thanks... for the memory!
I really could use more / my throughput's on the floor The balloon is flat / my swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to Bob Hope)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 66 lines · Dan Magenheimer
Quoted 66 lines
From: Michal Hocko [mailto:[email protected]]
Sent: Thursday, August 04, 2011 3:00 AM
Subject: Re: [PATCH 2/4] frontswap: using vzalloc instead of vmallocQuoted 28 lines · Johannes Weiner
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Bob Liu
This patch also add checking whether alloc
frontswap_mapmemory failed.Signed-off-by Bob Liu <[email protected]>---
mm/swapfile.c | 6 +++---1 files changed, 3 insertions(+), 3 deletions(-)mm/swapfile.c +0
-1@@ -2124,9 +2124,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) } /* frontswap enabled? set up bit-per-page map for frontswap */ if (frontswap_enabled) { - frontswap_map = vmalloc(maxpages / sizeof(long));Quoted 8 lines
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 2129
Quoted 5 lines
mm/swapfile.c +3
-2- if (frontswap_map) - memset(frontswap_map, 0, maxpages / sizeof(long)); + frontswap_map = vzalloc(maxpages / sizeof(long)); + if (!frontswap_map) + goto bad_swap;vzalloc part looks good but shouldn't we disable frontswap rather than fail?
Quoted 2 lines
Silently dropping explicitely enabled features is not a good idea, IMO.
Sure, I didn't mean silently. It should be a big fat warning that there is not enough memory to enable the feature.
Quoted 4 lines
But from a quick look, this seems to be actually happening as frontswap's bitmap tests check for whether there is even a bitmap allocated and it should essentially never do anything for real if there isn't.
Yes, that was my impression as well. I wasn't 100% sure about that though, because there are many places which check
frontswap_enabledand do not check the map. I though that disabling the feature should be safer.Quoted 2 lines
How about printing a warning as to why the swapon fails and give the admin a choice to disable it on her own?
I am not that familiar with the code but
drivers/staging/zcache/zcache.csays:
/*
* zcache initialization
* NOTE FOR NOW zcache MUST BE PROVIDED AS A KERNEL BOOT PARAMETER OR
* NOTHING HAPPENS!
*/Is there something admin can do about it?
Quoted 3 lines
It's outside this patch's scope, though, just as changing the behaviour to fail swapon is.
Quoted 9 lines
Quoted 2 lines
Agreed. The patch should just use vzalloc and the allocation failure should be handled separately - if needed at all.
Agreed here too. The
frontswap_enabledflag is global (enabling frontswap across all frontswap devices) whereas failure to allocate thefrontswap_mapwill disable frontswap for only one swap device. And since frontswap is strictly a performance enhancement, there's no reason to fail the swapon for the entire swap device.
Agreed.
Quoted 4 lines
I am fairly sure that the failed allocation is handled gracefully through the remainder of the frontswap code, but will re-audit to confirm. A warning might be nice though.
There is a place i think maybe have problem.
function __frontswap_flush_area() in file frontswap.c called memset(sis->frontswap_map, .., ..);
But if frontswap_map allocation fail there is a null pointer access ?
Quoted 9 lines
In any case:
Quoted 4 lines
-
frontswap_map= vmalloc(maxpages / sizeof(long));
- if (frontswap_map)
-memset(frontswap_map, 0, maxpages / sizeof(long));
+frontswap_map= vzalloc(maxpages / sizeof(long));Acked-by Dan Magenheimer <[email protected]>
Thanks,
Quoted 5 lines
Quoted 2 lines
+ if (!frontswap_map)
+ gotobad_swap;NAK
Quoted 8 lines
Dan
Thanks... for the memory!
I really could use more / my throughput's on the floor The balloon is flat / my swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to Bob Hope)
:)
Signature · 9 lines
Regards, --Bob -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
RE: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 8 lines
Quoted 3 lines
I am fairly sure that the failed allocation is handled gracefully through the remainder of the frontswap code, but will re-audit to confirm. A warning might be nice though.
There is a place i think maybe have problem.
function__frontswap_flush_area()in filefrontswap.ccalledmemset(sis->frontswap_map, .., ..);
But iffrontswap_mapallocation fail there is a null pointer access ?
Good catch!
I'll fix that when I submit a frontswap update in a few days.
Thanks,
Dan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 4 lines · Dan Magenheimer
Quoted 4 lines
Quoted 3 lines
I am fairly sure that the failed allocation is handled gracefully through the remainder of the frontswap code, but will re-audit to confirm. A warning might be nice though.
Quoted 9 lines
Quoted 4 lines
There is a place i think maybe have problem.
function__frontswap_flush_area()in filefrontswap.ccalledmemset(sis->frontswap_map, .., ..);
But iffrontswap_mapallocation fail there is a null pointer access ?Good catch!
I'll fix that when I submit a frontswap update in a few days.
Would you please add current patch to you frontswap update series ? So I needn't to send a Version 2 separately with only drop the allocation failed handler.
Thanks.
Signature · 9 lines
Regards, --Bob -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
RE: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 16 lines
From: Bob Liu [mailto:[email protected]]
Subject: Re: [PATCH 2/4] frontswap: using vzalloc instead of vmallocQuoted 11 lines · Dan Magenheimer
Quoted 8 lines
Quoted 3 lines
I am fairly sure that the failed allocation is handled gracefully through the remainder of the frontswap code, but will re-audit to confirm. A warning might be nice though.
There is a place i think maybe have problem.
function__frontswap_flush_area()in filefrontswap.ccalledmemset(sis->frontswap_map, .., ..);
But iffrontswap_mapallocation fail there is a null pointer access ?Good catch!
Quoted 8 lines
Quoted 1 line
I'll fix that when I submit a frontswap update in a few days.
Would you please add current patch to you frontswap update series ? So I needn't to send a Version 2 separately with only drop the allocation failed handler.
Thanks.
Regards,
--Bob
Hi Bob --
I'm not an expert here, so you or others can feel free to correct me if I've got this wrong or if I misunderstood you, but I don't think that's the way patchsets are supposed to be done, at least until they are merged into Linus' tree. I think you are asking me to add a fifth patch in the frontswap patch series that fixes this bug, rather than incorporate the fix into the next posted version of the frontswap patchset. However, I expect to post V5 soon with some additional (minor syntactic) changes to the patchset from Konrad Wilk's very thorough review. Then this V5 will replace the current version in linux-next soon thereafter (and hopefully then into linux-3.2.) So I think it would be the correct process for me to include your bugfix (with an acknowledgement in the commit log) in that posted V5.
That said, if you are using frontswap V4 (the version currently in linux-next), the bug fix we've discussed needs to be fixed but is exceedingly unlikely to occur in the real world because it would require the malloc of swap_map to succeed (which is 8 bits per swap page in the swapon'ed swap device) but the malloc of frontswap_map immediately thereafter to fail (which is 1 bit per swap page in the swapon'ed swap device). (And also this is not a problem for the vast majority of kernel developers... it's only possible for frontswap users like you that have enabled zcache or tmem or RAMster via a kernel boot option.)
Thanks,
Dan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/4] frontswap: using vzalloc instead of vmalloc
Quoted 27 lines · Dan Magenheimer
Quoted 16 lines
From: Bob Liu [mailto:[email protected]]
Subject: Re: [PATCH 2/4] frontswap: using vzalloc instead of vmallocQuoted 11 lines · Dan Magenheimer
Quoted 8 lines
Quoted 3 lines
I am fairly sure that the failed allocation is handled gracefully through the remainder of the frontswap code, but will re-audit to confirm. A warning might be nice though.
There is a place i think maybe have problem.
function__frontswap_flush_area()in filefrontswap.ccalledmemset(sis->frontswap_map, .., ..);
But iffrontswap_mapallocation fail there is a null pointer access ?Good catch!
Quoted 8 lines
Quoted 1 line
I'll fix that when I submit a frontswap update in a few days.
Would you please add current patch to you frontswap update series ? So I needn't to send a Version 2 separately with only drop the allocation failed handler.
Thanks.
Regards,
--BobHi Bob --
Quoted 13 lines
I'm not an expert here, so you or others can feel free to correct me if I've got this wrong or if I misunderstood you, but I don't think that's the way patchsets are supposed to be done, at least until they are merged into Linus' tree. I think you are asking me to add a fifth patch in the frontswap patch series that fixes this bug, rather than incorporate the fix into the next posted version of the frontswap patchset. However, I expect to post V5 soon with some additional (minor syntactic) changes to the patchset from Konrad Wilk's very thorough review. Then this V5 will replace the current version in linux-next soon thereafter (and hopefully then into linux-3.2.) So I think it would be the correct process for me to include your bugfix (with an acknowledgement in the commit log) in that posted V5.
Yes, but current patch "frontswap: using vzalloc instead of vmalloc" has the error handler
which is unneeded.
+ if (!frontswap_map)
+ goto bad_swap;
If you want to include it into your series you must delete it by yourself(or I send an new one) and then add an
extra patch which fix the frontswap_map null pointer bug into your series too.
That's what I want. Sorry for the noise :).
Quoted 13 lines
That said, if you are using frontswap V4 (the version currently in linux-next), the bug fix we've discussed needs to be fixed but is exceedingly unlikely to occur in the real world because it would require the malloc of
swap_mapto succeed (which is 8 bits per swap page in the swapon'ed swap device) but the malloc offrontswap_mapimmediately thereafter to fail (which is 1 bit per swap page in the swapon'ed swap device). (And also this is not a problem for the vast majority of kernel developers... it's only possible for frontswap users like you that have enabled zcache or tmem or RAMster via a kernel boot option.)Thanks,
Dan
Signature · 9 lines
Regards, --Bob -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Bob Liu
Signed-off-by Bob Liu <[email protected]>
Quoted 25 lines
---
mm/page_cgroup.c | 3 +--1 files changed, 1 insertions(+), 2 deletions(-)mm/page_cgroup.c +1
-3@@ -513,11 +513,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) length = DIV_ROUND_UP(max_pages, SC_PER_PAGE); array_size = length * sizeof(void *); - array = vmalloc(array_size); + array = vzalloc(array_size); if (!array) goto nomem; - memset(array, 0, array_size); ctrl = &swap_cgroup_ctrl[type]; mutex_lock(&swap_cgroup_mutex); ctrl->length = length; --1.6.3.3
Quoted 7 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Bob Liu
Signed-off-by Bob Liu <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Bob Liu
Signed-off-by Bob Liu <[email protected]>
Quoted 25 lines
--- mm/page_cgroup.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)mm/page_cgroup.c +1
-2@@ -513,11 +513,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) length =DIV_ROUND_UP (max_pages,SC_PER_PAGE ); array_size = length *sizeof (void *); - array =vmalloc (array_size); + array =vzalloc (array_size);if (!array) goto nomem; -memset (array,0 , array_size); ctrl = &swap_cgroup_ctrl[type];mutex_lock (&swap_cgroup_mutex); ctrl->length = length;Signature · 1 line
1.6.3.3
Signature · 13 lines
Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · On Thu, 4 Aug 2011 11:09:47 +0800 Bob Liu <[email protected]> wrote:
Signed-off-by Bob Liu <[email protected]>
Quoted 26 lines
--- mm/page_cgroup.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)mm/page_cgroup.c +1
-2@@ -513,11 +513,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) length =DIV_ROUND_UP (max_pages,SC_PER_PAGE ); array_size = length *sizeof (void *); - array =vmalloc (array_size); + array =vzalloc (array_size);if (!array) goto nomem; -memset (array,0 , array_size); ctrl = &swap_cgroup_ctrl[type];mutex_lock (&swap_cgroup_mutex); ctrl->length = length;Signature · 1 line
1.6.3.3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>