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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB6BBC77B73 for ; Tue, 2 May 2023 17:55:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DC2F6B0072; Tue, 2 May 2023 13:55:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78CA06B0075; Tue, 2 May 2023 13:55:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62DB86B007B; Tue, 2 May 2023 13:55:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 504986B0072 for ; Tue, 2 May 2023 13:55:59 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D190B1C84DA for ; Tue, 2 May 2023 17:55:58 +0000 (UTC) X-FDA: 80746068396.10.4B1F419 Received: from out-19.mta1.migadu.com (out-19.mta1.migadu.com [95.215.58.19]) by imf19.hostedemail.com (Postfix) with ESMTP id 542701A1498 for ; Tue, 2 May 2023 12:53:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="X8e/zveM"; spf=pass (imf19.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.19 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683032323; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ESr9I0e8zhQfwnabaXWJmwqboN5UgcpvA4HHb+DuoSo=; b=NbbM8VV9jlkEixwKSPv/Xkmxdd/B8k+nUiO/yY50Qddg4UWiMGbBYv12T1ZF0Z1qo3+tNL 6ULg5VqsUZNqUV7W83pYkibnrgf3yFmy5UV0E5uGMnrjo4uphZAp/FT8JB3akbppo+hKjP J+iUBDTTmS9VQ0S8hWaqA4NVVFdwMg8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683032323; a=rsa-sha256; cv=none; b=nQhKgUBFA7vFloDEmzyyPm2OZQDcy+9364gUynIJ9nSSAu09OTqeAjMZdi9FotrnquyiR/ mlLTCJas6V9Twf5pxxha1Jv2c081SO1FT6ezsQFPuxuTj2Ir7WykGAsC9tihBfoNkMC16e b1ad4Cv3lS2zrpzzG8BvpeWItWU8O0I= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="X8e/zveM"; spf=pass (imf19.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.19 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Mon, 1 May 2023 14:18:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1682975916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ESr9I0e8zhQfwnabaXWJmwqboN5UgcpvA4HHb+DuoSo=; b=X8e/zveM3y8evn6iXFP1GQo9OkihBkN8WMX+PdxDnY3z/6lrHLFpCsMAkSpjJKhXXfOrwF IUeI4bLp/6VHOK8l63qdJcQBLJJOOe6I4c1Q3m33D6EX2Iby3DxkSkgglbdgCL1yyraxZj BHxkRt89pPHeAAb7NZCRpzeOKMHy5No= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Kent Overstreet Cc: Suren Baghdasaryan , akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org Subject: Re: [PATCH 00/40] Memory allocation profiling Message-ID: References: <20230501165450.15352-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 542701A1498 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: 7ioi197jwedqjswxg1faoyttaozpnxbc X-HE-Tag: 1683032033-298956 X-HE-Meta: U2FsdGVkX1+lNSYQZi0wLeznMOJl6m9yLSuu8hOYRJG68oZQALJpa8ndDr2FWxppVJyZcgQ8Vp9R5p2KHMPU9bdGNaQnjtODUl0jAFIsa/8vS+CiS/J/YsyNrdQXhxno8nBWFU9abiXqDMy8XVLPETgLJlgGYs8ZiNCpw5tTuMiZ8T4sgFMeDkVyFiCd/dyvssz2vpteMxAtzCIRi1FNVOTcakq7dqmlmxah4f+KCaOjID/W6vEO8YNY18Dkx36njBqNtCKrl2avJqD+XCedUf2XI+Z2Plxtv8F7mABEup4i2gWScOo9UKmPghhDTTMGDB0nUOwAnP/ofGjUV7UFJJsyRkwFg+6Kw/wjYjCQ4UjcJgVxkA07Z3k89fz/VEX4iUwydDJQ2/5rAyY6Cq+SVeueWwrpnewJfvw6+SWnC+VlDPVj0iTa46j0nhlyKx48iwtmeGsSQH6ThDP8nRjbveD/I0TMFGHhI/y9ZgcxdWKyuiUmxXtIdDGFXCzysLlJctetzRCgAU5ty8fWlZEY6AbQMIR472n0etJr8gAm5v1I5k16dPOGeRoSMvAf9ApKcaRJ4XfMQWCdz7T3E5+G8vQfx8wmohE1dIkfFxDu3yckNvg37JAgtUqTQlMLaUM5cCDoG71Ph1Iwfn0Vg4mWmO7HL7SrIoRPMFUhLd0D0ILrrjLAO7hBnumqcunD89nURGegXbctE1oj6mxdPT+SokdXDKB1Zwoxk0dW18rW/tKFgFAjiDjqDKrFLzYXtSBMx4J3espfp6hGOpqeKthNtqQoVHXIQnE5c/XHLb38QbXvNkMbtRtxWOfJcJcqnQh2y/zYsEOzSGDib3czkH9vScXmj1pHXOcPiFWdHydXz/vI+XG/Rxtjhw== 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 Mon, May 01, 2023 at 03:37:58PM -0400, Kent Overstreet wrote: > On Mon, May 01, 2023 at 11:14:45AM -0700, Roman Gushchin wrote: > > It's a good idea and I generally think that +25-35% for kmalloc/pgalloc > > should be ok for the production use, which is great! > > In the reality, most workloads are not that sensitive to the speed of > > memory allocation. > > :) > > My main takeaway has been "the slub fast path is _really_ fast". No > disabling of preemption, no atomic instructions, just a non locked > double word cmpxchg - it's a slick piece of work. > > > > For kmalloc, the overhead is low because after we create the vector of > > > slab_ext objects (which is the same as what memcg_kmem does), memory > > > profiling just increments a lazy counter (which in many cases would be > > > a per-cpu counter). > > > > So does kmem (this is why I'm somewhat surprised by the difference). > > > > > memcg_kmem operates on cgroup hierarchy with > > > additional overhead associated with that. I'm guessing that's the > > > reason for the big difference between these mechanisms but, I didn't > > > look into the details to understand memcg_kmem performance. > > > > I suspect recent rt-related changes and also the wide usage of > > rcu primitives in the kmem code. I'll try to look closer as well. > > Happy to give you something to compare against :) To be fair, it's not an apple-to-apple comparison, because: 1) memcgs are organized in a tree, these days usually with at least 3 layers, 2) memcgs are dynamic. In theory a task can be moved to a different memcg while performing a (very slow) allocation, and the original memcg can be released. To prevent this we have to perform a lot of operations which you can happily avoid. That said, there is clearly a place for optimization, so thank you for indirectly bringing this up. Thanks!