Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5815427rwr; Mon, 1 May 2023 11:09:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DF8fYEurgJKMLkHERYJon6Impqlq/1Y38HyfKEhbubEdH1BqujKFaY7RDPFx+DwCaN4zE X-Received: by 2002:a17:902:db03:b0:1a9:8ff5:af51 with SMTP id m3-20020a170902db0300b001a98ff5af51mr19919297plx.60.1682964568641; Mon, 01 May 2023 11:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682964568; cv=none; d=google.com; s=arc-20160816; b=mgEGbxIuQ/uQSdq/ww9LCz50xpXqBASXKmlkkevIH+esPx8jcD02YP2ac7FUW3Mou4 UKfMMZDvLrIo+949Rjs6C9bWpinOcPwuKp0okODIM6idIWIQKk5BNsJ9jlHE7zqz3ajC 2CMg0rjTqXLB4avVFivDh7oZTUwfk7B2bQn/at4rCVNh2R0VfkaRoB+aAi5YYFTxBnwi 7t/2v+fULgSBjB3SA+n8GGT5FJ7JfEhgdJulBghDbyW8XJqh9vKhg5+tZiXprxiz8u3h OypuUOeGDwnSzT2Fn/cn3UCHmrTVyCCqwgdUEU/1b38kOsZWB5BpXb4h/KOPeMgiD8D7 V7LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=+2lYHhqlJD16G2HYpsFMb3ZFL7Kq76WjunB2OGwz3cs=; b=Xb7upX941RNXoZDySmZTAMV62/ZXH3hxZlJBMBto1bBIu1fUr7Wkg8vr4AC7mlEDHz mRdTYAZ++0d+c5TGGFZk19nJims+nFbcLVSDnl3hBRa4OI69zz+eva/m8BdkpcRM81Vk 0whz3jQkTrxtAy+64tiN7B0Pol23gbsGA/FOXaOLAkdq5NRTjAvNCtl85kJ4fWq0Leq7 V4TD3w3J5jSb4Io16QWM+pNd4A/lKTyN78PMcRjzjkTCGm3oCYCxe01x3Uv5NIlpZOIu Xu1XodpIwydCz+6iV0riB1HKz20K9V0+KwirN8iSS1nD1IEhboYdlx/GOzXqeDTg3rt4 TNww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=InnNvCby; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a170903124a00b001a97d1e9642si20051042plh.186.2023.05.01.11.09.15; Mon, 01 May 2023 11:09:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=InnNvCby; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbjEASI0 (ORCPT + 99 others); Mon, 1 May 2023 14:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbjEASIY (ORCPT ); Mon, 1 May 2023 14:08:24 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 753FF172B for ; Mon, 1 May 2023 11:08:22 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-2f3fe12de15so1577607f8f.3 for ; Mon, 01 May 2023 11:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682964501; x=1685556501; 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=+2lYHhqlJD16G2HYpsFMb3ZFL7Kq76WjunB2OGwz3cs=; b=InnNvCbyWRIxKxFGHEw18GDFvAR07SJg7UsaQSzayd856NvZvHy/7D82OiVunxTwOQ iI4bPEnaVC8DKfBD9q2mpFU/D2+4QZOsePkMvk/nKecGEkR7ieMp18RUohlow/ONsuPb fRpdmKiy/hCz/JHzVWz2n5Mg5OcWXlB55bYJJxXjQz7D5uG5SID6uaCO/Kks5xdfPjJJ it9fnMSSuNm2JWdg5Tcm2D1rTGbvS4aDpWOvTKMsD+KeIoUScC3se5ywU/XKx17SosJd CH4HSE+fdc45RYf+DKFB/2hLNASZoyYfq4ehjOUiQfqHoIRcizKtgl3mADdezSKqh+u9 RU9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682964501; x=1685556501; 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=+2lYHhqlJD16G2HYpsFMb3ZFL7Kq76WjunB2OGwz3cs=; b=gXUe299MSamAa7oNk+nAExSjVcoVPYZBU9vjSck6PGVKvDeQAeyIQtu0fs7fee9lr5 S/bt/U2W+pu7rFgB5EoGH36GDFBFvkSb/ZAhnt2pKWo0kSonjJK5WEPVkou6El+lJ8KG dxrIpIaWjQqnCFFbBcQIiq4yoJeywbBhujjl42o2GNBPXo7zmifdUmlGvzpRV4aXyopG C4AiwLBRqYhusCZRvywvGNBEuJPh8U8mlEXffTw6YRoPeSN2ghx66yTRExfr9f7dlZja So9jfmBxFMq8WCDb589IHXtagjxWZZQmVr9jrweJNuUh6jmBKGLTZ3qlV0OtY1sAty+Q 5DMg== X-Gm-Message-State: AC+VfDzNLeds9Sy32n6kLKHlvUFYwSH01yxdP/mH9wgc3i6aFGMO4jNO 1giHwPfYQK+ppIfdYbn6S7eOY5Yfug3Rm5QlX5ouqQ== X-Received: by 2002:a5d:6351:0:b0:306:2b9e:2a8c with SMTP id b17-20020a5d6351000000b003062b9e2a8cmr3336094wrw.11.1682964500617; Mon, 01 May 2023 11:08:20 -0700 (PDT) MIME-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 1 May 2023 11:08:05 -0700 Message-ID: Subject: Re: [PATCH 00/40] 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, 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 1, 2023 at 10:47=E2=80=AFAM Roman Gushchin wrote: > > On Mon, May 01, 2023 at 09:54:10AM -0700, Suren Baghdasaryan wrote: > > 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 (nomem_profiling=3Dy) and (for comparison purposes) basel= ine > > with CONFIG_MEMCG_KMEM enabled and allocations using __GFP_ACCOUNT: > > > > kmalloc pgalloc > > Baseline (6.3-rc7) 9.200s 31.050s > > profiling disabled 9.800 (+6.52%) 32.600 (+4.99%) > > profiling enabled 12.500 (+35.87%) 39.010 (+25.60%) > > memcg_kmem enabled 41.400 (+350.00%) 70.600 (+127.38%) > > Hm, this makes me think we have a regression with memcg_kmem in one of > the recent releases. When I measured it a couple of years ago, the overhe= ad > was definitely within 100%. > > Do you understand what makes the your profiling drastically faster than k= mem? I haven't profiled or looked into kmem overhead closely but I can do that. I just wanted to see how the overhead compares with the existing accounting mechanisms. 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). 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. > > Thanks!