Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1446282rwd; Thu, 25 May 2023 12:45:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4e6i0R/iWW96O7ssuiMOyLhYeTbIoEXgRGVA3VXrmVzvTsjualEIr1AihKrMB0AyuPBcgN X-Received: by 2002:a17:903:32cd:b0:1af:efa5:6947 with SMTP id i13-20020a17090332cd00b001afefa56947mr3238219plr.39.1685043907233; Thu, 25 May 2023 12:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685043907; cv=none; d=google.com; s=arc-20160816; b=SUr4qmXKQpeBND17Ge3/YKj6mc500J2w6JyfBAusEOFXVjfMKshoOLW1h6zQ4uMDw4 jC1Li/QdSBchR6wfQtrGWzQfK+cHXZMDEKdZtmmPlHBQDrJu7UGCKvOjik1RgCg3TiVI 1Sy8UCdJpwPGvCu1T7aODXzNBorbd07ijEGW9gRYCUE2wslVTmd5gA55KGfdXWxKlu3x apFvWCXAZadC8k4Xzmh9E7Em54Qq+TqQnuVGqGDO3luk0LtJ84kGX8sqVI2j2Y6fRcGN l9sAGnq5AE68tFYewe0J3Y9nkM69uzyQWK1gkenhZSZXJFNUK7dQw/aQdUgqgfE4zGLV Ed9Q== 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; bh=Vt39i/BftUoM2GNX3BTlg6zOC7OQnBsMokEKJoMmKWI=; b=KTdm6IP2ncjTFxLUP7ckYHpKTBbjJM3vWPlMKkD9RBiijS8xJOiyXQG1JYARC4LNKz w98dk94dZG+iSSooXDiEk/znW2UhlPvTX4BnoFVONthOBfU82VaLwkm5Ar+US7RFl8k0 ui1gW6SvbvGED62BH/djROjfhV6n6J4b4vPn6eL+k0auwzolb3pXzEfsABKqeJDEvLaY zqMGWDlyLEEr70W/NM36I8C7juX9tfA4qwnuYsxt2GflPiCWDAbamiVfmil+NHYhh4XB 2UXIcR1+NNx0wPzDymMJcL4k5vWdu76EEoeoX5u7fQa1ue8wjR97sot/MjrSpwvQBWe8 PUuw== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020a170902761500b001a95c7e5ad9si2086529pll.352.2023.05.25.12.44.52; Thu, 25 May 2023 12:45:07 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240667AbjEYTXT convert rfc822-to-8bit (ORCPT + 99 others); Thu, 25 May 2023 15:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243688AbjEYTXC (ORCPT ); Thu, 25 May 2023 15:23:02 -0400 Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0742AE57; Thu, 25 May 2023 12:19:35 -0700 (PDT) Received: by mail-vk1-f177.google.com with SMTP id 71dfb90a1353d-456f7ea8694so312199e0c.0; Thu, 25 May 2023 12:19:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685042277; x=1687634277; 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=XUkevm3aMU5xLxVBa9KxEIFuZRkmPE748qzKxoDf9/0=; b=dNZ3rmg6sV4BREbRboM9CuBrgR24asHz38JUEVp2l5Zx77M4xIhYBCYbOx15qkXAgq /Xlae6PgTtVTfxIwOwKJF603ioO8shZhnO4oz8VdQwBskLPiagLq8k5aTuk1JtWe5d8j gZfKwC75aJ8Efc3et4VdwqMplnJsMqdtO/gU0CPGcS8x02hA/ogjCkrj/4/w/H7Swksv Z+F2jFNOTqessoEwGAWScSoOmpQ3nr/ASkXkuhIYz1UPfFh/h6mlSaeKusqbNIOVXa7d t36KL2/tr+kTqcbJvtRWLoDQsuECUWCEaP+E3VpbWv0Ps6oW4ciDtYJV8IA5605bY91t iGZw== X-Gm-Message-State: AC+VfDw+CSeWisxj/wWZo1Z9/PaGan7IyR1t5qFW1WjL4FwxTAsyAash 7OHIQ21CsjmRBExBRz5TD/A7etAJ/GQYu9FW6G4= X-Received: by 2002:a1f:e604:0:b0:43f:e32a:c650 with SMTP id d4-20020a1fe604000000b0043fe32ac650mr6364003vkh.15.1685042277355; Thu, 25 May 2023 12:17:57 -0700 (PDT) MIME-Version: 1.0 References: <20230525071133.2066610-1-irogers@google.com> <20230525071133.2066610-9-irogers@google.com> In-Reply-To: <20230525071133.2066610-9-irogers@google.com> From: Namhyung Kim Date: Thu, 25 May 2023 12:17:46 -0700 Message-ID: Subject: Re: [PATCH v1 08/16] perf daemon: Dynamically allocate path to perf To: Ian Rogers 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: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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:12 AM 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, struct 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 = strdup(path); > + return __daemon.perf; Then you need to free it somewhere. Thanks, Namhyung > +} > + > int cmd_daemon(int argc, const char **argv) > { > struct option daemon_options[] = { > @@ -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 = stdout; > > argc = parse_options(argc, argv, daemon_options, daemon_usage, > -- > 2.40.1.698.g37aff9b760-goog >