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 96298C433EF for ; Thu, 21 Oct 2021 17:36:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 24423619F6 for ; Thu, 21 Oct 2021 17:36:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 24423619F6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 83B33900002; Thu, 21 Oct 2021 13:36:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EBE86B0071; Thu, 21 Oct 2021 13:36:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DB59900002; Thu, 21 Oct 2021 13:36:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id 5F40C6B006C for ; Thu, 21 Oct 2021 13:36:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1628982499A8 for ; Thu, 21 Oct 2021 17:36:29 +0000 (UTC) X-FDA: 78721148898.22.0C73102 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf03.hostedemail.com (Postfix) with ESMTP id C9C5530000B9 for ; Thu, 21 Oct 2021 17:36:25 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 369CD1FD58; Thu, 21 Oct 2021 17:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1634837787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0eDU1SMK968q7PGozinR0fnwI8mivFPo6U/lEqiI1KE=; b=EXSUjDjvJKvCHYCYvA/99sVcJcLUtm3FL4wOtYSW8HUOVugMSAqhUAT9ZXS3QpnBwtNdCO rFH+2yz+YnVmZVEWDxkb35Q7KNPQVdBPfBOvkAq0OTFORyIYR0vJzZEzzLARRcrKNe15jU eruSQXsILzo1NMb8xklETsDrnvhWpck= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1634837787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0eDU1SMK968q7PGozinR0fnwI8mivFPo6U/lEqiI1KE=; b=xBtjlDQHd1PcjVvO88qnT341ih2Rz1pw4+QhsF2S3QaCcZ/GQ2B+4lNS9w2ypo+TyL+4lX GiF5TZBjH5CEXYDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D6C8413AE4; Thu, 21 Oct 2021 17:36:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id q7w4MxqlcWEkEQAAMHmgww (envelope-from ); Thu, 21 Oct 2021 17:36:26 +0000 Message-ID: <1dfb7a79-3e66-a9fe-ee7c-1277d7ff5950@suse.cz> Date: Thu, 21 Oct 2021 19:36:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] slob: add size header to all allocations Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Rustam Kovhaev 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 References: <20211015005729.GD24333@magnolia> <20211018033841.3027515-1-rkovhaev@gmail.com> <20211020114638.GA378758@kvm.asia-northeast3-a.c.our-ratio-313919.internal> From: Vlastimil Babka In-Reply-To: <20211020114638.GA378758@kvm.asia-northeast3-a.c.our-ratio-313919.internal> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: C9C5530000B9 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=EXSUjDjv; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xBtjlDQH; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Stat-Signature: 73kmzdmdsbqs1dwq4g4xi4mb6ckuuuqj X-Rspamd-Server: rspam06 X-HE-Tag: 1634837785-5502 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 10/20/21 13:46, Hyeonggon Yoo wrote: > On Sun, Oct 17, 2021 at 08:38:41PM -0700, 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). > > Hello Rustam, I measured its impact on memory usage on > tiny kernel configuration as SLOB is used in very small machine. > > on x86 32 bit + tinyconfig: > Before: > Slab: 668 kB > > After: > Slab: 688~692 kB > > it adds 20~24kB. Thanks for the measurement. That's 3.5% increase. > >> >> The main reason for this change is to simplify SLOB a little bit, make >> it a bit easier to debug whenever something goes wrong. >> > > It seems acceptable But I wonder it is worth to increase memory usage > to allow freeing kmem_cache_alloc-ed objects by kfree()? Not for the reason above, but for providing a useful API guarantee regardless of selected slab allocator IMHO yes. > Thanks, > Hyeonggon > >> meminfo right after the system boot, without the patch: >> Slab: 35500 kB >> >> the same, with the patch: >> Slab: 36396 kB >> >