From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758720AbeD0Qlv (ORCPT ); Fri, 27 Apr 2018 12:41:51 -0400 Received: from resqmta-ch2-11v.sys.comcast.net ([69.252.207.43]:48498 "EHLO resqmta-ch2-11v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757569AbeD0Qlu (ORCPT ); Fri, 27 Apr 2018 12:41:50 -0400 Date: Fri, 27 Apr 2018 11:41:48 -0500 (CDT) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Mikulas Patocka cc: Mike Snitzer , Vlastimil Babka , Matthew Wilcox , Pekka Enberg , linux-mm@kvack.org, dm-devel@redhat.com, David Rientjes , Joonsoo Kim , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] slab: introduce the flag SLAB_MINIMIZE_WASTE In-Reply-To: Message-ID: References: <20c58a03-90a8-7e75-5fc7-856facfb6c8a@suse.cz> <20180413151019.GA5660@redhat.com> <20180416142703.GA22422@redhat.com> <20180416144638.GA22484@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfKRd0xxBHiYG40oJPrc/urVxdNRBR2q1ftF+CpTOFADAnP3G9v8Fs1bp6ldks2HkwS19ocdQQ21oEBiJ2WA8kn9QlLOHaKCxI4oxhcGJjmSOQeq804PC s1KNGzW3wDaAtFRzWiqgoKcYE3DLSkPwMGVV737LGqYsT+jlmfajXJ/7ULM6KqbDAhciRs9RUvS24SboETlf2HGCJAO6rPXsc5Alu5doY+pPaCm53G3fe440 Xxzeglr8uyElq5RQZm7zOZDRJvcTSsTNUyfH0kHKD/hTl/wN9eVwC16Dppqd8+CImYuapnFqVHEGO5APlpkjwqVgGHHFSXtTKHtWs16hUY8PsUWhNVI2opQt dxXuSDMC5ak3YdwhQOE0C+y3PwOXnxUIwfC5YtlcX7lRcounEkiWKcIp2bew8PBszAL2+HDSlIoI8ryhtZXP4/n2bleGqeldHzG382f2yYR3gp4EhkW9j/G/ g9OBXOXMnkTaYZgY Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Apr 2018, Mikulas Patocka wrote: > > Hmmm... order 4 for these caches may cause some concern. These should stay > > under costly order I think. Otherwise allocations are no longer > > guaranteed. > > You said that slub has fallback to smaller order allocations. Yes it does... > The whole purpose of this "minimize waste" approach is to use higher-order > allocations to use memory more efficiently, so it is just doing its job. > (for these 3 caches, order-4 really wastes less memory than order-3 - on > my system TCPv6 and sighand_cache have size 2112, task_struct 2752). Hmmm... Ok if the others are fine with this as well. I got some pushback there in the past. > We could improve the fallback code, so that if order-4 allocation fails, > it tries order-3 allocation, and then falls back to order-0. But I think > that these failures are rare enough that it is not a problem. I also think that would be too many fallbacks. > > > + /* Increase order even more, but only if it reduces waste */ > > > + if (test_order_obj <= 32 && > > > > Where does the 32 come from? > > It is to avoid extremely high order for extremely small slabs. > > For example, see kmalloc-96. > 10922 96-byte objects would fit into 1MiB > 21845 96-byte objects would fit into 2MiB That is the result of considering absolute byte wastage.. > The algorithm would recognize this one more object that fits into 2MiB > slab as "waste reduction" and increase the order to 2MiB - and we don't > want this. > > So, the general reasoning is - if we have 32 objects in a slab, then it is > already considered that wasted space is reasonably low and we don't want > to increase the order more. > > Currently, kmalloc-96 uses order-0 - that is reasonable (we already have > 42 objects in 4k page, so we don't need to use higher order, even if it > wastes one-less object). The old code uses the concept of a "fraction" to calculate overhead. The code here uses absolute counts of bytes. Fraction looks better to me.