From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E0ABC433EF for ; Tue, 19 Oct 2021 01:22:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E942F6134F for ; Tue, 19 Oct 2021 01:22:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E942F6134F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4467B900002; Mon, 18 Oct 2021 21:22:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F4F06B007B; Mon, 18 Oct 2021 21:22:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E3D4900002; Mon, 18 Oct 2021 21:22:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 1B9936B0078 for ; Mon, 18 Oct 2021 21:22:33 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B6BF68249980 for ; Tue, 19 Oct 2021 01:22:32 +0000 (UTC) X-FDA: 78711436944.19.774B995 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 57D0B30000A8 for ; Tue, 19 Oct 2021 01:22:29 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id o133so16177956pfg.7 for ; Mon, 18 Oct 2021 18:22:32 -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=7RuujFmI6nmg1IlPFthEkWVa+glQgh5ZYzBAID93MHGyQ6xCWSpu+EYVD13SWNvNa0 YmAh55nUVhib8RhbxHg08df7vU72xnNbNwGl4TLoIWtcRR0cN+Vb732LBgyQc5mhBNw0 oRBE0QV6VqVmTv+0gd4ZkVhYT75kbu+7FSl8KLtYDwpbb+DzSexrE/Agk7FuUJXx8foD f04B+p8z3EDfhOFoG80SZh9mWgV5JZvBuU7XJ8Xv9ylL107pB+1H7CyUXJAuiyYgrEIu lSubmRmYFK3Bm/CEUguKPPFCXhpCFGZkYP847jltP/eXb9xR9zcVQfwoSNlHfyqmts+s S0tw== X-Gm-Message-State: AOAM531OWyCnmstFv43Eoq7DEMppwIErrGr3N8J7JV7gq0XC4OwK/aHa 8MyiTwiBl9TLn7BAH0VSY7Y= X-Google-Smtp-Source: ABdhPJx/gurImig6XRrgeoEO/r7wyQ5O40+HcN6GJkbcox6Gf8TSIr+7QFKlwoYAMkAlcDAZ7Yn1TQ== 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> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 57D0B30000A8 X-Stat-Signature: 1kqkw45r16sj5zha1mh8q5c5okz8bntd Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PAoteaNB; spf=pass (imf08.hostedemail.com: domain of rkovhaev@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=rkovhaev@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1634606549-298561 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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!