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 85C78A0C52; Thu, 21 Oct 2021 17:46:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FFEA411FE; Thu, 21 Oct 2021 17:46:12 +0200 (CEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id 98A3D4118E for ; Thu, 21 Oct 2021 17:46:11 +0200 (CEST) Received: by mail-wm1-f44.google.com with SMTP id s198-20020a1ca9cf000000b0030d6986ea9fso116532wme.1 for ; Thu, 21 Oct 2021 08:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CGNjK2zwOqVs4YobsRCR1EILtskXrIZlxrchrlzFodQ=; b=IVizOqYeFK70ujwaQhIgbSJoVKYPdGvCYxMQ0rAbMDOjjEywPJaUC6EGiYybTfgUgm prNHmRmpSFhVDMYyPdU3g7FgKiSXgLir2g2dmK2upHtdaOmLpEyw4KIyM3pjI9V6l0nH 3YJ9rr/7fGDXI0FTP1PhZK0rRA0cirlxZV7M2NZsYYX1RpMoQNl9H8f21/T9urSaHUr9 HxbdIT8UC5XhKGxwu1yw57yLXVRgdAFVaZUBkFjo8osT76wtHIbH/rsHH0r0e6Nt5NeT j/CsjJJ7PK6HnQCUsdnBd16gDtdv3FxJRw1gTLFwzO0n1BGF6zgs3G/XmxKDmXg4CORl Gw8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CGNjK2zwOqVs4YobsRCR1EILtskXrIZlxrchrlzFodQ=; b=m0Fak2Ig5Nc8KJLXMke8lqnLgl0GGi97o7aInY4mXvovTY6SrpIsPCO0pr4YVC0Zgb Ks64Q+zvlRvWEL5+f2qgPhh5iVa3OzQWGkzjg2ma30icga5kRmc4lT9O74ZlRorLmHH/ JDXfgacrO1enGCVHQ00yMC5U7HMZAjJWB3CMCmPjarlYm4ycGziAlYcxJln6aO2UE95O zO17kdLW/srzlGp1PDFSpifQQiAgRzXnm0uIE8nl5lEr0oEq/eRHEksZ+ZC+HB8ZP/+M de9i9OVYekcDXxM0/K22N6lieA+IgYKj4nQR+oA5Z+t/rKbPhnE2nIQQuRGfILq6fhwA Ie1Q== X-Gm-Message-State: AOAM532pCa5RUjSQvsCg3eTfgNVN74OPJxryq+Jg4vHBu+ZxAMVeQIf1 QERPK3v25y3mYuLtQl64ApD4Fw== X-Google-Smtp-Source: ABdhPJzSfVAEdUmdIWQxOXtvkAdWSQm1J1v7hbJBQGMUcdxJV8C2AFIcW5WqFa6Qz7wH3Cme4x3wgw== X-Received: by 2002:a1c:f402:: with SMTP id z2mr22775028wma.53.1634831171395; Thu, 21 Oct 2021 08:46:11 -0700 (PDT) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id f7sm2831868wmg.14.2021.10.21.08.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 08:46:10 -0700 (PDT) Date: Thu, 21 Oct 2021 17:46:10 +0200 From: Olivier Matz To: Honnappa Nagarahalli Cc: dev@dpdk.org, lucp.at.work@gmail.com, stephen@networkplumber.org, david.marchand@redhat.com, thomas@monjalon.net, ruifeng.wang@arm.com, nd@arm.com Message-ID: References: <20210730213709.19400-1-honnappa.nagarahalli@arm.com> <20211013201811.15247-1-honnappa.nagarahalli@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211013201811.15247-1-honnappa.nagarahalli@arm.com> Subject: Re: [dpdk-dev] [PATCH v4 1/2] eal: simplify the implementation of rte_ctrl_thread_create 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 Honnappa, On Wed, Oct 13, 2021 at 03:18:10PM -0500, Honnappa Nagarahalli wrote: > Remove the usage of pthread barrier and replace it with > synchronization using atomic variable. This also removes > the use of reference count required to synchronize freeing > the memory. > > Signed-off-by: Honnappa Nagarahalli Reviewed-by: Olivier Matz Few cosmetics comments below. (...) > +enum __rte_ctrl_thread_status { > + __RTE_CTRL_THREAD_LAUNCHING, /* Yet to call pthread_create function */ > + __RTE_CTRL_THREAD_RUNNING, /* Control thread is running successfully */ > + __RTE_CTRL_THREAD_ERROR /* Control thread encountered an error */ > +}; > + Are there double underscores needed? I think even the rte_ prefix could be removed since this is not exposed. (...) > @@ -236,24 +239,22 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, > "Cannot set name for ctrl thread\n"); > } > > - ret = pthread_setaffinity_np(*thread, sizeof(*cpuset), cpuset); > - if (ret != 0) > - params->start_routine = NULL; > - > - pthread_barrier_wait(¶ms->configured); > - ctrl_params_free(params); > - > - if (ret != 0) > - /* start_routine has been set to NULL above; */ > - /* ctrl thread will exit immediately */ > + /* Wait for the control thread to initialize successfully */ > + while ((ctrl_thread_status = > + __atomic_load_n(¶ms->ctrl_thread_status, __ATOMIC_ACQUIRE)) > + == __RTE_CTRL_THREAD_LAUNCHING) > + /* Yield the CPU. Using sched_yield call requires maintaining > + * another implementation for Windows as sched_yield is not > + * supported on Windows. > + */ > + rte_delay_us_sleep(1); > + > + /* Check if the control thread encountered an error */ > + if (ctrl_thread_status == __RTE_CTRL_THREAD_ERROR) > + /* ctrl thread is exiting */ > pthread_join(*thread, NULL); While not required, I suggest to use curly brackets when the number of lines in the body of the loop or test (including comments). Thanks Olivier