From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DD777A0547; Wed, 29 Sep 2021 14:29:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65570410E5; Wed, 29 Sep 2021 14:29:00 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 9CAE240685 for ; Wed, 29 Sep 2021 14:28:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632918538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oyqn45EYdq07k4kEEWQW4scvgEy+19/rw8885o3Iy2A=; b=RMnHmqT2gI/LjEDC2fk1kcOXlf528JStOxYx21N1MvZds+on3tTxJikr7ainXE6n59QYZA syNkrrsCnuuAnP4pE5YJZVkjvH3bmockErO6oE+4N5/81WIRf4mcdJ8TsnFPMJPyaNQvcd OAYz3m/9KnPjSSJHkzUusLXWScVYNN0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-wGqfqgncMo2FW6XvTXYm5A-1; Wed, 29 Sep 2021 08:28:56 -0400 X-MC-Unique: wGqfqgncMo2FW6XvTXYm5A-1 Received: by mail-wm1-f70.google.com with SMTP id d12-20020a1c730c000000b0030b4e0ecf5dso776662wmb.9 for ; Wed, 29 Sep 2021 05:28:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:subject:in-reply-to :content-transfer-encoding; bh=oyqn45EYdq07k4kEEWQW4scvgEy+19/rw8885o3Iy2A=; b=ETdjv+C8mq8NucsoELKdFvcYPpDJTumhjHwqijJzb1Ldie4BTYz9D1P9UWmegSQnfE 7sedHQHo4jo2pH0t/h1HVLv2Qxl4Z3AAjWLxuHT51rT9i7kvR7xBhQvrmg6n9BSmsBg8 0yu/f2x6ddjqj7XJhXvm/G89o+totvxFzfPfWfmsuDvioO9aj9yR7w4rUf9xEWdVgUQv v58e1aXN48DFk85PZW5HJs3LdXMVKou20kIQ4+xWGkXz2BG2KBEoi2CGT9Ec500csAVx epZJrqcfoH/b5VL4DVtugHbP2njhPDRTc9kRINiSAdtteVJ+hphsDmyAZzuFSyncSHHC zpRQ== X-Gm-Message-State: AOAM533qD+k13yh09a6GiezLZWyDPAMclqsJLaD3Jn/nH1RXSkBavpDd 4DzVhQDf982grJXjHNbYtr3Gk/ZKeMV1hoh74V8UX0csn8Tg+Xy7isn+Lpr7RuIhdHelhshZd88 lZY0= X-Received: by 2002:a1c:2289:: with SMTP id i131mr9975183wmi.34.1632918535531; Wed, 29 Sep 2021 05:28:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa76Y1NhZ7cr1vj9kRySBK+EvAeZHT9wjYe2QYMhHIzTJPw+AdK0M1xe4M7UO6Hk/ozyfK8w== X-Received: by 2002:a1c:2289:: with SMTP id i131mr9975174wmi.34.1632918535356; Wed, 29 Sep 2021 05:28:55 -0700 (PDT) Received: from [192.168.0.36] ([78.19.105.235]) by smtp.gmail.com with ESMTPSA id z6sm2136020wmp.1.2021.09.29.05.28.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 05:28:54 -0700 (PDT) Message-ID: <6ea20d4e-a7dd-afcb-3ca1-ffc023114d72@redhat.com> Date: Wed, 29 Sep 2021 13:28:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 To: Bruce Richardson , dev@dpdk.org Cc: ciara.power@intel.com, anatoly.burakov@intel.com, stable@dpdk.org, David Marchand References: <20210915141030.23514-1-bruce.richardson@intel.com> <20210924161842.2879019-1-bruce.richardson@intel.com> From: Kevin Traynor In-Reply-To: <20210924161842.2879019-1-bruce.richardson@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] telemetry: fix "in-memory" process socket conflicts X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Bruce, On 24/09/2021 17:18, Bruce Richardson wrote: > When DPDK is run with --in-memory mode, multiple processes can run > simultaneously using the same runtime dir. This leads to each process > removing another process' telemetry socket as it started up, giving > unexpected behaviour. > > This patch changes that behaviour to first check if the existing socket > is active. If not, it's an old socket to be cleaned up and can be > removed. If it is active, telemetry initialization fails and an error > message is printed out giving instructions on how to remove the error; > either by using file-prefix to have a different runtime dir (and > therefore socket path) or by disabling telemetry if it not needed. > telemetry is enabled by default but it may not be used by the application. Hitting this issue will cause rte_eal_init() to fail which will probably stop or severely limit the application. So it could change a working application to a non-working one (albeit one that doesn't interfere with other process' sockets). Can it just print a warning that telemetry will not be enabled and continue so it's not returning an rte_eal_init failure? A more minor thing, I see it changes the behaviour from, last one runs with telemetry, to, first one runs with telemetry. Though it can be figured from the commit message, it might be worth calling that change out explicitly. thanks, Kevin. > Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality") > Cc: stable@dpdk.org > > Reported-by: David Marchand > Signed-off-by: Bruce Richardson > --- > v2: fix build error on FreeBSD > --- > lib/telemetry/telemetry.c | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > > diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c > index 8304fbf6e9..78508c1a1d 100644 > --- a/lib/telemetry/telemetry.c > +++ b/lib/telemetry/telemetry.c > @@ -457,15 +457,30 @@ create_socket(char *path) > > struct sockaddr_un sun = {.sun_family = AF_UNIX}; > strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); > - unlink(sun.sun_path); > + > if (bind(sock, (void *) &sun, sizeof(sun)) < 0) { > struct stat st; > > - TMTY_LOG(ERR, "Error binding socket: %s\n", strerror(errno)); > - if (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode)) > + /* first check if we have a runtime dir */ > + if (stat(socket_dir, &st) < 0 || !S_ISDIR(st.st_mode)) { > TMTY_LOG(ERR, "Cannot access DPDK runtime directory: %s\n", socket_dir); > - sun.sun_path[0] = 0; > - goto error; > + goto error; > + } > + > + /* check if current socket is active */ > + if (connect(sock, (void *)&sun, sizeof(sun)) == 0) { > + TMTY_LOG(ERR, "Error binding telemetry socket, path already in use\n"); > + TMTY_LOG(ERR, "Use '--file-prefix' to select a different socket path, or '--no-telemetry' to disable\n"); > + path[0] = 0; > + goto error; > + } > + > + /* socket is not active, delete and attempt rebind */ > + unlink(sun.sun_path); > + if (bind(sock, (void *) &sun, sizeof(sun)) < 0) { > + TMTY_LOG(ERR, "Error binding socket: %s\n", strerror(errno)); > + goto error; > + } > } > > if (listen(sock, 1) < 0) { >