mm: memblock: always inline memblock_alloc
PATCH 1/1 mm: memblock: always inline memblock_alloc
Since memblock_alloc is not getting inlined, memblock_reserve owner info is lost. Below information is not enough for memory accounting. for example:
[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 memblock_alloc+0x20/0x2c [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188
Add "__always_inline" to make sure it get inlined and to get the exact owner of the memblock_reserve.
After adding __always_inline:
[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 start_kernel+0xa4/0x568 [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188
--- include/linux/memblock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/memblock.h +1 -1
@@ -404,7 +404,7 @@ void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid); -static inline void *__init memblock_alloc (phys_addr_t size,phys_addr_t align) +static __always_inline void * __init memblock_alloc(phys_addr_t size, phys_addr_t align) {return memblock_alloc_try_nid (size, align,MEMBLOCK_LOW_LIMIT ,MEMBLOCK_ALLOC_ACCESSIBLE ,NUMA_NO_NODE );
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Mike Rapoport
maintainerHi,
Quoted 11 lines · Faiyaz Mohammed
Since
memblock_allocis not getting inlined,memblock_reserveowner info is lost. Below information is not enough for memory accounting. for example:[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 memblock_alloc+0x20/0x2c [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188Add "
__always_inline" to make sure it get inlined and to get the exact owner of thememblock_reserve.
After adding__always_inline:[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 start_kernel+0xa4/0x568 [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188
I agree that making memblock_alloc() inline as well as other similar wrappers would improve the debugability.
Still, it has nothing to do with memory accounting and owner tracking. Please update the patch description to better explain what it actually improves.
Quoted 10 lines
Signed-off-by Faiyaz Mohammed <[email protected]>--- include/linux/memblock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/memblock.h +0
-0
include/linux/memblock.h void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, · line 407
Quoted 5 lines
include/linux/memblock.h +1
-1@@ -404,7 +404,7 @@ void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid); -static inline void *__init memblock_alloc (phys_addr_t size,phys_addr_t align) +static __always_inline void * __init memblock_alloc(phys_addr_t size, phys_addr_t align)
I think simply dropping __init here will make memblock_alloc() inline. There are also several more convenience wrappers marked __init, do you mind removing the __init annotation for them as well?
Quoted 3 lines
include/linux/memblock.h +0
-0{return memblock_alloc_try_nid (size, align,MEMBLOCK_LOW_LIMIT ,MEMBLOCK_ALLOC_ACCESSIBLE ,NUMA_NO_NODE );
Signature · 2 lines
Sincerely yours, Mike.
Quoted 15 lines · Mike Rapoport
Hi,
Quoted 11 lines · Faiyaz Mohammed
Since
memblock_allocis not getting inlined,memblock_reserveowner info is lost. Below information is not enough for memory accounting. for example:[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 memblock_alloc+0x20/0x2c [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188Add "
__always_inline" to make sure it get inlined and to get the exact owner of thememblock_reserve.
After adding__always_inline:[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 start_kernel+0xa4/0x568 [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188
Quoted 5 lines
I agree that making
memblock_alloc()inline as well as other similar wrappers would improve the debugability.
Still, it has nothing to do with memory accounting and owner tracking. Please update the patch description to better explain what it actually improves.
As describe in other thread, do memblock reserved accounting to track owners
to know size of memory allocated by different drivers/owners through
memblock_reserve, which help in comparing different kernel version and in
optimizations.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Faiyaz Mohammed <[email protected]>--- include/linux/memblock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/memblock.h +0
-0@@ -404,7 +404,7 @@ void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid);
Quoted 5 lines
include/linux/memblock.h void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, · line 407
Quoted 2 lines
include/linux/memblock.h +1
-1-static inline void *__init memblock_alloc (phys_addr_t size,phys_addr_t align) +static __always_inline void * __init memblock_alloc(phys_addr_t size, phys_addr_t align)I think simply dropping
__inithere will makememblock_alloc()inline. There are also several more convenience wrappers marked__init, do you mind removing the__initannotation for them as well?
Yes, if we drop __init, memblock_alloc will get inline but would it not increase
kernel footprint as the function will no more be released after kernel init?
Quoted 3 lines
Quoted 3 lines
include/linux/memblock.h +0
-0{return memblock_alloc_try_nid (size, align,MEMBLOCK_LOW_LIMIT ,MEMBLOCK_ALLOC_ACCESSIBLE ,NUMA_NO_NODE );
Mike Rapoport
maintainerQuoted 48 lines · Faiyaz Mohammed
Quoted 14 lines · Mike Rapoport
Hi,
Quoted 11 lines · Faiyaz Mohammed
Since
memblock_allocis not getting inlined,memblock_reserveowner info is lost. Below information is not enough for memory accounting. for example:[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 memblock_alloc+0x20/0x2c [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188Add "
__always_inline" to make sure it get inlined and to get the exact owner of thememblock_reserve.
After adding__always_inline:[ 0.000000] memblock_alloc_try_nid: 1490 bytes align=0x40 nid=-1 from=0x0000000000000000 max_addr=0x0000000000000000 start_kernel+0xa4/0x568 [ 0.000000] memblock_reserve: [0x000000023f09a3c0-0x000000023f09a991] memblock_alloc_range_nid+0xc0/0x188Quoted 5 lines
I agree that making
memblock_alloc()inline as well as other similar wrappers would improve the debugability.
Still, it has nothing to do with memory accounting and owner tracking. Please update the patch description to better explain what it actually improves.As describe in other thread, do memblock reserved accounting to track owners
to know size of memory allocated by different
drivers/ownersthrough
memblock_reserve, which help in comparing different kernel version and inoptimizations.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Faiyaz Mohammed <[email protected]>--- include/linux/memblock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 12 lines
include/linux/memblock.h void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, · line 406
Quoted 9 lines
include/linux/memblock.h +1
-1@@ -404,7 +404,7 @@ void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid); -static inline void *__init memblock_alloc (phys_addr_t size,phys_addr_t align) +static __always_inline void * __init memblock_alloc(phys_addr_t size, phys_addr_t align)I think simply dropping
__inithere will makememblock_alloc()inline. There are also several more convenience wrappers marked__init, do you mind removing the__initannotation for them as well?
Quoted 3 lines
Yes, if we drop
__init,memblock_allocwill get inline but would it not increase
kernel footprint as the function will no more be released after kernel init?
If memblock_alloc(), or any other function for that matter, is inlined, it does not have an entry in the object file, but it is rather inserted at the call sites.
The functions that use memblock_alloc() may change, but they all should be __init anyway so I won't expect increase in the kernel post-init memory footprint.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/memblock.h +0
-0{return memblock_alloc_try_nid (size, align,MEMBLOCK_LOW_LIMIT ,MEMBLOCK_ALLOC_ACCESSIBLE ,NUMA_NO_NODE );
Signature · 2 lines
Sincerely yours, Mike.