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 8AA2AC07545 for ; Tue, 24 Oct 2023 18:39:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCD6C6B020A; Tue, 24 Oct 2023 14:39:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D55EF6B020C; Tue, 24 Oct 2023 14:39:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA8476B024A; Tue, 24 Oct 2023 14:39:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A3E8C6B020A for ; Tue, 24 Oct 2023 14:39:07 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7F22F140710 for ; Tue, 24 Oct 2023 18:39:07 +0000 (UTC) X-FDA: 81381217134.25.A2DFBA1 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf11.hostedemail.com (Postfix) with ESMTP id AEFB940021 for ; Tue, 24 Oct 2023 18:39:05 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="E7/L3Heq"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of surenb@google.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698172745; 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:in-reply-to:references:references:dkim-signature; bh=kYl/hPQ1QO/qnjhfpaigT8V90o1Z/zrFBqqxchQb6PA=; b=DT9VJsbkzCCva9w79URI2kIGMb+3CNAviu7dX9dkp6d02BEnrOayUM8B6TwbToVUNH4o4o TxxnlFCpHZnJGbRC0cHnxqwHl659gBWXT5gGL9SlzZ9jepfJ8zzV7h4EHxusg0/9veh1iV PwXXkA5nVyCwVoHtzDIhmV4M5AugiK8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="E7/L3Heq"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of surenb@google.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698172745; a=rsa-sha256; cv=none; b=XeV75wbJ+CsDNPyI3vXVId7xlLNHw1tLIFwfS+65QmQM8DXi6XF7FfR9wUab4eovBcIIZ7 1DNfBS8XXTjNTd1uueTJ248SzGdXvpGpUQBSMa3bzUjLVXG5MdkEgKIIR0JBWHMryUtK7x kxdrd1ral6+iaMsAjJgXgJYYAm+W60w= Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-31c5cac3ae2so3490159f8f.3 for ; Tue, 24 Oct 2023 11:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698172744; x=1698777544; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kYl/hPQ1QO/qnjhfpaigT8V90o1Z/zrFBqqxchQb6PA=; b=E7/L3HeqTZrAA1hBP+DIIbQaCpMc3EI35rzqKFQT6xNpIVYvmmGimbCWCpJemydtyr rzRSQctj5WIknuKjVRY17clsdzdDn2VkooqMjhypW/r6UcD7vQlLUTJ389F4ijb4c+gw yUKoniYUCM0DnBS/+LEX9zOoixJV6+Ut49XyNXxKJ+jAOfGTSF/Jvtf+rtSJ8FgWqW6G iixkLsaMBKJyWVQyI8nDg74tNkSHVufyHCmAAgtuxQs2o3G0K0krYxfr8xMAezx9Uv+6 kJ2yF4gN2mx1BLOk6K/oRIId6h7YJIYE8AjBZuCKOf2e5WVHRua9zbz85FmrRg/EDEod BlTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698172744; x=1698777544; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kYl/hPQ1QO/qnjhfpaigT8V90o1Z/zrFBqqxchQb6PA=; b=YAUYXy7/uD2zq8Oi44s5F7uLo1aaV0MCZW9bAgm1bixAXcgk1H3M6w0BK4dF9jjc5f 2BsYkvkeRNk+wMwTDFqe6Tmdg7rkPoa2fBZkFvVMEoD3Rr8haYwxHfHgQBrefUnHgq9K rC1V9GoUi5bTKnPtLdHxFKF5e2S7ifzd6qCO3mFzFOlPG7CYUx4ftMEK45pQzihM96GH ZeMwHhcv3wAz3FwSXrhDFiy75L/2zYHa7H5SFlRWDe4e99LyrGVf/QK6KdmCfm7ng1b+ AbYiHSXNEVYzGZPibokraTviOj6Ykeup/oH8yq/E2AQKeT90hofb4/jAlDfTQkeAma7n ORcQ== X-Gm-Message-State: AOJu0YxjJa+6MrIecGB0ruq4z4VrNCowggqqA7p9Jimuk8AXZ/Ak1M5F 64WFeoGTIoUxvJGg0MFu8uVWsKeyRtvsV/KkDTdrNA== X-Google-Smtp-Source: AGHT+IEBkrXV9tW6JjjS6KAesMgogqWbIPz6JOX8ffpbsI1yBbmL6peaStLCV8xe25eowD6jRKUcC8TJUMwxtgmJk8k= X-Received: by 2002:adf:fe8a:0:b0:32d:ad05:906c with SMTP id l10-20020adffe8a000000b0032dad05906cmr10224110wrr.3.1698172743492; Tue, 24 Oct 2023 11:39:03 -0700 (PDT) MIME-Version: 1.0 References: <20231024134637.3120277-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 24 Oct 2023 11:38:47 -0700 Message-ID: Subject: Re: [PATCH v2 00/39] Memory allocation profiling To: Roman Gushchin Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, 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, vvvvvv@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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X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NwFpHY26aiPl0o ByqJnweG To+cxHoe2RvS7M5BaDfZJIYl4wrvRekD0MhIcad9vsVH/XgVeZN1vtzFZndce7FVnmC8uybZif3pYlBWP6XBTb+ig8l4gB9wFT5G8tbqQKKzxtt0qiNA//XcvIGwp5Fta4sm1qZYbfkaUQLnTZ9jHF/5cbC8PUJgQ250UH/3GhCoXUrFlZqNEdnmlczfwgADA+b2iLiFyrjTcsUAJILkDeC0RY9hBKukFGoMP+YY7Q6G9PuCs5jLpJhZQv3xodQPV9cCq9C/M0NMtTCqCV5vh8nanLJ2qVlE7KvjZqt5q1tr5x+g= 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: List-Subscribe: List-Unsubscribe: On Tue, Oct 24, 2023 at 11:29=E2=80=AFAM Roman Gushchin wrote: > > On Tue, Oct 24, 2023 at 06:45:57AM -0700, Suren Baghdasaryan wrote: > > Updates since the last version [1] > > - Simplified allocation tagging macros; > > - Runtime enable/disable sysctl switch (/proc/sys/vm/mem_profiling) > > instead of kernel command-line option; > > - CONFIG_MEM_ALLOC_PROFILING_BY_DEFAULT to select default enable state; > > - Changed the user-facing API from debugfs to procfs (/proc/allocinfo); > > - Removed context capture support to make patch incremental; > > - Renamed uninstrumented allocation functions to use _noprof suffix; > > - Added __GFP_LAST_BIT to make the code cleaner; > > - Removed lazy per-cpu counters; it turned out the memory savings was > > minimal and not worth the performance impact; > > Hello Suren, > > > Performance overhead: > > To evaluate performance we implemented an in-kernel test executing > > multiple get_free_page/free_page and kmalloc/kfree calls with allocatio= n > > sizes growing from 8 to 240 bytes with CPU frequency set to max and CPU > > affinity set to a specific CPU to minimize the noise. Below is performa= nce > > comparison between the baseline kernel, profiling when enabled, profili= ng > > when disabled and (for comparison purposes) baseline with > > CONFIG_MEMCG_KMEM enabled and allocations using __GFP_ACCOUNT: > > > > kmalloc pgalloc > > (1 baseline) 12.041s 49.190s > > (2 default disabled) 14.970s (+24.33%) 49.684s (+1.00%) > > (3 default enabled) 16.859s (+40.01%) 56.287s (+14.43%) > > (4 runtime enabled) 16.983s (+41.04%) 55.760s (+13.36%) > > (5 memcg) 33.831s (+180.96%) 51.433s (+4.56%) > > some recent changes [1] to the kmem accounting should have made it quite = a bit > faster. Would be great if you can provide new numbers for the comparison. > Maybe with the next revision? > > And btw thank you (and Kent): your numbers inspired me to do this kmemcg > performance work. I expect it still to be ~twice more expensive than your > stuff because on the memcg side we handle separately charge and statistic= s, > but hopefully the difference will be lower. Yes, I saw them! Well done! I'll definitely update my numbers once the patches land in their final form. > > Thank you! Thank you for the optimizations! > > [1]: > patches from next tree, so no stable hashes: > mm: kmem: reimplement get_obj_cgroup_from_current() > percpu: scoped objcg protection > mm: kmem: scoped objcg protection > mm: kmem: make memcg keep a reference to the original objcg > mm: kmem: add direct objcg pointer to task_struct > mm: kmem: optimize get_obj_cgroup_from_current()