Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp851093pxb; Thu, 21 Oct 2021 10:39:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVqmu/oU60kgHaYQVq8ow6wItY3swH/e+J7WCoWDnlKv9mbuRwWNmLtzWbGby/XOi82/kh X-Received: by 2002:a05:6402:5186:: with SMTP id q6mr9662355edd.340.1634837951272; Thu, 21 Oct 2021 10:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634837951; cv=none; d=google.com; s=arc-20160816; b=qkJ5YaX9N/VUvD7/2gsw/RiyL7GcgbzVcTkzA4LL3f3jljub3FVdFarvHj80amUY2w WJyPgg13lUJ1LNTdqHnQEUPfc3u8qOGbAulSirorg/x5mvUTkJC5XgsDnPMS6A8aGifR iJ7FfopQY6OX9U1/J+XQd2Bqvly36IiqnjniKwFfwfvwPiNQ0E8WQA+0nEVHuX+jphGS IbgF3xUrbF5fYc5yvV4Wiolu8uNVEeLpaMMJMnj5SsDF671+659vILqirZJzY465mKJ5 VfYHn0YY3Gl2FkqUt8C4go5+7NuMylMTxA6D98/EPx2ITL9TNuTNUs0t3nk8i5CMd+KD P4ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=0eDU1SMK968q7PGozinR0fnwI8mivFPo6U/lEqiI1KE=; b=x6xNngzVMZ6Zds47esVs/o+uOzPPlW+u8JJC4lPSI2FbXijvaOyFvENbnpdldQ8X5i R4AjTMjhw8OERH219EQ8ezghvBL4ExmKl6XM6Qbw28ub7LaigxTiQlytLdRaIB+nEMNO Of7r0eNY0awV7cZSIgwilANyK7cz9nDib/fY4JCmxWCUTbHF3pj09Vn6JDJKB2vPZuo+ VjcznqJglCMlMmcemK4PgjlOliuWPrnj23aVixKDHMrUpFcVBLak49fpLUsalSdolAdO O/SGjMm4389G+VCH+dl+ent5V8EspYG2hzazt3uf7q2MDk7oEdmzSytm868Jb4DxQZuA wj5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=EXSUjDjv; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=xBtjlDQH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si7943395edf.127.2021.10.21.10.38.44; Thu, 21 Oct 2021 10:39:11 -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=@suse.cz header.s=susede2_rsa header.b=EXSUjDjv; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=xBtjlDQH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232055AbhJURit (ORCPT + 99 others); Thu, 21 Oct 2021 13:38:49 -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 >> >