Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2075859rda; Tue, 24 Oct 2023 11:29:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4wqSIYhO1VRdc4qklADgsJ/FcSolYjYRyi4iSX1qyqjNOqCzwxQpF1Vdanrgnw4W0vjm5 X-Received: by 2002:a17:903:1c1:b0:1ca:e6c6:92f6 with SMTP id e1-20020a17090301c100b001cae6c692f6mr8285591plh.9.1698172188046; Tue, 24 Oct 2023 11:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698172188; cv=none; d=google.com; s=arc-20160816; b=iR9Rta0gSQjewZ2Qu6GSLi6vJM+HDzkkHehTghMDh5zgecPRD8XT2fpHx0xFlx06zJ 8459r1cXwbLG9KjGWrTHMt1+TXf1kFboJ29Jhlye49Y5PjNW+BJ+J3btjPm6w85a75uc hFqcZ7gltjPsYdq0d0I/jtcua9W6W/gstUycR9PV04T1xjBvFWW5xlBKf+6jWIWNCfl6 YIrpbFvs6nwmgfvo1Zfr7ITrmAX6IkPv6Vw5FQDxuF85KVMOhyG1D4Y5qeKgJ5Crd1OJ vA0jQ/077HbTc+KnJtrZ5X6HPenJt6k7arl8qss+UUZ5fEcm0tKkHjZcPC0tCESby7vG sTUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=cJvtH1RU485LotJpakrbV9U/UfyKsr5ptSPtEPeho50=; fh=XZXHwb2VVltm/y/4Bh+qiSc/o+zObAQhj9mP43i6I2c=; b=q30cr6ETOgR2185fGfqp8tHU0xuQ69mab/B4E0LXYAUXbHgKzmDkRLh0s6eexHIh1A W0dYeB9ECT2L7YblhI1FmrP/MiORs8Uv/xinZ30quH7qi1f9SkA0fHpS5xgFKVC7Pl84 ctsSKA4Vx71J0nXIArX0yfFmU61nW56GCoaZfTlNp4IUdQIAW6CEms9lM7uWbxSn581o alCUjSiKuHmdhlJ/yDdW288aFQl9jv14cGl1ryaaoheUn3lM4TPF1tELSqnRSrLoLJcz oLLsyKnwVRHcwRP2lZ7BLe/MWpXNaGv3qp8N/V8AIc5j/EblC3JezUK3B7ukVcyEbyIk QGwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qxmyiqZd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f11-20020a17090274cb00b001bbc138af0dsi8446785plt.163.2023.10.24.11.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 11:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qxmyiqZd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 888EF803BEA6; Tue, 24 Oct 2023 11:29:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344130AbjJXS3i (ORCPT + 99 others); Tue, 24 Oct 2023 14:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344120AbjJXS3g (ORCPT ); Tue, 24 Oct 2023 14:29:36 -0400 Received: from out-209.mta0.migadu.com (out-209.mta0.migadu.com [91.218.175.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A37D0123 for ; Tue, 24 Oct 2023 11:29:34 -0700 (PDT) Date: Tue, 24 Oct 2023 11:29:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698172172; 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=cJvtH1RU485LotJpakrbV9U/UfyKsr5ptSPtEPeho50=; b=qxmyiqZdvUbSc5OX8sJ5B56VRDGRIypt0m2ZexyNmyd2CWJuUlLqxDCgQmiWZxhgLrnEJP Q3PacIpe5vXTiE86jUv2kcvB2COry3b6xKIlN2wW5y2pG9dxxNOj26Rwsg8w9wjXki2GwQ /5zO2TFTFVb+ghWrRC0JLTshCp62Kqo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Suren Baghdasaryan 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 Subject: Re: [PATCH v2 00/39] Memory allocation profiling Message-ID: References: <20231024134637.3120277-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231024134637.3120277-1-surenb@google.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 11:29:45 -0700 (PDT) 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 allocation > 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 performance > comparison between the baseline kernel, profiling when enabled, profiling > 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 statistics, but hopefully the difference will be lower. Thank you! [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()