From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbdANCpR (ORCPT ); Fri, 13 Jan 2017 21:45:17 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:45435 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751021AbdANCpQ (ORCPT ); Fri, 13 Jan 2017 21:45:16 -0500 Subject: Re: [PATCH 2/6] mm: support __GFP_REPEAT in kvmalloc_node for >=64kB To: Michal Hocko , Andrew Morton References: <20170112153717.28943-1-mhocko@kernel.org> <20170112153717.28943-3-mhocko@kernel.org> Cc: Vlastimil Babka , David Rientjes , Mel Gorman , Johannes Weiner , Al Viro , linux-mm@kvack.org, LKML , Michal Hocko , "Michael S. Tsirkin" From: Tetsuo Handa Message-ID: Date: Sat, 14 Jan 2017 11:42:09 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170112153717.28943-3-mhocko@kernel.org> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/01/13 0:37, Michal Hocko wrote: > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c > index 5dc34653274a..105cd04c7414 100644 > --- a/drivers/vhost/net.c > +++ b/drivers/vhost/net.c > @@ -797,12 +797,9 @@ static int vhost_net_open(struct inode *inode, struct file *f) > struct vhost_virtqueue **vqs; > int i; > > - n = kmalloc(sizeof *n, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); > - if (!n) { > - n = vmalloc(sizeof *n); > - if (!n) > - return -ENOMEM; > - } > + n = kvmalloc(sizeof *n, GFP_KERNEL | __GFP_REPEAT); An opportunity to standardize as sizeof(*n) like other allocations. > diff --git a/mm/util.c b/mm/util.c > index 7e0c240b5760..9306244b9f41 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -333,7 +333,8 @@ EXPORT_SYMBOL(vm_mmap); > * Uses kmalloc to get the memory but if the allocation fails then falls back > * to the vmalloc allocator. Use kvfree for freeing the memory. > * > - * Reclaim modifiers - __GFP_NORETRY, __GFP_REPEAT and __GFP_NOFAIL are not supported > + * Reclaim modifiers - __GFP_NORETRY and __GFP_NOFAIL are not supported. __GFP_REPEAT > + * is supported only for large (>64kB) allocations Isn't this ">32kB" (i.e. __GFP_REPEAT is supported for 64kB allocation) ? > */ > void *kvmalloc_node(size_t size, gfp_t flags, int node) > { > @@ -350,8 +351,18 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node) > * Make sure that larger requests are not too disruptive - no OOM > * killer and no allocation failure warnings as we have a fallback > */ > - if (size > PAGE_SIZE) > - kmalloc_flags |= __GFP_NORETRY | __GFP_NOWARN; > + if (size > PAGE_SIZE) { > + kmalloc_flags |= __GFP_NOWARN; > + > + /* > + * We have to override __GFP_REPEAT by __GFP_NORETRY for !costly > + * requests because there is no other way to tell the allocator > + * that we want to fail rather than retry endlessly. > + */ > + if (!(kmalloc_flags & __GFP_REPEAT) || > + (size <= PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) > + kmalloc_flags |= __GFP_NORETRY; > + } > > ret = kmalloc_node(size, kmalloc_flags, node); > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-f200.google.com (mail-yw0-f200.google.com [209.85.161.200]) by kanga.kvack.org (Postfix) with ESMTP id 1C9F86B0033 for ; Fri, 13 Jan 2017 21:44:14 -0500 (EST) Received: by mail-yw0-f200.google.com with SMTP id u68so78155337ywg.4 for ; Fri, 13 Jan 2017 18:44:14 -0800 (PST) Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [2001:e42:101:1:202:181:97:72]) by mx.google.com with ESMTPS id f185si4137632ywd.95.2017.01.13.18.44.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Jan 2017 18:44:12 -0800 (PST) Subject: Re: [PATCH 2/6] mm: support __GFP_REPEAT in kvmalloc_node for >=64kB References: <20170112153717.28943-1-mhocko@kernel.org> <20170112153717.28943-3-mhocko@kernel.org> From: Tetsuo Handa Message-ID: Date: Sat, 14 Jan 2017 11:42:09 +0900 MIME-Version: 1.0 In-Reply-To: <20170112153717.28943-3-mhocko@kernel.org> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Andrew Morton Cc: Vlastimil Babka , David Rientjes , Mel Gorman , Johannes Weiner , Al Viro , linux-mm@kvack.org, LKML , Michal Hocko , "Michael S. Tsirkin" On 2017/01/13 0:37, Michal Hocko wrote: > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c > index 5dc34653274a..105cd04c7414 100644 > --- a/drivers/vhost/net.c > +++ b/drivers/vhost/net.c > @@ -797,12 +797,9 @@ static int vhost_net_open(struct inode *inode, struct file *f) > struct vhost_virtqueue **vqs; > int i; > > - n = kmalloc(sizeof *n, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); > - if (!n) { > - n = vmalloc(sizeof *n); > - if (!n) > - return -ENOMEM; > - } > + n = kvmalloc(sizeof *n, GFP_KERNEL | __GFP_REPEAT); An opportunity to standardize as sizeof(*n) like other allocations. > diff --git a/mm/util.c b/mm/util.c > index 7e0c240b5760..9306244b9f41 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -333,7 +333,8 @@ EXPORT_SYMBOL(vm_mmap); > * Uses kmalloc to get the memory but if the allocation fails then falls back > * to the vmalloc allocator. Use kvfree for freeing the memory. > * > - * Reclaim modifiers - __GFP_NORETRY, __GFP_REPEAT and __GFP_NOFAIL are not supported > + * Reclaim modifiers - __GFP_NORETRY and __GFP_NOFAIL are not supported. __GFP_REPEAT > + * is supported only for large (>64kB) allocations Isn't this ">32kB" (i.e. __GFP_REPEAT is supported for 64kB allocation) ? > */ > void *kvmalloc_node(size_t size, gfp_t flags, int node) > { > @@ -350,8 +351,18 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node) > * Make sure that larger requests are not too disruptive - no OOM > * killer and no allocation failure warnings as we have a fallback > */ > - if (size > PAGE_SIZE) > - kmalloc_flags |= __GFP_NORETRY | __GFP_NOWARN; > + if (size > PAGE_SIZE) { > + kmalloc_flags |= __GFP_NOWARN; > + > + /* > + * We have to override __GFP_REPEAT by __GFP_NORETRY for !costly > + * requests because there is no other way to tell the allocator > + * that we want to fail rather than retry endlessly. > + */ > + if (!(kmalloc_flags & __GFP_REPEAT) || > + (size <= PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) > + kmalloc_flags |= __GFP_NORETRY; > + } > > ret = kmalloc_node(size, kmalloc_flags, 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: email@kvack.org