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 EE931A0A0A for ; Thu, 3 Jun 2021 07:00:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E47014013F; Thu, 3 Jun 2021 07:00:36 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 751E64013F for ; Thu, 3 Jun 2021 07:00:35 +0200 (CEST) Received: from mail-qk1-f197.google.com ([209.85.222.197]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lofT9-0000rf-7z for stable@dpdk.org; Thu, 03 Jun 2021 05:00:35 +0000 Received: by mail-qk1-f197.google.com with SMTP id l6-20020a3770060000b02902fa5329f2b4so3426399qkc.18 for ; Wed, 02 Jun 2021 22:00:35 -0700 (PDT) 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=6A7TssdYfHGK91DH1axMOSjR6c6MuPgh+6MuV/iDaVs=; b=F9lrqVs8pVzlDtyAZgiWsikW5xkIOg4pOdpgDCUeKLBphCvPwYrQrwN2reujeK26hm iTNxyd371pBBADTT7MuqY4IPnoy6Ga1j1ystSqw5UH23FTdN6QMdlvzmSzazJek4d85w RCXgxzNzqYVFL14qXP33dDZiX/Bm8JR9Ofq/7QHmC5KgHaIN3jufHDIQnLV9QMyS5dst 9Sforpm4MrVt1HB6nInjozMfvFcFi8CMo/cdlqgDCCFtFdJURk6NpXTvE31slWrrVCDi FcvgjsvzI/PC1iHC3g3eWe2Qtg5/fJrSqndvWUzM6+oyJS36uuf0ocM22Xr5h8VbMOcE aKrA== X-Gm-Message-State: AOAM5323wOSDPF9DXmVQghirZ7nAjdK/MBiTz/BHPbiLFBDc7wlxYST/ Bs459pL88yo2ICa1hvHllrdXdh45tNKoDd4GUixQQC3ComtIU7MQ7p2b2Id49Hsr6tbfkwUzzB9 Uwvy2FzCIV5eBZafdHX3TS7K5PKvj/ieB5lsmkHjS X-Received: by 2002:ac8:7c4b:: with SMTP id o11mr28031452qtv.336.1622696434270; Wed, 02 Jun 2021 22:00:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8geqt8iTMkOycNvUKG5IhwVQeDY1U5ukeQWNnVG/5zz98uBsRtvLY+bccEdXm33spXq/5jyJnOG1yFzpO+80= X-Received: by 2002:ac8:7c4b:: with SMTP id o11mr28031440qtv.336.1622696434035; Wed, 02 Jun 2021 22:00:34 -0700 (PDT) MIME-Version: 1.0 References: <20210521154907.320565-1-lucp.at.work@gmail.com> <20210521154907.320565-2-lucp.at.work@gmail.com> In-Reply-To: <20210521154907.320565-2-lucp.at.work@gmail.com> From: Christian Ehrhardt Date: Thu, 3 Jun 2021 07:00:08 +0200 Message-ID: To: Luc Pelletier Cc: dpdk stable Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [PATCH 19.11.9 2/2] eal: fix hang in control thread creation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Fri, May 21, 2021 at 5:49 PM Luc Pelletier wrote: > > [ upstream commit af68c1d699be6c369e296b775bdbf13ae18b79cc ] > > The affinity of a control thread is set after it has been launched. If > setting the affinity fails, pthread_cancel is called followed by a call > to pthread_join, which can hang forever if the thread's start routine > doesn't call a pthread cancellation point. > > This patch modifies the logic so that the control thread exits > gracefully if the affinity cannot be set successfully and removes the > call to pthread_cancel. > > Fixes: 6383d2642b62 ("eal: set name when creating a control thread") > --- Thank you, applied to 19.11.9 (to become -rc2) now > lib/librte_eal/common/eal_common_thread.c | 29 +++++++++++++---------- > 1 file changed, 17 insertions(+), 12 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c > index a5089ae49..b1e5c2a08 100644 > --- a/lib/librte_eal/common/eal_common_thread.c > +++ b/lib/librte_eal/common/eal_common_thread.c > @@ -161,12 +161,16 @@ static void ctrl_params_free(struct rte_thread_ctrl_params *params) > static void *rte_thread_init(void *arg) > { > struct rte_thread_ctrl_params *params = arg; > - void *(*start_routine)(void *) = params->start_routine; > + void *(*start_routine)(void *); > void *routine_arg = params->arg; > > pthread_barrier_wait(¶ms->configured); > + start_routine = params->start_routine; > ctrl_params_free(params); > > + if (start_routine == NULL) > + return NULL; > + > return start_routine(routine_arg); > } > > @@ -188,14 +192,12 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, > params->refcnt = 2; > > ret = pthread_barrier_init(¶ms->configured, NULL, 2); > - if (ret != 0) { > - free(params); > - return -ret; > - } > + if (ret != 0) > + goto fail_no_barrier; > > ret = pthread_create(thread, attr, rte_thread_init, (void *)params); > if (ret != 0) > - goto fail; > + goto fail_with_barrier; > > if (name != NULL) { > ret = rte_thread_setname(*thread, name); > @@ -206,19 +208,22 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, > > ret = pthread_setaffinity_np(*thread, sizeof(*cpuset), cpuset); > if (ret != 0) > - goto fail_cancel; > + params->start_routine = NULL; > > pthread_barrier_wait(¶ms->configured); > ctrl_params_free(params); > > - return 0; > + if (ret != 0) > + /* start_routine has been set to NULL above; */ > + /* ctrl thread will exit immediately */ > + pthread_join(*thread, NULL); > > -fail_cancel: > - pthread_cancel(*thread); > - pthread_join(*thread, NULL); > + return -ret; > > -fail: > +fail_with_barrier: > (void)pthread_barrier_destroy(¶ms->configured); > + > +fail_no_barrier: > free(params); > > return -ret; > -- > 2.25.1 > -- Christian Ehrhardt Staff Engineer, Ubuntu Server Canonical Ltd