Received: by 10.192.165.156 with SMTP id m28csp1323422imm; Wed, 18 Apr 2018 07:56:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx493DEuP3xCXPROCQ+sJToyUIv/X5QtuM6neXJbl1V7FDNk6fev4dXKkPEX65c2ZlAFzkdO/ X-Received: by 10.99.143.69 with SMTP id r5mr2019160pgn.159.1524063412491; Wed, 18 Apr 2018 07:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524063412; cv=none; d=google.com; s=arc-20160816; b=Cmryiks5T4507FFxQLzV8oHilrIUYbHchk3zr0VNbAN7IJTY66vg1gZyyVS865hsf6 9NpzBJKaPL56Dv2MCa0HmAvtel3+MZ3u3Cf5O3HitL7ISZbMWk2UYq1xUtT+XeWLurkg oZprugSZad3PXMxl5qyPVgbu40Kzz36o9RQ5Z2dq+0UU5Iv4Qx5frLOZzFFsVmS1Geav FtSZ5w9Bmd4wvbluLYT0XIjpKAWoGBJGRb/GzlVBQNC8xF/qQ2Gg0IMLSLNRTpBYNk41 8LWj6j+qxnriVjLPTey1nEPpGEWp0ysi7pg7dbPF2Q4c0zB0cP4Z5lHt6diQCz6TRiu6 8N0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=KwI1ow9otKQXbluT8Oy6179hYIkiVFfO5DLPG1E9LLc=; b=rOBftdehl0Nt2EMUl2amE2GRhRX2V3EwYJCMkRXhhh1jEPo/yQxHFX+/bVIepCuii0 iZOomv0jvxqshYZ4MIIVIeWqyHxs4I+WJhfLmbf2MDWm18UW2lEw82lGt0Jszdf7JmQj 3lURnoTUS+bcifb5M9DjYiMI0vi+BX9XMuMNuwdFGb6RuXX08B5mfizJtD3iivJ2s/UR TDI13CDV2K6u7+ECI1SoBI0tdkZFrtRYFaWDepyKThKkMqsASyWqRRFvQK4TlF0wA3Vp g0f2aMIlyI953MDz2yqcZQ6f6xWPxsn9ZkvLCmh67O+HmR0Me5fCIHROlKKEcrlQW1WN Qf6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si1236806pgn.283.2018.04.18.07.56.38; Wed, 18 Apr 2018 07:56:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752940AbeDROzf (ORCPT + 99 others); Wed, 18 Apr 2018 10:55:35 -0400 Received: from resqmta-ch2-03v.sys.comcast.net ([69.252.207.35]:48032 "EHLO resqmta-ch2-03v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751520AbeDROze (ORCPT ); Wed, 18 Apr 2018 10:55:34 -0400 Received: from resomta-ch2-08v.sys.comcast.net ([69.252.207.104]) by resqmta-ch2-03v.sys.comcast.net with ESMTP id 8oUAfoR1UDeSm8oUff15mR; Wed, 18 Apr 2018 14:55:33 +0000 Received: from gentwo.org ([98.222.162.64]) by resomta-ch2-08v.sys.comcast.net with SMTP id 8oUdfGRb781MX8oUefn27h; Wed, 18 Apr 2018 14:55:33 +0000 Received: by gentwo.org (Postfix, from userid 1001) id BEB161161663; Wed, 18 Apr 2018 09:55:31 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id BC4C7116047F; Wed, 18 Apr 2018 09:55:31 -0500 (CDT) Date: Wed, 18 Apr 2018 09:55:31 -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: MS4wfJIbBmtwaC84OzRwukLpY4FU6v2BVCj6ygV+ot+D2DoJw8aDlnMDNoT7/DK1qc6viwQivtFkS2K/TOxh1O6ACpNWDzC6lCyJQvNtUqrOmpohBcqQCu2n kdoCBMamu6Kq/E+ATTnIb9ww5spH5W8dmclWeuTuX+U8S7vmq3Sb2UXsJNr8zWpMFxqy8YcCwlNt6F16N/yL2pd14O4sMH+Tn1nNcG3RDZnSjyDBs2Zeh5+G m+3jLh8aKRLKLtzMV834qRZp0skgfSBHYBIctdbepQ+3QkWuezHJhUq8ZsFKZmNSA0ME9t4uQwpBIkHDmr7BUytpqpkAmGWaHjq88qhjNLzhtoRGHtnwD73y qh+E8I5AHzv8SoVHZLKkrwmMOD2c2rHTDLJAm91eiSl0XMegX6l5gBmVtqvpnNb2SM6rYqFOYO0Rr19/q7W/65Zl1tr+xlT1BpClTRO7CqamR8Q3/JjT2Q7U SDmoiRgdJvigCnln Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Apr 2018, Mikulas Patocka wrote: > I can make a slub-only patch with no extra flag (on a freshly booted > system it increases only the order of caches "TCPv6" and "sighand_cache" > by one - so it should not have unexpected effects): > > Doing a generic solution for slab would be more comlpicated because slab > assumes that all slabs have the same order, so it can't fall-back to > lower-order allocations. Well again SLAB uses compound pages and thus would be able to detect the size of the page. It may be some work but it could be done. > > Index: linux-2.6/mm/slub.c > =================================================================== > --- linux-2.6.orig/mm/slub.c 2018-04-17 19:59:49.000000000 +0200 > +++ linux-2.6/mm/slub.c 2018-04-17 20:58:23.000000000 +0200 > @@ -3252,6 +3252,7 @@ static inline unsigned int slab_order(un > static inline int calculate_order(unsigned int size, unsigned int reserved) > { > unsigned int order; > + unsigned int test_order; > unsigned int min_objects; > unsigned int max_objects; > > @@ -3277,7 +3278,7 @@ static inline int calculate_order(unsign > order = slab_order(size, min_objects, > slub_max_order, fraction, reserved); > if (order <= slub_max_order) > - return order; > + goto ret_order; > fraction /= 2; > } > min_objects--; > @@ -3289,15 +3290,25 @@ static inline int calculate_order(unsign > */ > order = slab_order(size, 1, slub_max_order, 1, reserved); The slab order is determined in slab_order() > if (order <= slub_max_order) > - return order; > + goto ret_order; > > /* > * Doh this slab cannot be placed using slub_max_order. > */ > order = slab_order(size, 1, MAX_ORDER, 1, reserved); > - if (order < MAX_ORDER) > - return order; > - return -ENOSYS; > + if (order >= MAX_ORDER) > + return -ENOSYS; > + > +ret_order: > + for (test_order = order + 1; test_order < MAX_ORDER; test_order++) { > + unsigned long order_objects = ((PAGE_SIZE << order) - reserved) / size; > + unsigned long test_order_objects = ((PAGE_SIZE << test_order) - reserved) / size; > + if (test_order_objects > min(32, MAX_OBJS_PER_PAGE)) > + break; > + if (test_order_objects > order_objects << (test_order - order)) > + order = test_order; > + } > + return order; Could yo move that logic into slab_order()? It does something awfully similar.