Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3563857pxb; Mon, 18 Oct 2021 18:28:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9eiZ3xeCEN6b/pxXhYv637x+tTFX/aB+k1VO6fMEYd6773N2zfL32zCDkNsfi4SFbgKJe X-Received: by 2002:a05:6402:1a56:: with SMTP id bf22mr39191208edb.208.1634606906148; Mon, 18 Oct 2021 18:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634606906; cv=none; d=google.com; s=arc-20160816; b=bl90p03wuAJfizoBmkpP15IUZq5yNibgWL/ZZ1J5kLzXJl7H3bU3gxFEMVWFDV4WtS VR0/NgZ1SxmIOUn+MM5hVzbEVjwGjgvjIjdA/FiXIHT55qHDSAK1UCQN5LGRNz2MDv+Z 6RT7ZKJYdpqNiNrcLLQ67AKAPcKlnq9lv5qmbjdSsk3X+Xk2Md3ItErPZkR4cAnb8KC3 sj/o1gUjkj67FgBnnBprTbE0pAfmY2qPPpCp0HjUoX3aWl74ZSYG0tPhqSb4r1yFI7mz 0O7YSEj1MZJCdgLPmwoG/HxU+XuXuzOdv9mae6gRZZYi0GJU1X72HJcZ/i14z213ZJCf /EPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+YOaBslX4qQWuo6l9MyOOELjnCnQrK4/rjlKQ4on+uI=; b=ojPbBmrt/U9Rx/ul2Wel9lBwPDZ/2MQdqiLRIbHL+VYImBxat8qlctzYn0JTYrViXY pZX2zaO61OILErBG4jSrgzzO9xjbrtiPA+cM6mN8kmQdep1dEj9W4SVRoU3aGJpypvbf JjsJs/qAuWie4EMwdaSZKkZp5hW4qbJ+cVjmELEeTPGilC5MI80NLFp2BPw0w23JjRtU Zb4XSZkRVsUjLZvwCudcIeqNoV/Zu8W4i0Y0JhY4FuFffOYrquBdK3QpPT08pw/Yohnr +HBBW81b3zN3TFG7nG2QCtktrjbINLoMZPwfCy5AbiFnpiEEPxH2i4vYV9NmblUH1TYs THYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PAoteaNB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si21795347ejb.449.2021.10.18.18.28.02; Mon, 18 Oct 2021 18:28:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PAoteaNB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbhJSBYo (ORCPT + 99 others); Mon, 18 Oct 2021 21:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhJSBYn (ORCPT ); Mon, 18 Oct 2021 21:24:43 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCDB1C06161C for ; Mon, 18 Oct 2021 18:22:31 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id e65so15442914pgc.5 for ; Mon, 18 Oct 2021 18:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+YOaBslX4qQWuo6l9MyOOELjnCnQrK4/rjlKQ4on+uI=; b=PAoteaNB2U05XT9NzhUNZ8BfJ9IGdDGJbFqsLK5aGtRwHISTazk1CdeqfRIo2CsZAI pXL36igTTnJZd6SD+X6X31806gm5WTTOwqoTbCc33Hmk3K16e59AuaYmdasS6cLn0dlM yekdCRME2oRJsXVp55esvuVkOWF4smz9ZaSnycj1WIRGNT1XWurSTvuzc9gv13FmcEDR RB8823pD6E09XjA6Xf2Enk3MJy3q7gwQjwI83eIbAB8DPVVYsOck8j1BxPhvFnA/AAmI 8CBbfQMmwj4wZg12thf/1n4J/IkKnY/61Ehywa+FVVl2ECG0wasuRlHwNY7T3f0pzPmc L/Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+YOaBslX4qQWuo6l9MyOOELjnCnQrK4/rjlKQ4on+uI=; b=XyKtMcezECbRX6OByynNkp92QeOf2cSSNc13x/Bn5MyAXLbyvE+Ju80VkoAlMFOeP8 qeOpPS5s3XjLZAPfrpRtzzcSxCCiilj+khEpbFUb3Vc5+47kczrFcYcPu2FqRG0oTtlq moEUoi4r5mslXkbyvqdSB0p+zX45rm1sZluyOmJWvIcpQKgjy4inD372A70EM228E5kb WMKoKJk+YuVH4+JnERwARH6AfeP6IW1featxxBNnqZWYkstox5lxv7sNUR54VNk89Out la7bJtC2xyd+cVNcbxxpUj1JwIy1an8xxP51wvz5pGLzqHFAZ+Dmq0F2dtuEsuW9ygNQ Vz8w== X-Gm-Message-State: AOAM532tKDb2B5srR2/vRgJeF2xJmr5LyFnRwfZDnSLuyiniSSFxQitw fBMDYp9d8qVNBOg80FFkqoE= X-Received: by 2002:a63:1444:: with SMTP id 4mr26015024pgu.251.1634606551172; Mon, 18 Oct 2021 18:22:31 -0700 (PDT) Received: from nuc10 (d50-92-229-34.bchsia.telus.net. [50.92.229.34]) by smtp.gmail.com with ESMTPSA id v9sm14748903pfc.23.2021.10.18.18.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 18:22:30 -0700 (PDT) Date: Mon, 18 Oct 2021 18:22:28 -0700 From: Rustam Kovhaev To: Vlastimil Babka Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, djwong@kernel.org, david@fromorbit.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, dvyukov@google.com Subject: Re: [PATCH] slob: add size header to all allocations Message-ID: References: <20211015005729.GD24333@magnolia> <20211018033841.3027515-1-rkovhaev@gmail.com> <20758764-8139-ab0b-a782-dc63559b43ba@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20758764-8139-ab0b-a782-dc63559b43ba@suse.cz> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 18, 2021 at 11:22:46AM +0200, Vlastimil Babka wrote: > On 10/18/21 05:38, Rustam Kovhaev wrote: > > Let's prepend all allocations of (PAGE_SIZE - align_offset) and less > > with the size header. This way kmem_cache_alloc() memory can be freed > > with kfree() and the other way around, as long as they are less than > > (PAGE_SIZE - align_offset). > > This size limitation seems like an unnecessary gotcha. Couldn't we make > these large allocations in slob_alloc_node() (that use slob_new_pages() > directly) similar enough to large kmalloc() ones, so that kfree() can > recognize them and free properly? AFAICS it might mean just adding > __GFP_COMP to make sure there's a compound order stored, as these already > don't seem to set PageSlab. Thanks for the pointers, I'll send a new version. > > The main reason for this change is to simplify SLOB a little bit, make > > it a bit easier to debug whenever something goes wrong. > > I would say the main reason is to simplify the slab API and guarantee that > both kmem_cache_alloc() and kmalloc() can be freed by kfree(). > > We should also update the comments at top of slob.c to reflect the change. > And Documentation/core-api/memory-allocation.rst (the last paragraph). OK, thank you! > > meminfo right after the system boot, without the patch: > > Slab: 35500 kB > > > > the same, with the patch: > > Slab: 36396 kB > > 2.5% increase, hopefully acceptable. > > Thanks!