Received: by 10.192.165.156 with SMTP id m28csp1094448imm; Mon, 16 Apr 2018 14:04:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+VRa6C4JFVsXOPNO4X8oKMsJae/OW/JWu+OoaJukER8xtrGtrq4p+/BPJFnfBpj5ZqWjvC X-Received: by 10.101.65.4 with SMTP id w4mr14452290pgp.413.1523912644177; Mon, 16 Apr 2018 14:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523912644; cv=none; d=google.com; s=arc-20160816; b=v8amDZRxXan2mlXcYpITT4lPVJMrMYIwISrXzXwQoh2dU2JxrBDDGsZ/kDAThSTmYL Dvdqt3r/eItDEFaLVydGqUA9iohU/7bb4Ub5gXAmD8/43SDJru7W9xB0++GPgFjvPwX5 IuJTpeEpcB+Hebv/YwaWFFlL0SD2tengFfbvZ8hvM1QReSoGGBkor78TuZOV7jVHmiTg ooDXwpXAr+KbAoSzI8LZfRIdfCaUon5tP7tlACSEHy+hRf98xg783zrW4gmQnHWR0d4s qMPqE3aveU3xtyLt+EItjxVSF5QtQP6UTcOxxDFN4WmRe+uiG2xjoLnNOnFgMXrVmtau 1fig== 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=HnYqCq881S9HKjPS0pUrfJAklwbFZiDF2kR1w9o+D30=; b=tWkNNgQORSiB47oF+lywd/Jjro09ESb9XIzVJl2lybXiCwuOpgTdoRkiO36JFhTq4h mRIlquRO5grt94TGSq2Z9NAA4of9HIJFGinzWlLC0tsCOu4GXvMP9c0b7gHg54oitpXV CIVIZACbkPqnnuP+CN/8lZ9cqcoHEbqu8nvIgUpDFLa2ZYfX7q+Zf7Xu1PEv8C5kWWwQ B/u0iYOIjsY7NaLZIuOzBWtOYJwD45rOgyccRSj7Yws31K/FBnxG8HtI1iSvtkys8QYn +iqTKYd49/cAbGMKBT729ugeaU5p7piUaJDD/MUl+CM/pwaQOjC9NzbjRU7Cyhk26G/r p7zw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si3998144plt.358.2018.04.16.14.03.49; Mon, 16 Apr 2018 14:04:04 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751157AbeDPVBR (ORCPT + 99 others); Mon, 16 Apr 2018 17:01:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51366 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750709AbeDPVBQ (ORCPT ); Mon, 16 Apr 2018 17:01:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EDA28DC23; Mon, 16 Apr 2018 21:01:15 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 226DD2026DFD; Mon, 16 Apr 2018 21:01:15 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w3GL1Fcl021284; Mon, 16 Apr 2018 17:01:15 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w3GL1DmQ021279; Mon, 16 Apr 2018 17:01:13 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Mon, 16 Apr 2018 17:01:13 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Vlastimil Babka cc: Christopher Lameter , 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 Subject: Re: 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.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 21:01:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 21:01:15 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Apr 2018, Vlastimil Babka wrote: > On 04/16/2018 09:36 PM, Mikulas Patocka wrote: > > >>> I need to increase it just for dm-bufio slabs. > >> > >> If you do this then others will want the same... > > > > If others need it, they can turn on the flag SLAB_MINIMIZE_WASTE too. > > I think it should be possible without a new flag. The slub allocator > could just balance priorities (performance vs memory efficiency) better. > Currently I get the impression that "slub_max_order" is a performance > tunable. Let's add another criteria for selecting an order, that would > try to pick an order to minimize wasted space below e.g. 10% with some > different kind of max order. Pick good defaults, add tunables if you must. > > I mean, anyone who's creating a cache for 640KB objects most likely > doesn't want to waste another 384KB by each such object. They shouldn't > have to add a flag to let the slub allocator figure out that using 2MB > pages is the right thing to do here. > > Vlastimil The problem is that higher-order allocations (larger than 32K) are unreliable. So, if you increase page order beyond that, the allocation may randomly fail. dm-bufio deals gracefully with allocation failure, because it preallocates some buffers with vmalloc, but other subsystems may not deal with it and they cound return ENOMEM randomly or misbehave in other ways. So, the "SLAB_MINIMIZE_WASTE" flag is also saying that the allocation may fail and the caller is prepared to deal with it. The slub subsystem does actual fallback to low-order when the allocation fails (it allows different order for each slab in the same cache), but slab doesn't fallback and you get NULL if higher-order allocation fails. So, SLAB_MINIMIZE_WASTE is needed for slab because it will just randomly fail with higher order. Mikulas