Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3041795pxb; Sat, 6 Feb 2021 17:45:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwROit0KAUYm53Q/bmIhus0ILH2J9q/8vx2v80XnyinjqOr79PVktZPZ2ZnzWLpLTbmPNmj X-Received: by 2002:aa7:d297:: with SMTP id w23mr10739702edq.173.1612662328757; Sat, 06 Feb 2021 17:45:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612662328; cv=none; d=google.com; s=arc-20160816; b=Y/Vp61tnMt1a4DkAMpXurmV35nDrWpbV+mCf1hLM5751rgtGxSHNvsFVHcDkuqAzql cipJ/srTVqYfXJDCQ8OXKoIzVWfRx+yyiTk4XN3JzFazwiybGnNeS7ebDxR10+sYpaWX 8yJDoNBBMlU0tk2QnzPBhUdNp4L3WJAR0+6tEo6XUGmZjCUZcC+5uEpDAEtWO4HwTc4r ueshNC3iLhPjB/Dpkn9eFyuyz9hJLDtPLVxGPhOl8fJiO7evPVS3n68Se/QFffLVc5SU z1rGrgSCh+elmuuzsd+mn+GgkN58SbmmaomwWYm8uCd5cdFGoB9lrxSce6++Ik+vcTwt 9l7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=KxipTUAce9qB/6VR3y/HbUzBfM0MwI5RwtE1w0thUzg=; b=eFiVPTTyfpELlchCNgDvPRSESDAlU8rlOg1FpokcBqpf/dw7SA7XPK4Q5MgK5SpmXu FfFv8IAdFVvdYDtaZEbPYFlr2XAJm0+X2FKYGM+xozDMCBiVsMxj9z9hDg/ZPUGEHPz0 RVTAZV2h3vzUB5xRd3VwazSUFIXpXqKBLtuVqubIJQuj6dPFIvdHsNBLLmcbIHSOf+Km dtfKjMuIIC3XRpSakjvFTr8uYRd8D4Xj9G0IDnI9qHipCGILR6GOMAud8BbWpvYvQjKn fW3GKrYp5g+mzyqmvLHooKh3QYHm+lEvnC9H5h7ASIC0MqVwgXo8rTcBEStvdupySy+3 S7xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si9384060edj.194.2021.02.06.17.45.04; Sat, 06 Feb 2021 17:45:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229609AbhBGBhl (ORCPT + 99 others); Sat, 6 Feb 2021 20:37:41 -0500 Received: from mail-lj1-f182.google.com ([209.85.208.182]:32925 "EHLO mail-lj1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBGBhh (ORCPT ); Sat, 6 Feb 2021 20:37:37 -0500 Received: by mail-lj1-f182.google.com with SMTP id a25so12435424ljn.0 for ; Sat, 06 Feb 2021 17:37:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KxipTUAce9qB/6VR3y/HbUzBfM0MwI5RwtE1w0thUzg=; b=OrXoydRgATFh7b6xm9TVT+P7PMCGIuRnG580PBwBdQCW4o+b+QOlyhzNZ4kAbYng2m 3N0hEKSObtIH5axbmfFqqYHEg/MRVEVK1k4Q8+NhT5Ox08Tpf9G2qoAk0QquFwMUyuCi pMzB9htPb85rNzYvr5I4VdgMU/q6dak3b9MQAxmSkCC1jCtsQFauKHAW3kJwsYV4VWMB LS0mQ7K7gf00iBJhSkvs3zjF8YdMjEcnxGSsoOFaZI9rPFj/ZFHgt4PuQE8bNPx5oye6 d0Crd+QtJxguCmgcHZar1X5pQzTR1jLHCsNICLAtNLg+uzkqyN6El9pkHmTADIq1cD9a K/Lg== X-Gm-Message-State: AOAM531ycyMUujt9LBZIq1dgu60CS3bFpvuB4MA5Xny0J6w0ru5kEVUS BuGCbN+HJH2k7LC8s66RzaG9fJyH7Vf5wZ5B/+I= X-Received: by 2002:a2e:9007:: with SMTP id h7mr1780560ljg.26.1612661814510; Sat, 06 Feb 2021 17:36:54 -0800 (PST) MIME-Version: 1.0 References: <20210129134855.195810-1-jolsa@redhat.com> <20210130234856.271282-1-jolsa@kernel.org> <20210130234856.271282-5-jolsa@kernel.org> In-Reply-To: From: Namhyung Kim Date: Sun, 7 Feb 2021 10:36:43 +0900 Message-ID: Subject: Re: [PATCH 04/24] perf daemon: Add server socket support To: Jiri Olsa Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 7, 2021 at 4:04 AM Jiri Olsa wrote: > > On Fri, Feb 05, 2021 at 08:30:10PM +0900, Namhyung Kim wrote: > > On Sun, Jan 31, 2021 at 8:49 AM Jiri Olsa wrote: > > > > > > Add support to create server socket that listens for client > > > commands and process them. > > > > > > This patch adds only the core support, all commands using > > > this functionality are coming in following patches. > > > > > > Signed-off-by: Jiri Olsa > > > --- > > > tools/perf/builtin-daemon.c | 101 +++++++++++++++++++++++++++++++++++- > > > 1 file changed, 100 insertions(+), 1 deletion(-) > > > > > > diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c > > > index 8d0ac44ec808..756d60616d7d 100644 > > > --- a/tools/perf/builtin-daemon.c > > > +++ b/tools/perf/builtin-daemon.c > > > @@ -1,5 +1,6 @@ > > > // SPDX-License-Identifier: GPL-2.0 > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -7,6 +8,10 @@ > > > #include > > > #include > > > #include > > > +#include > > > +#include > > > +#include > > > +#include > > > #include "builtin.h" > > > #include "perf.h" > > > #include "debug.h" > > > @@ -37,6 +42,78 @@ static void sig_handler(int sig __maybe_unused) > > > done = true; > > > } > > > > > > +static int setup_server_socket(struct daemon *daemon) > > > +{ > > > + struct sockaddr_un addr; > > > + char path[100]; > > > + int fd; > > > + > > > + fd = socket(AF_UNIX, SOCK_STREAM, 0); > > > + if (fd < 0) { > > > + fprintf(stderr, "socket: %s\n", strerror(errno)); > > > + return -1; > > > + } > > > + > > > + fcntl(fd, F_SETFD, FD_CLOEXEC); > > > + > > > + scnprintf(path, PATH_MAX, "%s/control", daemon->base); > > > > I couldn't find where the default value of daemon->base is set. > > Also 100 bytes seem not enough for the path name. > > 108 bytes is the limit of the unix socket path, > I'm adding more checks on the provided base, > so we display some reasonable error Sgtm. Thanks, Namhyung