Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp566449rwd; Thu, 25 May 2023 00:14:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4CGado5FtbHgusg6TipDQG4Yf3Gn2OMX7G7fD1vmws2wp6XIsxMKOmX984DtO804iFnkbM X-Received: by 2002:a17:902:e892:b0:1ae:1237:874d with SMTP id w18-20020a170902e89200b001ae1237874dmr618246plg.69.1684998881793; Thu, 25 May 2023 00:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684998881; cv=none; d=google.com; s=arc-20160816; b=HClRJ0hjtKOO3dlWyRQokTQHbk2SwAIHg04PzF790oYi5uF6irtPP8IKaNuakNA0ES 93SU0OJixNTXKIztg8DI9s1pDQpPDfUxILvBWn3TZK58ApvtZY5SDXTPz+wy8sE9QJGq bApMdQugOPvFAYunk5mKyxC7jqcUUnBwgq15UpFlTGwc3fIKRwNXQ3r+CpNtpOvvDz6m gRQRyYWpIvmlHu2XkuBAIGIBtg9fMWFqqy4M9xoyFjWmfc3k7f2MOn1crl8YthbO6HVn G39wcjs6lpYsQdt9cKTH5uyEJdrfM4mXW6Lc19InSWxT2hKUWr3rLos77+54t0gzpYxa iyfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=JINgRbKyqeD/5xjEyB2Z8M27zbkpuoQ93P6f/ale0uI=; b=KtGxjsS9VNpB8syXQ+AG44Evjx7CXuaJTUQXEs5wLHjj7ZoE1Mwi/agdoHnOiROXFP 76zMwx/nWQhnqcDPG1Gf76cYy2DtZ9ERRUYEz9MTp6J9jYUlrTQamsIBWCzPv+tifGxe rIk9zwTIZNaYlvi4rN0juOPe9pkb6jEb5c9YX1+tN/9nwVTYcVWsjb2VDZ2IsCXaCygM b4JKhHl10ou6obNOEDL9u9NAYTRuevmGdlXXQWz0DqDMdDMP0Ln+jyzrlTevRbCt3Ezv hBjAMX0og7Hj44az3MzK/mwVMSsxDSBfsVdjjiD3HsfJOsN6qfyXPb8szMITYS535Hqn cJOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OP4afWsT; 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 jh9-20020a170903328900b001ab2a0e3163si787827plb.598.2023.05.25.00.14.29; Thu, 25 May 2023 00:14:41 -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=OP4afWsT; 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 S239118AbjEYHNI (ORCPT + 99 others); Thu, 25 May 2023 03:13:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238998AbjEYHM0 (ORCPT ); Thu, 25 May 2023 03:12:26 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0C28E4C for ; Thu, 25 May 2023 00:12:17 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba83fed51b0so392957276.3 for ; Thu, 25 May 2023 00:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684998736; x=1687590736; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=JINgRbKyqeD/5xjEyB2Z8M27zbkpuoQ93P6f/ale0uI=; b=OP4afWsTIYHlIiVTegNyeLRIqJ2zMqeyRsGXo/7eq4nQ5gebMPUTViLGgtu89xP43w X25NyK2bhxqAHZtrw1issc4tRmXnff5EtFVyw+kq3E99WowlEQlVAV4935YOas6Bl/Bq LhMHBUoNbwpi0bpYt5T9maZQF4yoblT3yyX+IAZdUcmpyyuKxTOzG4miAldimh5JFUIB Hiu2a09aHEQYNjXmmZv0C//qoO+ntkS8zOpyqiIypFAXIpib6mKGDVU/UHRod0EfNM7Q nOsc/DeVMBBGfIoAUK4Fbqu4C3dpZ7W1WSvi/0P4y2uIevkTZhzXlmn9TyFaWIKeHC/j G8xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684998736; x=1687590736; 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=JINgRbKyqeD/5xjEyB2Z8M27zbkpuoQ93P6f/ale0uI=; b=OTt4vhmOHSyKpyGoFLM2D0FjycajqHp5qBzJSUpZ5UXmCi5j7n+d2ejRTrraLHOhYL w2CZKKmEH9SnYAl5KmvousH5gCkcjQiRXKOpKVApvmDWkbP7wUpSt6tsqG9Di6k5nuMH PGfdUWNR0gWnF19l5kCkQxHv2dkylJCDMMswbd8kt6NR+BpeN7ewiT5vd7MFUMTaE0l2 ChEHutaX29dh90bcegG2DVXsFjcT8ANGHn+jV1uVfSurxhEi0cdxv8RGsCNznCuQghJp Dq2V52j2b3w+xcTG02Ky+KzxXry1CqkxCVnbqnznq3MypcIg9slrFzdSFdctvyRXMt3H NoqA== X-Gm-Message-State: AC+VfDxNjxLxip3/sKjE5Hr1tfpCeFOjoacu3KFCG9ICnnciTevgWgJ6 UvqPTjnAQFwS19fZhznA9Y3OOQBNzOaF X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a25:7456:0:b0:ba7:1499:e202 with SMTP id p83-20020a257456000000b00ba71499e202mr1646377ybc.7.1684998736756; Thu, 25 May 2023 00:12:16 -0700 (PDT) Date: Thu, 25 May 2023 00:11:25 -0700 In-Reply-To: <20230525071133.2066610-1-irogers@google.com> Message-Id: <20230525071133.2066610-9-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 08/16] perf daemon: Dynamically allocate path to perf 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 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; +} + 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