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 3851FC433F5 for ; Tue, 16 Nov 2021 13:53:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8525D61B4D for ; Tue, 16 Nov 2021 13:53:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8525D61B4D 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 D4F8C6B0074; Tue, 16 Nov 2021 08:53:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D00326B007D; Tue, 16 Nov 2021 08:53:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B79296B007E; Tue, 16 Nov 2021 08:53:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id A5F316B0074 for ; Tue, 16 Nov 2021 08:53:04 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 40D082DEA3 for ; Tue, 16 Nov 2021 13:52:54 +0000 (UTC) X-FDA: 78814934268.20.AC5B2F4 Received: from smtprelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by imf04.hostedemail.com (Postfix) with ESMTP id 250205000300 for ; Tue, 16 Nov 2021 13:52:40 +0000 (UTC) Received: from forelay.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 4FE5E184956A0 for ; Tue, 16 Nov 2021 13:52:53 +0000 (UTC) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 30865184D4162 for ; Tue, 16 Nov 2021 13:52:49 +0000 (UTC) X-FDA: 78814934058.12.DD32E5E Received: from smtprelay.hostedemail.com (unknown [216.40.44.199]) by imf12.hostedemail.com (Postfix) with ESMTP id ADE9710003CD for ; Tue, 16 Nov 2021 13:52:48 +0000 (UTC) Received: from forelay.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 266168384365 for ; Tue, 16 Nov 2021 13:52:47 +0000 (UTC) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0736F184DD1CF for ; Tue, 16 Nov 2021 13:52:43 +0000 (UTC) X-FDA: 78814933722.27.8EDBA4E Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf13.hostedemail.com (Postfix) with ESMTP id 76839105299D for ; Tue, 16 Nov 2021 13:52:29 +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-out1.suse.de (Postfix) with ESMTPS id 8EADD212B7; Tue, 16 Nov 2021 11:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637061977; 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=5+gUcs/tjKbbk/7yjyhx4CtVWFpBne6sQR2PGyQ6344=; b=ML6kzvf86bM4nnzWKFtNChdojDg87P2IrQwJmzvErHw1YCxQyy1sWz1UOQc4HC82R3OD5e Y+NB9wEzQBFUNOZMjoxFNPH5cdNt+LOhsNzGjcH+CZSrbNgs2+ka8GqfMgb6D9XpsLiTXW 7qXbuQhrROM9fivT6OxNZc73SJdaEW0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637061977; 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=5+gUcs/tjKbbk/7yjyhx4CtVWFpBne6sQR2PGyQ6344=; b=bq5Owu98dWYzz0faNGWzKmuJajz1+tkAdQOg4tXKeWJeakdNKIV0+MZWkxmVPrDSBtBoxW DdcgfvYNOLswnpCQ== 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 5648813C01; Tue, 16 Nov 2021 11:26:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id nkATFFmVk2F1QwAAMHmgww (envelope-from ); Tue, 16 Nov 2021 11:26:17 +0000 Message-ID: <037227db-c869-7d9c-65e8-8f5f8682171d@suse.cz> Date: Tue, 16 Nov 2021 12:26:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH v3] slob: add size header to all allocations Content-Language: en-US To: Rustam Kovhaev , cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, corbet@lwn.net Cc: djwong@kernel.org, david@fromorbit.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, dvyukov@google.com References: <20211029030534.3847165-1-rkovhaev@gmail.com> From: Vlastimil Babka In-Reply-To: <20211029030534.3847165-1-rkovhaev@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-HE-Tag-Orig: 1637070749-479753 X-Rspamd-Queue-Id: 250205000300 X-Stat-Signature: gfxpzs1y7ofn5c8o1yrek1dq3st9hqnm Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ML6kzvf8; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=bq5Owu98; dmarc=none; spf=softfail (imf04.hostedemail.com: 216.40.44.22 is neither permitted nor denied by domain of vbabka@suse.cz) smtp.mailfrom=vbabka@suse.cz X-HE-Tag-Orig: 1637070768-436614 X-Rspamd-Server: rspam01 X-HE-Tag: 1637070760-842298 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/29/21 05:05, Rustam Kovhaev wrote: > Let's prepend both kmalloc() and kmem_cache_alloc() allocations with the > size header. > It simplifies the slab API and guarantees that both kmem_cache_alloc() > and kmalloc() memory could be freed by kfree(). > > meminfo right after the system boot, x86-64 on xfs, without the patch: > Slab: 35456 kB > > the same, with the patch: > Slab: 36100 kB > > Link: https://lore.kernel.org/lkml/20210929212347.1139666-1-rkovhaev@gmail.com > Signed-off-by: Rustam Kovhaev Sorry for the late reply. I think we can further simplify this. We have: static void *slob_alloc(size_t size, gfp_t gfp, int align, int node, int align_offset) Previously there was one caller that passed size as unchanged, align_offset = 0, the other passed size + SLOB_HDR_SIZE, align_offset = SLOB_HDR_SIZE. Now both callers do the latter. We can drop the align_offset parameter and pass size unchanged. slob_alloc() can internally add SLOB_HDR_SIZE to size, and use SLOB_HDR_SIZE instead of align_offset. Thanks, Vlastimil