From: Pavel Tatashin <pasha.tatashin@oracle.com> To: linux-mm@kvack.org, sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 2/4] mm: Zeroing hash tables in allocator Date: Thu, 2 Mar 2017 00:33:43 -0500 [thread overview] Message-ID: <1488432825-92126-3-git-send-email-pasha.tatashin@oracle.com> (raw) In-Reply-To: <1488432825-92126-1-git-send-email-pasha.tatashin@oracle.com> Add a new flag HASH_ZERO which when provided grantees that the hash table that is returned by alloc_large_system_hash() is zeroed. In most cases that is what is needed by the caller. Use page level allocator's __GFP_ZERO flags to zero the memory. It is using memset() which is efficient method to zero memory and is optimized for most platforms. Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com> Reviewed-by: Babu Moger <babu.moger@oracle.com> --- include/linux/bootmem.h | 1 + mm/page_alloc.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 962164d..e223d91 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h @@ -358,6 +358,7 @@ static inline void __init memblock_free_late( #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ #define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min * shift passed via *_hash_shift */ +#define HASH_ZERO 0x00000004 /* Zero allocated hash table */ /* Only NUMA needs hash distribution. 64bit NUMA architectures have * sufficient vmalloc space. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a7a6aac..1b0f7a4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7142,6 +7142,7 @@ static unsigned long __init arch_reserved_kernel_pages(void) unsigned long long max = high_limit; unsigned long log2qty, size; void *table = NULL; + gfp_t gfp_flags; /* allow the kernel cmdline to have a say */ if (!numentries) { @@ -7186,12 +7187,17 @@ static unsigned long __init arch_reserved_kernel_pages(void) log2qty = ilog2(numentries); + /* + * memblock allocator returns zeroed memory already, so HASH_ZERO is + * currently not used when HASH_EARLY is specified. + */ + gfp_flags = (flags & HASH_ZERO) ? GFP_ATOMIC | __GFP_ZERO : GFP_ATOMIC; do { size = bucketsize << log2qty; if (flags & HASH_EARLY) table = memblock_virt_alloc_nopanic(size, 0); else if (hashdist) - table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); + table = __vmalloc(size, gfp_flags, PAGE_KERNEL); else { /* * If bucketsize is not a power-of-two, we may free @@ -7199,8 +7205,8 @@ static unsigned long __init arch_reserved_kernel_pages(void) * alloc_pages_exact() automatically does */ if (get_order(size) < MAX_ORDER) { - table = alloc_pages_exact(size, GFP_ATOMIC); - kmemleak_alloc(table, size, 1, GFP_ATOMIC); + table = alloc_pages_exact(size, gfp_flags); + kmemleak_alloc(table, size, 1, gfp_flags); } } } while (!table && size > PAGE_SIZE && --log2qty); -- 1.7.1 -- 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>
WARNING: multiple messages have this Message-ID (diff)
From: Pavel Tatashin <pasha.tatashin@oracle.com> To: linux-mm@kvack.org, sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 2/4] mm: Zeroing hash tables in allocator Date: Thu, 02 Mar 2017 05:33:43 +0000 [thread overview] Message-ID: <1488432825-92126-3-git-send-email-pasha.tatashin@oracle.com> (raw) In-Reply-To: <1488432825-92126-1-git-send-email-pasha.tatashin@oracle.com> Add a new flag HASH_ZERO which when provided grantees that the hash table that is returned by alloc_large_system_hash() is zeroed. In most cases that is what is needed by the caller. Use page level allocator's __GFP_ZERO flags to zero the memory. It is using memset() which is efficient method to zero memory and is optimized for most platforms. Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com> Reviewed-by: Babu Moger <babu.moger@oracle.com> --- include/linux/bootmem.h | 1 + mm/page_alloc.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 962164d..e223d91 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h @@ -358,6 +358,7 @@ static inline void __init memblock_free_late( #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ #define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min * shift passed via *_hash_shift */ +#define HASH_ZERO 0x00000004 /* Zero allocated hash table */ /* Only NUMA needs hash distribution. 64bit NUMA architectures have * sufficient vmalloc space. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a7a6aac..1b0f7a4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7142,6 +7142,7 @@ static unsigned long __init arch_reserved_kernel_pages(void) unsigned long long max = high_limit; unsigned long log2qty, size; void *table = NULL; + gfp_t gfp_flags; /* allow the kernel cmdline to have a say */ if (!numentries) { @@ -7186,12 +7187,17 @@ static unsigned long __init arch_reserved_kernel_pages(void) log2qty = ilog2(numentries); + /* + * memblock allocator returns zeroed memory already, so HASH_ZERO is + * currently not used when HASH_EARLY is specified. + */ + gfp_flags = (flags & HASH_ZERO) ? GFP_ATOMIC | __GFP_ZERO : GFP_ATOMIC; do { size = bucketsize << log2qty; if (flags & HASH_EARLY) table = memblock_virt_alloc_nopanic(size, 0); else if (hashdist) - table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); + table = __vmalloc(size, gfp_flags, PAGE_KERNEL); else { /* * If bucketsize is not a power-of-two, we may free @@ -7199,8 +7205,8 @@ static unsigned long __init arch_reserved_kernel_pages(void) * alloc_pages_exact() automatically does */ if (get_order(size) < MAX_ORDER) { - table = alloc_pages_exact(size, GFP_ATOMIC); - kmemleak_alloc(table, size, 1, GFP_ATOMIC); + table = alloc_pages_exact(size, gfp_flags); + kmemleak_alloc(table, size, 1, gfp_flags); } } } while (!table && size > PAGE_SIZE && --log2qty); -- 1.7.1
next prev parent reply other threads:[~2017-03-02 5:33 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-03-02 5:33 [PATCH v3 0/4] Zeroing hash tables in allocator Pavel Tatashin 2017-03-02 5:33 ` Pavel Tatashin 2017-03-02 5:33 ` [PATCH v3 1/4] sparc64: NG4 memset 32 bits overflow Pavel Tatashin 2017-03-02 5:33 ` Pavel Tatashin 2017-03-03 23:34 ` Andrew Morton 2017-03-03 23:34 ` Andrew Morton 2017-03-02 5:33 ` Pavel Tatashin [this message] 2017-03-02 5:33 ` [PATCH v3 2/4] mm: Zeroing hash tables in allocator Pavel Tatashin 2017-03-02 5:33 ` [PATCH v3 3/4] mm: Updated callers to use HASH_ZERO flag Pavel Tatashin 2017-03-02 5:33 ` Pavel Tatashin 2017-03-02 5:33 ` [PATCH v3 4/4] mm: Adaptive hash table scaling Pavel Tatashin 2017-03-02 5:33 ` Pavel Tatashin 2017-03-03 23:32 ` Andrew Morton 2017-03-03 23:32 ` Andrew Morton 2017-04-26 20:11 ` Michal Hocko 2017-04-26 20:11 ` Michal Hocko 2017-05-02 8:04 ` Michal Hocko 2017-05-02 8:04 ` Michal Hocko 2017-05-04 18:23 ` Pasha Tatashin 2017-05-04 18:23 ` Pasha Tatashin 2017-05-04 18:28 ` Pasha Tatashin 2017-05-04 18:28 ` Pasha Tatashin 2017-05-05 13:30 ` Michal Hocko 2017-05-05 13:30 ` Michal Hocko 2017-05-05 15:33 ` Pasha Tatashin 2017-05-05 15:33 ` Pasha Tatashin 2017-05-09 9:46 ` Michal Hocko 2017-05-09 9:46 ` Michal Hocko 2017-05-09 9:46 ` Michal Hocko 2017-05-09 13:07 ` Pasha Tatashin 2017-05-09 13:07 ` Pasha Tatashin 2017-05-05 13:29 ` Michal Hocko 2017-05-05 13:29 ` Michal Hocko 2017-05-17 15:51 ` Pasha Tatashin 2017-05-17 15:51 ` Pasha Tatashin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1488432825-92126-3-git-send-email-pasha.tatashin@oracle.com \ --to=pasha.tatashin@oracle.com \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=sparclinux@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.