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 D0238C433F5 for ; Thu, 21 Oct 2021 17:36:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1C9761A59 for ; Thu, 21 Oct 2021 17:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbhJURiv (ORCPT ); Thu, 21 Oct 2021 13:38:51 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:45912 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbhJURio (ORCPT ); Thu, 21 Oct 2021 13:38:44 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> >