Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1831553rwd; Thu, 25 May 2023 19:50:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KNEzvpfK1MGXpuaoPGj+edSQP9WP5QRwdyNqcoaGGYAX1l3NHtSGkHj+F6exy+wPVSOt1 X-Received: by 2002:a05:6a00:9a3:b0:63e:6b8a:7975 with SMTP id u35-20020a056a0009a300b0063e6b8a7975mr1460628pfg.9.1685069425624; Thu, 25 May 2023 19:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685069425; cv=none; d=google.com; s=arc-20160816; b=R2CP3CsEd8k1hZHvPKNpnfVh/yu955fQOcejPMejRZZ3ovZmmhi6Q0s0j3UTDA+BVm BmAcIuBPzzeUHBn03b1GFMkGtifslXsah/qZx76NHQoF4pVRFbxCl8tBZRqb7KgyEmTs FQEoOx7lwGcAAily3Grk/YZyYmnvqfwCmFNgcYsTGMYw/3d8iBYCG4YgVa3Dko6y7wqm +GrPqNXJouEZuwZByiYqJw94hSKbuM87nDaQwi69Pu6984C5C+vM/vunkMwjHNWk7xkP qMzxEUHHj+3ZiV4QrRg2Feja/ys3pZqv8GnRNBgDTh2LDNxhEIC1EaDhE1HvjiP9EigE mCug== 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=zUzk7xsdgJU7M6GKVkRONbmBW/W1VsolmG1MhtnbW4k=; b=YwaUgPEmniNM6STJH7eORHWGC2GeYB3J6eD3EJq/1BOhn3TFzEDuCrWHTFtA3xF6Si aXAl2azpprSlxUACeP1NlTH5hu06lNzH7N2xn8bUyhp2WIuUwZt0b2XRAbFZaPHZAxWb 6jZArN0ey7/upMzEsU3ys7jCtj2p8jK8vOsi5hbPP6iNB8O8z/Osl1aI4Te02ECXk9dR J01H1NFcNsH2kh6xMEIGOfD7O9PoNobvmtmH2BuBQ2GNljaP1iI7ylsajgrXokJzUTn1 eDVHF07M0P+O+8S0nK7gppDG+qKlQBh0GKQlZMHZ+NOkAtqtAnYXXdnDIGCmiM+64Qg9 bNuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="dewv9/nO"; 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 h2-20020aa796c2000000b0063b7f1ed115si2896174pfq.167.2023.05.25.19.50.11; Thu, 25 May 2023 19:50:25 -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="dewv9/nO"; 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 S232149AbjEZClL (ORCPT + 99 others); Thu, 25 May 2023 22:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbjEZClI (ORCPT ); Thu, 25 May 2023 22:41:08 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52517E6 for ; Thu, 25 May 2023 19:41:07 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f5dbd8f677so19755e9.1 for ; Thu, 25 May 2023 19:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685068866; x=1687660866; 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=zUzk7xsdgJU7M6GKVkRONbmBW/W1VsolmG1MhtnbW4k=; b=dewv9/nOBEAzMMod+HXOrJ8nBG3gmuVk08ABPHupoSdpSx+7jxn5yueVp3w2S3nQR5 dVwzByUhHIuOJwycmURLANkZpcqXcccLLvNNFiWCeYTktW72fiRXLExhXMq3Tg0gdLqQ xqL+o3eBlXJjpy3ija2AJz09T0JXh6eMj+bLhfyWcE7+QhSZo+nxPSmLumbyMBvvyKYI h0f28YcmKLp0GCEMCVKWRmn8ioJG8Bh4l5OGA8k3U3obCQdTmz6MFaV56wXuLV0CJU+P kO/D0B9dSVRI7EXyi7s0TCWI1DFHS5yo/ge6o3eKNtIugLRDv9KId1tdAjQO3nu7wmoB z58Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685068866; x=1687660866; 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=zUzk7xsdgJU7M6GKVkRONbmBW/W1VsolmG1MhtnbW4k=; b=CJbrC2+PGIDgIYGbaDq34j3OVILQJ8CAPKsywOkxy/OtTEgQSIhz/rlfHqHM9Xhye2 9R55EnL9hM747LL0HnrTxAdFCb0zVivP+tgSfb3ufmv890RSBgP2UHh+GXhheX/Fhi7g MCafVvNL1Xn8epGo/F899xMrrzBhsKgk5vGkRSsPQrqsRe5eYX37C96ELTdriHtymJRp uaLDHhV7gx1XZcXb0aGwuawY5g4Wr51jXMG03ef1p8Cx/ykF/+ef7ieK2l4bqI22Rg2t NwbaSEegfbznGYDsAfo1WOnRUGk9yj4nbXv4JJFo5jvODLfoXCbimQRbZUNxqqPIffPM y1jQ== X-Gm-Message-State: AC+VfDwUMsi38rkQfpziiLrsFWmUfz69QWT3kfx7tTgS8erhkbSTuojC MULP8xN83JJcoqu/+4/xlRn4/5UCXaAkUIBKhAVtFQ== X-Received: by 2002:a05:600c:4711:b0:3f5:f63:d490 with SMTP id v17-20020a05600c471100b003f50f63d490mr2819wmo.5.1685068865714; Thu, 25 May 2023 19:41:05 -0700 (PDT) MIME-Version: 1.0 References: <20230525071133.2066610-1-irogers@google.com> <20230525071133.2066610-9-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Thu, 25 May 2023 19:40:53 -0700 Message-ID: Subject: Re: [PATCH v1 08/16] perf daemon: Dynamically allocate path to perf To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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 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=ham 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 Thu, May 25, 2023 at 12:17=E2=80=AFPM Namhyung Kim = wrote: > > On Thu, May 25, 2023 at 12:12=E2=80=AFAM Ian Rogers = wrote: > > > > Avoid a PATH_MAX array in __daemon (the .data section) by dynamically > > allocating the memory. > > > > Signed-off-by: Ian Rogers > > --- > > tools/perf/builtin-daemon.c | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c > > index 34cbe3e959aa..adb5751c3ed0 100644 > > --- a/tools/perf/builtin-daemon.c > > +++ b/tools/perf/builtin-daemon.c > > @@ -90,7 +90,7 @@ struct daemon { > > char *base; > > struct list_head sessions; > > FILE *out; > > - char perf[PATH_MAX]; > > + char *perf; > > int signal_fd; > > time_t start; > > }; > > @@ -1490,6 +1490,15 @@ static int __cmd_ping(struct daemon *daemon, str= uct option parent_options[], > > return send_cmd(daemon, &cmd); > > } > > > > +static char *set_perf_exe(void) > > +{ > > + char path[PATH_MAX]; > > + > > + perf_exe(path, sizeof(path)); > > + __daemon.perf =3D strdup(path); > > + return __daemon.perf; > > Then you need to free it somewhere. For leak sanitizer, if an allocation is reachable from a global then it isn't considered a leak. I'll address this in v2. Thanks, Ian > Thanks, > Namhyung > > > > +} > > + > > int cmd_daemon(int argc, const char **argv) > > { > > struct option daemon_options[] =3D { > > @@ -1503,7 +1512,9 @@ int cmd_daemon(int argc, const char **argv) > > OPT_END() > > }; > > > > - perf_exe(__daemon.perf, sizeof(__daemon.perf)); > > + if (!set_perf_exe()) > > + return -ENOMEM; > > + > > __daemon.out =3D stdout; > > > > argc =3D parse_options(argc, argv, daemon_options, daemon_usage= , > > -- > > 2.40.1.698.g37aff9b760-goog > >