Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701AbcD1PlE (ORCPT ); Thu, 28 Apr 2016 11:41:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45974 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbcD1PlB (ORCPT ); Thu, 28 Apr 2016 11:41:01 -0400 Date: Thu, 28 Apr 2016 11:40:59 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Michal Hocko cc: Andrew Morton , linux-mm@kvack.org, LKML , Shaohua Li , dm-devel@redhat.com Subject: Re: [PATCH] md: simplify free_params for kmalloc vs vmalloc fallback In-Reply-To: <20160428152812.GM31489@dhcp22.suse.cz> Message-ID: References: <1461849846-27209-20-git-send-email-mhocko@kernel.org> <1461855076-1682-1-git-send-email-mhocko@kernel.org> <20160428152812.GM31489@dhcp22.suse.cz> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 28 Apr 2016 15:41:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1379 Lines: 50 On Thu, 28 Apr 2016, Michal Hocko wrote: > On Thu 28-04-16 11:04:05, Mikulas Patocka wrote: > > Acked-by: Mikulas Patocka > > Thanks! > > > BTW. we could also use kvmalloc to complement kvfree, proposed here: > > https://www.redhat.com/archives/dm-devel/2015-July/msg00046.html > > If there are sufficient users (I haven't checked other than quick git > grep on KMALLOC_MAX_SIZE the problem is that kmallocs with large sizes near KMALLOC_MAX_SIZE are unreliable, they'll randomly fail if memory is too fragmented. > and there do not seem that many) who are > sharing the same fallback strategy then why not. But I suspect that some > would rather fallback earlier and even do not attempt larger than e.g. > order-1 requests. > -- > Michal Hocko > SUSE Labs There are many users that use one of these patterns: if (size <= some_threshold) p = kmalloc(size); else p = vmalloc(size); or p = kmalloc(size); if (!p) p = vmalloc(size); For example: alloc_fdmem, seq_buf_alloc, setxattr, getxattr, ipc_alloc, pidlist_allocate, get_pages_array, alloc_bucket_locks, frame_vector_create. If you grep the kernel for vmalloc, you'll find this pattern over and over again. In alloc_large_system_hash, there is table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL); - that is clearly wrong because __vmalloc doesn't respect GFP_ATOMIC Mikulas