* [PATCH] mm: memory_hotplug: no need to check res twice in add_memory
[not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
@ 2012-12-20 19:11 ` Sasha Levin
2012-12-20 19:11 ` [PATCH] mm/sparse: don't check return value of alloc_bootmem calls Sasha Levin
2012-12-20 19:11 ` [PATCH] slob: use DIV_ROUND_UP where possible Sasha Levin
2 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2012-12-20 19:11 UTC (permalink / raw)
To: Andrew Morton, Wen Congyang, Jiang Liu, Lai Jiangshan,
Yasuaki Ishimatsu, linux-mm, linux-kernel
Cc: Sasha Levin
Remove one redundant check of res.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
mm/memory_hotplug.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 962e353..4082244 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -898,8 +898,7 @@ error:
/* rollback pgdat allocation and others */
if (new_pgdat)
rollback_node_hotadd(nid, pgdat);
- if (res)
- release_memory_resource(res);
+ release_memory_resource(res);
out:
unlock_memory_hotplug();
--
1.8.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] mm/sparse: don't check return value of alloc_bootmem calls
[not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
2012-12-20 19:11 ` [PATCH] mm: memory_hotplug: no need to check res twice in add_memory Sasha Levin
@ 2012-12-20 19:11 ` Sasha Levin
2012-12-20 20:23 ` David Rientjes
2012-12-20 19:11 ` [PATCH] slob: use DIV_ROUND_UP where possible Sasha Levin
2 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2012-12-20 19:11 UTC (permalink / raw)
To: Andrew Morton, Johannes Weiner, Michal Hocko, Gavin Shan,
David Rientjes, linux-mm, linux-kernel
Cc: Sasha Levin
These calls will panic if they can't allocate the memory, so we can
assume that we get actual memory back. This simplifies some functions
and removes unneeded checks.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
mm/sparse.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/mm/sparse.c b/mm/sparse.c
index 6b5fb76..ae64d6e 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -403,15 +403,13 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
size = PAGE_ALIGN(size);
map = __alloc_bootmem_node_high(NODE_DATA(nodeid), size * map_count,
PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
- if (map) {
- for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
- if (!present_section_nr(pnum))
- continue;
- map_map[pnum] = map;
- map += size;
- }
- return;
+ for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
+ if (!present_section_nr(pnum))
+ continue;
+ map_map[pnum] = map;
+ map += size;
}
+ return;
/* fallback */
for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
@@ -497,8 +495,6 @@ void __init sparse_init(void)
*/
size = sizeof(unsigned long *) * NR_MEM_SECTIONS;
usemap_map = alloc_bootmem(size);
- if (!usemap_map)
- panic("can not allocate usemap_map\n");
for (pnum = 0; pnum < NR_MEM_SECTIONS; pnum++) {
struct mem_section *ms;
@@ -538,8 +534,6 @@ void __init sparse_init(void)
#ifdef CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER
size2 = sizeof(struct page *) * NR_MEM_SECTIONS;
map_map = alloc_bootmem(size2);
- if (!map_map)
- panic("can not allocate map_map\n");
for (pnum = 0; pnum < NR_MEM_SECTIONS; pnum++) {
struct mem_section *ms;
--
1.8.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] slob: use DIV_ROUND_UP where possible
[not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
2012-12-20 19:11 ` [PATCH] mm: memory_hotplug: no need to check res twice in add_memory Sasha Levin
2012-12-20 19:11 ` [PATCH] mm/sparse: don't check return value of alloc_bootmem calls Sasha Levin
@ 2012-12-20 19:11 ` Sasha Levin
2012-12-20 19:40 ` Christoph Lameter
2 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2012-12-20 19:11 UTC (permalink / raw)
To: Christoph Lameter, Pekka Enberg, Matt Mackall, linux-mm,
linux-kernel
Cc: Sasha Levin
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
mm/slob.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slob.c b/mm/slob.c
index a99fdf7..f729c46 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -122,7 +122,7 @@ static inline void clear_slob_page_free(struct page *sp)
}
#define SLOB_UNIT sizeof(slob_t)
-#define SLOB_UNITS(size) (((size) + SLOB_UNIT - 1)/SLOB_UNIT)
+#define SLOB_UNITS(size) DIV_ROUND_UP(size, SLOB_UNIT)
/*
* struct slob_rcu is inserted at the tail of allocated slob blocks, which
--
1.8.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] slob: use DIV_ROUND_UP where possible
2012-12-20 19:11 ` [PATCH] slob: use DIV_ROUND_UP where possible Sasha Levin
@ 2012-12-20 19:40 ` Christoph Lameter
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Lameter @ 2012-12-20 19:40 UTC (permalink / raw)
To: Sasha Levin; +Cc: Pekka Enberg, Matt Mackall, linux-mm, linux-kernel
Obviously good.
Acked-by: Christoph Lameter <cl@linux.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/sparse: don't check return value of alloc_bootmem calls
2012-12-20 19:11 ` [PATCH] mm/sparse: don't check return value of alloc_bootmem calls Sasha Levin
@ 2012-12-20 20:23 ` David Rientjes
2012-12-20 20:36 ` Sasha Levin
0 siblings, 1 reply; 7+ messages in thread
From: David Rientjes @ 2012-12-20 20:23 UTC (permalink / raw)
To: Sasha Levin
Cc: Andrew Morton, Johannes Weiner, Michal Hocko, Gavin Shan,
linux-mm, linux-kernel
On Thu, 20 Dec 2012, Sasha Levin wrote:
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 6b5fb76..ae64d6e 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -403,15 +403,13 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
> size = PAGE_ALIGN(size);
> map = __alloc_bootmem_node_high(NODE_DATA(nodeid), size * map_count,
> PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
> - if (map) {
> - for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
> - if (!present_section_nr(pnum))
> - continue;
> - map_map[pnum] = map;
> - map += size;
> - }
> - return;
> + for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
> + if (!present_section_nr(pnum))
> + continue;
> + map_map[pnum] = map;
> + map += size;
> }
> + return;
>
> /* fallback */
> for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
That's not true when slab_is_available() and why would you possibly add a
return statement right before fallback code in such cases?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/sparse: don't check return value of alloc_bootmem calls
2012-12-20 20:23 ` David Rientjes
@ 2012-12-20 20:36 ` Sasha Levin
2012-12-20 20:43 ` David Rientjes
0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2012-12-20 20:36 UTC (permalink / raw)
To: David Rientjes
Cc: Andrew Morton, Johannes Weiner, Michal Hocko, Gavin Shan,
linux-mm, linux-kernel
On 12/20/2012 03:23 PM, David Rientjes wrote:
> On Thu, 20 Dec 2012, Sasha Levin wrote:
>
>> diff --git a/mm/sparse.c b/mm/sparse.c
>> index 6b5fb76..ae64d6e 100644
>> --- a/mm/sparse.c
>> +++ b/mm/sparse.c
>> @@ -403,15 +403,13 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
>> size = PAGE_ALIGN(size);
>> map = __alloc_bootmem_node_high(NODE_DATA(nodeid), size * map_count,
>> PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
>> - if (map) {
>> - for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
>> - if (!present_section_nr(pnum))
>> - continue;
>> - map_map[pnum] = map;
>> - map += size;
>> - }
>> - return;
>> + for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
>> + if (!present_section_nr(pnum))
>> + continue;
>> + map_map[pnum] = map;
>> + map += size;
>> }
>> + return;
>>
>> /* fallback */
>> for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
>
> That's not true when slab_is_available() and why would you possibly add a
> return statement right before fallback code in such cases?
So what we really need is to update the documentation of __alloc_bootmem_node, I'll send
a patch that does that instead.
I've dragged the 'return' out of the if(map) condition, I should have removed the fallback
as well and so the return would also be gone, but that's irrelevant now.
Thanks,
Sasha
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/sparse: don't check return value of alloc_bootmem calls
2012-12-20 20:36 ` Sasha Levin
@ 2012-12-20 20:43 ` David Rientjes
0 siblings, 0 replies; 7+ messages in thread
From: David Rientjes @ 2012-12-20 20:43 UTC (permalink / raw)
To: Sasha Levin
Cc: Andrew Morton, Johannes Weiner, Michal Hocko, Gavin Shan,
linux-mm, linux-kernel
On Thu, 20 Dec 2012, Sasha Levin wrote:
> So what we really need is to update the documentation of __alloc_bootmem_node, I'll send
> a patch that does that instead.
>
It panics iff slab is not available to allocate from yet, otherwise it's
just a wrapper around kmalloc(). This emits a warning to the kernel log,
though, so __alloc_bootmem_node() should certainly not be called that late
in the boot sequence.
Since __alloc_bootmem_node_nopanic() is the way to avoid the panic, I
think the change that should be made here so to panic even when the
kmalloc() fails in __alloc_bootmem_node(), __alloc_bootmem_node_high(),
and __alloc_bootmem_low_node().
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-12-20 20:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
2012-12-20 19:11 ` [PATCH] mm: memory_hotplug: no need to check res twice in add_memory Sasha Levin
2012-12-20 19:11 ` [PATCH] mm/sparse: don't check return value of alloc_bootmem calls Sasha Levin
2012-12-20 20:23 ` David Rientjes
2012-12-20 20:36 ` Sasha Levin
2012-12-20 20:43 ` David Rientjes
2012-12-20 19:11 ` [PATCH] slob: use DIV_ROUND_UP where possible Sasha Levin
2012-12-20 19:40 ` Christoph Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).