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 C8FA5C77B7C for ; Sun, 7 May 2023 17:21:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 041DA6B0072; Sun, 7 May 2023 13:21:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F34626B007D; Sun, 7 May 2023 13:21:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFBDB6B007E; Sun, 7 May 2023 13:21:13 -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 CFB316B0072 for ; Sun, 7 May 2023 13:21:13 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 91E001C7298 for ; Sun, 7 May 2023 17:21:13 +0000 (UTC) X-FDA: 80764124826.16.1629C9E Received: from out-51.mta0.migadu.com (out-51.mta0.migadu.com [91.218.175.51]) by imf21.hostedemail.com (Postfix) with ESMTP id 765FC1C0004 for ; Sun, 7 May 2023 17:21:11 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=t9HPg37z; spf=pass (imf21.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.51 as permitted sender) smtp.mailfrom=kent.overstreet@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=1683480071; 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=hurdbnJwUJqK07Lm+4BMc/GcG+c58gJSfQAtVR+cBkY=; b=165nDH4xYkGnJ6Bk5Qp5NTAyaCWfwfftfeX8L5zM0Z3YJL1pEY90OgKVK4QIzmZNGiLP0u KDxDsJxmN4hjDwfgQyJYW0c3rDRV7+yR+XsS5ja0w+/LPH2EOJkJpAWtLjZ0AjW1LnwJBg ApIgwFUXKvuZWVg/Sqd5mNoe3Dcbqhc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=t9HPg37z; spf=pass (imf21.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.51 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683480071; a=rsa-sha256; cv=none; b=SKBhEgEWuu9iCRmTarfGJ8O8ea2dIJTgGFXTAgCQeHNpGlbZIkkgrLHtEVw5bds2a9pXgY OsIcyWk6J3rmKwF8OYO7RxS3tE2dTBW9vhXmLdn9192oVYpe/DJX0lYy55/rgA8S7rK/wy TGD2UBJun78ndz+1HShSyInzqZ55H6M= Date: Sun, 7 May 2023 13:20:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1683480068; 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=hurdbnJwUJqK07Lm+4BMc/GcG+c58gJSfQAtVR+cBkY=; b=t9HPg37zepSR1RnzhSUKFRxBUu28FVu1Yi23jFUki7ZMbwLSC/NiT3n7wFBZNUFaL6UoyB zJPC7zS/i2KkcdGtaRgLAJgrWe5jboQdCOvInvXLMeR4wfr6JjMe/ufK6pDB5akkqqXdTQ ldiDYd0e9CxSI40mvUKNrcXC5Ki5rqQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Michal Hocko Cc: Suren Baghdasaryan , akpm@linux-foundation.org, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, 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-Stat-Signature: 15yfw6sxqfn56h4sy7r7gqbe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K u9qB1H7huPx2+fIhQG3u3qCFnoDDF9HNUaLUNJbBSv9JLJ307OxEWg1a69to9Dff9r2VQUAsWR6A4Mg5CHulJ9AHzd7Jmosg6f7adGfX5NkfBw7yP2FHo2onOZg== 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 Thu, May 04, 2023 at 11:07:22AM +0200, Michal Hocko wrote: > No. I am mostly concerned about the _maintenance_ overhead. For the > bare tracking (without profiling and thus stack traces) only those > allocations that are directly inlined into the consumer are really > of any use. That increases the code impact of the tracing because any > relevant allocation location has to go through the micro surgery. > > e.g. is it really interesting to know that there is a likely memory > leak in seq_file proper doing and allocation? No as it is the specific > implementation using seq_file that is leaking most likely. There are > other examples like that See? So this is a rather strange usage of "maintenance overhead" :) But it's something we thought of. If we had to plumb around a _RET_IP_ parameter, or a codetag pointer, it would be a hassle annotating the correct callsite. Instead, alloc_hooks() wraps a memory allocation function and stashes a pointer to a codetag in task_struct for use by the core slub/buddy allocator code. That means that in your example, to move tracking to a given seq_file function, we just: - hook the seq_file function with alloc_hooks - change the seq_file function to call non-hooked memory allocation functions. > It would have been more convincing if you had some numbers at hands. > E.g. this is a typical workload we are dealing with. With the compile > time tags we are able to learn this with that much of cost. With a dynamic > tracing we are able to learn this much with that cost. See? As small as > possible is a rather vague term that different people will have a very > different idea about. Engineers don't prototype and benchmark everything as a matter of course, we're expected to have the rough equivealent of a CS education and an understanding of big O notation, cache architecture, etc. The slub fast path is _really_ fast - double word non locked cmpxchg. That's what we're trying to compete with. Adding a big globally accessible hash table is going to tank performance compared to that. I believe the numbers we already posted speak for themselves. We're considerably faster than memcg, fast enough to run in production. I'm not going to be switching to a design that significantly regresses performance, sorry :) > TBH I am much more concerned about the maintenance burden on the MM side > than the actual code tagging itslef which is much more self contained. I > haven't seen other potential applications of the same infrastructure and > maybe the code impact would be much smaller than in the MM proper. Our > allocator API is really hairy and convoluted. You keep saying "maintenance burden", but this is a criticism that can be directed at _any_ patchset that adds new code; it's generally understood that that is the accepted cost for new functionality. If you have specific concerns where you think we did something that makes the code harder to maintain, _please point them out in the appropriate patch_. I don't think you'll find too much - the instrumentation in the allocators simply generalizes what memcg was already doing, and the hooks themselves are a bit boilerplaty but hardly the sort of thing people will be tripping over later. TL;DR - put up or shut up :)