From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id 139906B0012 for ; Tue, 17 Apr 2018 12:18:14 -0400 (EDT) Received: by mail-wr0-f197.google.com with SMTP id 38so15516174wrv.8 for ; Tue, 17 Apr 2018 09:18:14 -0700 (PDT) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id p25si1848526edi.103.2018.04.17.09.18.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Apr 2018 09:18:12 -0700 (PDT) Subject: Re: [PATCH RESEND] slab: introduce the flag SLAB_MINIMIZE_WASTE References: <20c58a03-90a8-7e75-5fc7-856facfb6c8a@suse.cz> <20180413151019.GA5660@redhat.com> <20180416142703.GA22422@redhat.com> <20180416144638.GA22484@redhat.com> From: Vlastimil Babka Message-ID: Date: Tue, 17 Apr 2018 18:16:13 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Christopher Lameter , Mikulas Patocka Cc: Mike Snitzer , Matthew Wilcox , Pekka Enberg , linux-mm@kvack.org, dm-devel@redhat.com, David Rientjes , Joonsoo Kim , Andrew Morton , linux-kernel@vger.kernel.org On 04/17/2018 04:45 PM, Christopher Lameter wrote: > On Mon, 16 Apr 2018, Mikulas Patocka wrote: > >> This patch introduces a flag SLAB_MINIMIZE_WASTE for slab and slub. This >> flag causes allocation of larger slab caches in order to minimize wasted >> space. >> >> This is needed because we want to use dm-bufio for deduplication index and >> there are existing installations with non-power-of-two block sizes (such >> as 640KB). The performance of the whole solution depends on efficient >> memory use, so we must waste as little memory as possible. > > Hmmm. Can we come up with a generic solution instead? Yes please. > This may mean relaxing the enforcement of the allocation max order a bit > so that we can get dense allocation through higher order allocs. > > But then higher order allocs are generally seen as problematic. I think in this case they are better than wasting/fragmenting 384kB for 640kB object. > Note that SLUB will fall back to smallest order already if a failure > occurs so increasing slub_max_order may not be that much of an issue. > > Maybe drop the max order limit completely and use MAX_ORDER instead? For packing, sure. For performance, please no (i.e. don't try to allocate MAX_ORDER for each and every cache). > That > means that callers need to be able to tolerate failures. Is it any different from now? I suppose there would still be smallest-order fallback involved in sl*b itself? And if your allocation is so large it can fail even with the fallback (i.e. >= costly order), you need to tolerate failures anyway? One corner case I see is if there is anyone who would rather use their own fallback instead of the space-wasting smallest-order fallback. Maybe we could map some GFP flag to indicate that. >