From: Mikulas Patocka <mpatocka@redhat.com> To: Michal Hocko <mhocko@suse.com>, Andrew Morton <akpm@linux-foundation.org>, Stephen Rothwell <sfr@canb.auug.org.au> Cc: Vlastimil Babka <vbabka@suse.cz>, Andreas Dilger <adilger@dilger.ca>, John Hubbard <jhubbard@nvidia.com>, David Miller <davem@davemloft.net>, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm: convert three more cases to kvmalloc Date: Wed, 28 Jun 2017 23:24:10 -0400 (EDT) [thread overview] Message-ID: <alpine.LRH.2.02.1706282317480.11892@file01.intranet.prod.int.rdu2.redhat.com> (raw) Hi I'm submitting this for the next merge window. Mikulas From: Mikulas Patocka <mpatocka@redhat.com> The patch a7c3e901 ("mm: introduce kv[mz]alloc helpers") converted a lot of kernel code to kvmalloc. This patch converts three more forgotten cases. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> --- fs/file.c | 12 +----------- kernel/bpf/syscall.c | 11 +---------- kernel/cgroup/cgroup-v1.c | 7 +------ 3 files changed, 3 insertions(+), 27 deletions(-) Index: linux-2.6/fs/file.c =================================================================== --- linux-2.6.orig/fs/file.c +++ linux-2.6/fs/file.c @@ -32,17 +32,7 @@ unsigned int sysctl_nr_open_max = static void *alloc_fdmem(size_t size) { - /* - * Very large allocations can stress page reclaim, so fall back to - * vmalloc() if the allocation size will be considered "large" by the VM. - */ - if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { - void *data = kmalloc(size, GFP_KERNEL_ACCOUNT | - __GFP_NOWARN | __GFP_NORETRY); - if (data != NULL) - return data; - } - return __vmalloc(size, GFP_KERNEL_ACCOUNT, PAGE_KERNEL); + return kvmalloc(size, GFP_KERNEL_ACCOUNT); } static void __free_fdtable(struct fdtable *fdt) Index: linux-2.6/kernel/bpf/syscall.c =================================================================== --- linux-2.6.orig/kernel/bpf/syscall.c +++ linux-2.6/kernel/bpf/syscall.c @@ -58,16 +58,7 @@ void *bpf_map_area_alloc(size_t size) * trigger under memory pressure as we really just want to * fail instead. */ - const gfp_t flags = __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO; - void *area; - - if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { - area = kmalloc(size, GFP_USER | flags); - if (area != NULL) - return area; - } - - return __vmalloc(size, GFP_KERNEL | flags, PAGE_KERNEL); + return kvmalloc(size, GFP_USER | __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO); } void bpf_map_area_free(void *area) Index: linux-2.6/kernel/cgroup/cgroup-v1.c =================================================================== --- linux-2.6.orig/kernel/cgroup/cgroup-v1.c +++ linux-2.6/kernel/cgroup/cgroup-v1.c @@ -184,15 +184,10 @@ struct cgroup_pidlist { /* * The following two functions "fix" the issue where there are more pids * than kmalloc will give memory for; in such cases, we use vmalloc/vfree. - * TODO: replace with a kernel-wide solution to this problem */ -#define PIDLIST_TOO_LARGE(c) ((c) * sizeof(pid_t) > (PAGE_SIZE * 2)) static void *pidlist_allocate(int count) { - if (PIDLIST_TOO_LARGE(count)) - return vmalloc(count * sizeof(pid_t)); - else - return kmalloc(count * sizeof(pid_t), GFP_KERNEL); + return kvmalloc(count * sizeof(pid_t), GFP_KERNEL); } static void pidlist_free(void *p)
WARNING: multiple messages have this Message-ID (diff)
From: Mikulas Patocka <mpatocka@redhat.com> To: Michal Hocko <mhocko@suse.com>, Andrew Morton <akpm@linux-foundation.org>, Stephen Rothwell <sfr@canb.auug.org.au> Cc: Vlastimil Babka <vbabka@suse.cz>, Andreas Dilger <adilger@dilger.ca>, John Hubbard <jhubbard@nvidia.com>, David Miller <davem@davemloft.net>, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm: convert three more cases to kvmalloc Date: Wed, 28 Jun 2017 23:24:10 -0400 (EDT) [thread overview] Message-ID: <alpine.LRH.2.02.1706282317480.11892@file01.intranet.prod.int.rdu2.redhat.com> (raw) Hi I'm submitting this for the next merge window. Mikulas From: Mikulas Patocka <mpatocka@redhat.com> The patch a7c3e901 ("mm: introduce kv[mz]alloc helpers") converted a lot of kernel code to kvmalloc. This patch converts three more forgotten cases. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> --- fs/file.c | 12 +----------- kernel/bpf/syscall.c | 11 +---------- kernel/cgroup/cgroup-v1.c | 7 +------ 3 files changed, 3 insertions(+), 27 deletions(-) Index: linux-2.6/fs/file.c =================================================================== --- linux-2.6.orig/fs/file.c +++ linux-2.6/fs/file.c @@ -32,17 +32,7 @@ unsigned int sysctl_nr_open_max = static void *alloc_fdmem(size_t size) { - /* - * Very large allocations can stress page reclaim, so fall back to - * vmalloc() if the allocation size will be considered "large" by the VM. - */ - if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { - void *data = kmalloc(size, GFP_KERNEL_ACCOUNT | - __GFP_NOWARN | __GFP_NORETRY); - if (data != NULL) - return data; - } - return __vmalloc(size, GFP_KERNEL_ACCOUNT, PAGE_KERNEL); + return kvmalloc(size, GFP_KERNEL_ACCOUNT); } static void __free_fdtable(struct fdtable *fdt) Index: linux-2.6/kernel/bpf/syscall.c =================================================================== --- linux-2.6.orig/kernel/bpf/syscall.c +++ linux-2.6/kernel/bpf/syscall.c @@ -58,16 +58,7 @@ void *bpf_map_area_alloc(size_t size) * trigger under memory pressure as we really just want to * fail instead. */ - const gfp_t flags = __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO; - void *area; - - if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { - area = kmalloc(size, GFP_USER | flags); - if (area != NULL) - return area; - } - - return __vmalloc(size, GFP_KERNEL | flags, PAGE_KERNEL); + return kvmalloc(size, GFP_USER | __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO); } void bpf_map_area_free(void *area) Index: linux-2.6/kernel/cgroup/cgroup-v1.c =================================================================== --- linux-2.6.orig/kernel/cgroup/cgroup-v1.c +++ linux-2.6/kernel/cgroup/cgroup-v1.c @@ -184,15 +184,10 @@ struct cgroup_pidlist { /* * The following two functions "fix" the issue where there are more pids * than kmalloc will give memory for; in such cases, we use vmalloc/vfree. - * TODO: replace with a kernel-wide solution to this problem */ -#define PIDLIST_TOO_LARGE(c) ((c) * sizeof(pid_t) > (PAGE_SIZE * 2)) static void *pidlist_allocate(int count) { - if (PIDLIST_TOO_LARGE(count)) - return vmalloc(count * sizeof(pid_t)); - else - return kmalloc(count * sizeof(pid_t), GFP_KERNEL); + return kvmalloc(count * sizeof(pid_t), GFP_KERNEL); } static void pidlist_free(void *p) -- 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>
next reply other threads:[~2017-06-29 3:24 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-06-29 3:24 Mikulas Patocka [this message] 2017-06-29 3:24 ` [PATCH] mm: convert three more cases to kvmalloc Mikulas Patocka 2017-06-29 7:10 ` Michal Hocko 2017-06-29 7:10 ` Michal Hocko 2017-06-30 2:13 ` Mikulas Patocka 2017-06-30 2:13 ` Mikulas Patocka 2017-06-30 7:21 ` Michal Hocko 2017-06-30 7:21 ` Michal Hocko
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=alpine.LRH.2.02.1706282317480.11892@file01.intranet.prod.int.rdu2.redhat.com \ --to=mpatocka@redhat.com \ --cc=adilger@dilger.ca \ --cc=akpm@linux-foundation.org \ --cc=davem@davemloft.net \ --cc=jhubbard@nvidia.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mhocko@suse.com \ --cc=sfr@canb.auug.org.au \ --cc=vbabka@suse.cz \ /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.