summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorVasily Averin <vvs@virtuozzo.com>2018-11-16 18:08:11 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-11-18 13:15:09 -0500
commit873d7bcfd066663e3e50113dc4a0de19289b6354 (patch)
treee9be2db8ec7c81c1e6eb3404a2178336a7df5d7b /mm
parentf341e16fb67ddc199582d187b0d39120a9dfd2bf (diff)
mm/swapfile.c: use kvzalloc for swap_info_struct allocation
Commit a2468cc9bfdf ("swap: choose swap device according to numa node") changed 'avail_lists' field of 'struct swap_info_struct' to an array. In popular linux distros it increased size of swap_info_struct up to 40 Kbytes and now swap_info_struct allocation requires order-4 page. Switch to kvzmalloc allows to avoid unexpected allocation failures. Link: http://lkml.kernel.org/r/fc23172d-3c75-21e2-d551-8b1808cbe593@virtuozzo.com Fixes: a2468cc9bfdf ("swap: choose swap device according to numa node") Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Acked-by: Aaron Lu <aaron.lu@intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Huang Ying <ying.huang@intel.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/swapfile.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 644f746e167a..8688ae65ef58 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2813,7 +2813,7 @@ static struct swap_info_struct *alloc_swap_info(void)
2813 unsigned int type; 2813 unsigned int type;
2814 int i; 2814 int i;
2815 2815
2816 p = kzalloc(sizeof(*p), GFP_KERNEL); 2816 p = kvzalloc(sizeof(*p), GFP_KERNEL);
2817 if (!p) 2817 if (!p)
2818 return ERR_PTR(-ENOMEM); 2818 return ERR_PTR(-ENOMEM);
2819 2819
@@ -2824,7 +2824,7 @@ static struct swap_info_struct *alloc_swap_info(void)
2824 } 2824 }
2825 if (type >= MAX_SWAPFILES) { 2825 if (type >= MAX_SWAPFILES) {
2826 spin_unlock(&swap_lock); 2826 spin_unlock(&swap_lock);
2827 kfree(p); 2827 kvfree(p);
2828 return ERR_PTR(-EPERM); 2828 return ERR_PTR(-EPERM);
2829 } 2829 }
2830 if (type >= nr_swapfiles) { 2830 if (type >= nr_swapfiles) {
@@ -2838,7 +2838,7 @@ static struct swap_info_struct *alloc_swap_info(void)
2838 smp_wmb(); 2838 smp_wmb();
2839 nr_swapfiles++; 2839 nr_swapfiles++;
2840 } else { 2840 } else {
2841 kfree(p); 2841 kvfree(p);
2842 p = swap_info[type]; 2842 p = swap_info[type];
2843 /* 2843 /*
2844 * Do not memset this entry: a racing procfs swap_next() 2844 * Do not memset this entry: a racing procfs swap_next()