Message ID | 20240301-slab-memcg-v1-0-359328a46596@suse.cz (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B37A8C5475B for <linux-mm@archiver.kernel.org>; Fri, 1 Mar 2024 17:07:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 164216B0088; Fri, 1 Mar 2024 12:07:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 042E7940011; Fri, 1 Mar 2024 12:07:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8BB86B009B; Fri, 1 Mar 2024 12:07:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AE0336B009B for <linux-mm@kvack.org>; Fri, 1 Mar 2024 12:07:15 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8CAAF1201BE for <linux-mm@kvack.org>; Fri, 1 Mar 2024 17:07:15 +0000 (UTC) X-FDA: 81849100830.29.41513DC Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf03.hostedemail.com (Postfix) with ESMTP id 534032002C for <linux-mm@kvack.org>; Fri, 1 Mar 2024 17:07:12 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=aEYEwxxz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oWi0rFN8; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=aEYEwxxz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oWi0rFN8; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709312832; h=from:from:sender:reply-to:subject:subject: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: references:dkim-signature; bh=JWL3xLKHsHdlJnILzpkn8H/KWzQeCNwfHWgrgk6UfkI=; b=g21etV2GcEYMTrcQQweFnQds3BCJgs6TMMZv5jDzY2Pe/Z8/zeQptEHVYvbkgiH5qjahig Yux+zTiGt8Bmde4wXHoRt6Bwy0cMLridGIvPmjdFYGkZ7yiG4Fhar8MYRnVup/re5iMTJj 9+8fWG70vfxxkkdvTjd27FHy7h5ra4c= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=aEYEwxxz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oWi0rFN8; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=aEYEwxxz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oWi0rFN8; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709312832; a=rsa-sha256; cv=none; b=bJkWYz++RJ9tvIT+MS7uzQfWkynykDsjXbc5EQAHHI/LjpY8aXE7flYPWz0gtIbm9kDRKx f/zzen6Mp63TSvkAjZCrJDvzCAcHXy+eSi5NZ2aI1104RubFj8oO34d/RmnzWALbhL1pE4 V8hjd2S79UDs170T0RQaoOW/M2uMt8M= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8B827207B5; Fri, 1 Mar 2024 17:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1709312830; 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; bh=JWL3xLKHsHdlJnILzpkn8H/KWzQeCNwfHWgrgk6UfkI=; b=aEYEwxxzeymsxCReiwtKQ71aPmw2twMkOHoZrO7gi/hwptOpSO8Gkymp1z04EpTRCFQVWM bTmkCC3Un7JpF+O/+wsvlSByBPoVv48C5l5FsVL4vfXEYggd2iUfQC/CaHBIdhhl+fY3Us VD9IVbnwRmiMXvFLVDfu2vfaXsRrLmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1709312830; 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; bh=JWL3xLKHsHdlJnILzpkn8H/KWzQeCNwfHWgrgk6UfkI=; b=oWi0rFN8PpclO76dABxGHJgaC0Wy6gmCoQYOhTD7BgCRWRS/Rvx3vzNP2POQckCk36pNAT L7usYQuHj7ceFPCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1709312830; 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; bh=JWL3xLKHsHdlJnILzpkn8H/KWzQeCNwfHWgrgk6UfkI=; b=aEYEwxxzeymsxCReiwtKQ71aPmw2twMkOHoZrO7gi/hwptOpSO8Gkymp1z04EpTRCFQVWM bTmkCC3Un7JpF+O/+wsvlSByBPoVv48C5l5FsVL4vfXEYggd2iUfQC/CaHBIdhhl+fY3Us VD9IVbnwRmiMXvFLVDfu2vfaXsRrLmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1709312830; 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; bh=JWL3xLKHsHdlJnILzpkn8H/KWzQeCNwfHWgrgk6UfkI=; b=oWi0rFN8PpclO76dABxGHJgaC0Wy6gmCoQYOhTD7BgCRWRS/Rvx3vzNP2POQckCk36pNAT L7usYQuHj7ceFPCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5928D13A59; Fri, 1 Mar 2024 17:07:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id al52FT4L4mUcGQAAD6G6ig (envelope-from <vbabka@suse.cz>); Fri, 01 Mar 2024 17:07:10 +0000 From: Vlastimil Babka <vbabka@suse.cz> Subject: [PATCH RFC 0/4] memcg_kmem hooks refactoring and kmem_cache_charge() Date: Fri, 01 Mar 2024 18:07:07 +0100 Message-Id: <20240301-slab-memcg-v1-0-359328a46596@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIADwL4mUC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDIyNL3eKcxCTd3NTc5HTdxFSzJGNzC8tkSyMTJaCGgqLUtMwKsGHRSkF uzkqxtbUAW4jPNmEAAAA= To: Linus Torvalds <torvalds@linux-foundation.org>, Josh Poimboeuf <jpoimboe@kernel.org>, Jeff Layton <jlayton@kernel.org>, Chuck Lever <chuck.lever@oracle.com>, Kees Cook <kees@kernel.org>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Andrew Morton <akpm@linux-foundation.org>, Roman Gushchin <roman.gushchin@linux.dev>, Hyeonggon Yoo <42.hyeyoo@gmail.com>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@kernel.org>, Shakeel Butt <shakeelb@google.com>, Muchun Song <muchun.song@linux.dev>, Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz> X-Mailer: b4 0.13.0 X-Rspamd-Queue-Id: 534032002C X-Rspam-User: X-Stat-Signature: kmp8co1sonhazz467j143sxm81m5dxxk X-Rspamd-Server: rspam01 X-HE-Tag: 1709312832-137532 X-HE-Meta: U2FsdGVkX1/hrWa4NDwIZGY5IOBrvpefHO4lpC9ngyLp9YMZ4Dcyh/pG/9mw29TZaJGTg56L8kvu8+Jyw5vCPXJjZvBLandIn0ouUhgpqE0HhLBV5Dbc6KtCwBplIumWoPcp328ww7QIxA13JBQINgwY5YwhFbUHvhkyqIOn0A9Iz/8AXIfdF31kRwzRF6CyD0ypTrwJpzboSbQJT3tFiEcLSrRxgxV+fxKj3kUqnBi6YH50pIYor8cUlruFe3j+QwDdObaKXeY5s4wuW65L/oUXllsV2BJRriIzakAVOw9aYQIG4snNOnWyLKMbpLmwkAHe8cKWd7YwyFzhfMHlZE8Rfb4WLlq/0RnHy4/lPzsdDW1b6IGPsvEdfUug9YZkJkk881CkJeElAq8Abc9d2GNSl1opOKzcKMi3V90EUe/mwEJHr873FO6iKCCbf04mLueU13fppXRxD0X59cvROIQ7+kXWVyT94/x/YRnY4YqcsMZSQRF+6pHo4LiZQ0xuBiBUzr7LWLi5Zgh4SCWPPQ01Y/5Xx/ihZHhcVKfRccrBr7mGTOqTjENxL0rsX3ahAkoPrj+iQjITDY4i8lgJiBe6kjNfW/s4QOk4W4nkX4H5C67mr3rMeKhUO+ffNwxtlttNE56bUH1LH86hzTii25/v9ABeyGkuPONXuqkww0Elmg9u/nt1fO+K3+xqJ4lx0359iD2wkNWWcjJtQ4z0iD0Nlw87emLzfkjxGBDXDD0g6jk2GCpID/qVRyVUfqPIvZfArybPyURNMsPQ/tDeRlmp2oEcc1rWKf6PdmhQFsmlMmEOLiah+u1P1Rsex4tHce+gyVu8poLwLi7JKufGTln8bSTILug88uX+kEUjpSHgvUs7uNTvTnAcKyqufl39oTZzFS2C3McAx0EBE+YXIRh8pevBL+lO5kPJ+UW80uu4elSQ0Xd2hRMsKg5MtmkLkEtQ+s3AEbY8WYLQ1vq 2V1rj3bc OVbl3oLCoxLXYjEaaj8XA2EACx5G6Otms03LM81oLQjcfN4qH1LU9FAAJFQ== 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
memcg_kmem hooks refactoring and kmem_cache_charge()
|
expand
|
Hi, I have tried to look into Linus's suggestions to reduce slab memcg accounting overhead [1] [2]. The reorganized hooks are in Patch 1 and it definitely seems like nice cleanup on its own. In Patch 2 I have tried to move them to mm/memcontrol.c to reduce calls to memcg code. I hoped to see better performance, but probably didn't. Patch 3 introduces the suggested kmem_cache_charge() API and Patch 4 tries to use it for the testcase in [1] but it's unfinished due to my lack of VFS knowledge. I haven't done much benchmarking yet, just in a guest VM on my desktop for the test case from [1]. Applying patches 1+2 might have improved it slightly, but could be noise. With 3+4 the memcg overhead is gone as expected (the charging never happens) but due to the unfinished state I don't know yet if the separation might hurt cases where the open() actually succeeds. Anyway thought I would share already so others can play with it and see if it's a good direction to pursue (with patches 3+4). I think Patch 1 should be good to apply in any case (after more testing, and review), not yet sure about Patch 2. [1] https://lore.kernel.org/all/CAHk-=whYOOdM7jWy5jdrAm8LxcgCMFyk2bt8fYYvZzM4U-zAQA@mail.gmail.com/ [2] https://lore.kernel.org/all/CAHk-=whw936qzDLBQdUz-He5WK_0fRSWwKAjtbVsMGfX70Nf_Q@mail.gmail.com/ Signed-off-by: Vlastimil Babka <vbabka@suse.cz> --- Vlastimil Babka (4): mm, slab: move memcg charging to post-alloc hook mm, slab: move slab_memcg hooks to mm/memcontrol.c mm, slab: introduce kmem_cache_charge() UNFINISHED mm, fs: use kmem_cache_charge() in path_openat() fs/file_table.c | 9 +- fs/internal.h | 1 + fs/namei.c | 4 +- include/linux/slab.h | 10 +++ mm/memcontrol.c | 90 ++++++++++++++++++++ mm/slab.h | 10 +++ mm/slub.c | 231 +++++++++++++++------------------------------------ 7 files changed, 188 insertions(+), 167 deletions(-) --- base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d change-id: 20240229-slab-memcg-ae6b3789c924 Best regards,