From nobody Mon Feb 9 06:34:44 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AB34C77B7E for ; Thu, 25 May 2023 07:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232180AbjEYHN7 (ORCPT ); Thu, 25 May 2023 03:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237564AbjEYHNO (ORCPT ); Thu, 25 May 2023 03:13:14 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0DB10F7 for ; Thu, 25 May 2023 00:12:39 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba8bab3b392so605991276.1 for ; Thu, 25 May 2023 00:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684998750; x=1687590750; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=OOlx2WRh+JFuq5y5J1qgtXH5kcli3Ek1O+02SLEhl6g=; b=kmXVsTge4xmX+270y+4v3x5uW1+11ox1yW+hi9yEMgQn9sO0CHfD+VwreYbdFONYoN LjcOzr176iehQTRWpLbTvBtKPzDvkKPOHMOe5UJli8zL7Q/4efTzSwUWVeoLxMGAGIL5 52U1NI/uaGB+bmjAvbSlPl1I+T4m4aHFhvV1yeGgJzmXFBme6m9WwsXSRMKvyohQDQdH cRhImkqUfXu2cmZJRZ+7FtGsPaqchPbL/I0+x+Yxy7oWeIg2ikFVuyIm6Vf3Y9N+ZFFY A573FB21aZOIgWnAoW2z8qnTLF+RMR9aL76pKKyKZht6Sn0y9c3r/kQMunTjTkCfFftM I/Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684998750; x=1687590750; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OOlx2WRh+JFuq5y5J1qgtXH5kcli3Ek1O+02SLEhl6g=; b=YKNMDi3mmyw4up4tZguBjlBhrEBofBWoLanHbhH5C004JhxZKw1di5RZSsmPGAV1zK iytxYUpOSr7GXNgK/jSkMOlUxpqJUNZBcoOtPoD5K/EwRHGSSxXpxP/xMcVBXnZ+Kl+B vmwxk9R1e55g42BakA2ZXkMr7zgQAtjqeh6tWv7fii7lKpGipAWekFekUC9aftuDakpn 8PJREUY5NB/00pnV2548hQ0Vxb6DIYbM1kwd9zT4d77bOAu5f0wsyCfdgpGSOwA0nXE+ MAglK1fGyi0AgrXJbJvOWTvalzjz4OO1cpWMu0bnVbF/ir1H9lAOAn2Oqcyb0u7DBj9q dT+A== X-Gm-Message-State: AC+VfDwJVaTW0MONnaQlVKh8PdQC1DUf9H/dehGPJ1KOCTExYAfEXAGh gvQ7PLuweea6slSs7EMr+Himq0s3Km5y X-Google-Smtp-Source: ACHHUZ5IKhWTV/gXJDXr9pJVclWxuWbfOiaxQn3UH+XZ67yumdh7Bo9yq4vReN/76WBymOEj6XPPtLGWFSZY X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a25:6584:0:b0:ba8:381b:f764 with SMTP id z126-20020a256584000000b00ba8381bf764mr1455616ybb.3.1684998750427; Thu, 25 May 2023 00:12:30 -0700 (PDT) Date: Thu, 25 May 2023 00:11:31 -0700 In-Reply-To: <20230525071133.2066610-1-irogers@google.com> Message-Id: <20230525071133.2066610-15-irogers@google.com> Mime-Version: 1.0 References: <20230525071133.2066610-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v1 14/16] tools api fs: Dynamically allocate cgroupfs mount point cache From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , "Masami Hiramatsu (Google)" , "Steven Rostedt (Google)" , Ross Zwisler , Leo Yan , Tiezhu Yang , Yang Jihong , Andi Kleen , Kan Liang , Ravi Bangoria , Sean Christopherson , K Prateek Nayak , Paolo Bonzini , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the cgroupfs_cache_entry 4128 byte array out of .bss. Signed-off-by: Ian Rogers --- tools/lib/api/fs/cgroup.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/lib/api/fs/cgroup.c b/tools/lib/api/fs/cgroup.c index 1573dae4259d..250629a09423 100644 --- a/tools/lib/api/fs/cgroup.c +++ b/tools/lib/api/fs/cgroup.c @@ -14,7 +14,7 @@ struct cgroupfs_cache_entry { }; =20 /* just cache last used one */ -static struct cgroupfs_cache_entry cached; +static struct cgroupfs_cache_entry *cached; =20 int cgroupfs_find_mountpoint(char *buf, size_t maxlen, const char *subsys) { @@ -24,9 +24,9 @@ int cgroupfs_find_mountpoint(char *buf, size_t maxlen, co= nst char *subsys) char *p, *path; char mountpoint[PATH_MAX]; =20 - if (!strcmp(cached.subsys, subsys)) { - if (strlen(cached.mountpoint) < maxlen) { - strcpy(buf, cached.mountpoint); + if (cached && !strcmp(cached->subsys, subsys)) { + if (strlen(cached->mountpoint) < maxlen) { + strcpy(buf, cached->mountpoint); return 0; } return -1; @@ -91,8 +91,13 @@ int cgroupfs_find_mountpoint(char *buf, size_t maxlen, c= onst char *subsys) free(line); fclose(fp); =20 - strncpy(cached.subsys, subsys, sizeof(cached.subsys) - 1); - strcpy(cached.mountpoint, mountpoint); + if (!cached) + cached =3D calloc(1, sizeof(*cached)); + + if (cached) { + strncpy(cached->subsys, subsys, sizeof(cached->subsys) - 1); + strcpy(cached->mountpoint, mountpoint); + } =20 if (mountpoint[0] && strlen(mountpoint) < maxlen) { strcpy(buf, mountpoint); --=20 2.40.1.698.g37aff9b760-goog