From: David Marchand <david.marchand@redhat.com>
To: Wei Huang <wei.huang@intel.com>
Cc: dev <dev@dpdk.org>, Rosen Xu <rosen.xu@intel.com>,
Qi Zhang <qi.z.zhang@intel.com>, dpdk stable <stable@dpdk.org>,
"Zhang, Tianfei" <tianfei.zhang@intel.com>,
"Yigit, Ferruh" <ferruh.yigit@intel.com>
Subject: Re: [PATCH v3] raw/ifpga: fix pthread cannot join
Date: Thu, 20 Jan 2022 09:08:16 +0100 [thread overview]
Message-ID: <CAJFAV8y=DOUuULWCLVXex9LDBHOaSi45W2ZJ867_+ToH5+Vzcg@mail.gmail.com> (raw)
In-Reply-To: <20220120055814.7244-1-wei.huang@intel.com>
On Thu, Jan 20, 2022 at 7:01 AM Wei Huang <wei.huang@intel.com> wrote:
>
> From: Tianfei Zhang <tianfei.zhang@intel.com>
>
> When we want to close a thread, we should set a flag to notify
> thread handler function.
>
> Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com>
> ---
> v2: update commit log
> ---
> v3: set thread id to 0 after pthread_join
Evaluating/setting a pthread_t variable is a bad idea: this type
should be considered opaque.
Plus here, the ifpga_monitor_start variable already indicates whether
ifpga_monitor_start_thread is valid.
Only checking for ifpga_monitor_start in ifpga_rawdev_gsd_handle loop
should be enough.
> ---
> drivers/raw/ifpga/ifpga_rawdev.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
> index 8d9db58..2bc569b 100644
> --- a/drivers/raw/ifpga/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga/ifpga_rawdev.c
> @@ -497,7 +497,7 @@ static int set_surprise_link_check_aer(
> int gsd_enable, ret;
> #define MS 1000
>
> - while (1) {
> + while (ifpga_monitor_start) {
> gsd_enable = 0;
> for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
> ifpga_rdev = &ifpga_rawdevices[i];
> @@ -542,18 +542,21 @@ static int set_surprise_link_check_aer(
> static int
> ifpga_monitor_stop_func(void)
> {
> + void *status;
This status variable is unused, no need for it.
> int ret;
>
> - if (ifpga_monitor_start == 1) {
> + if ((ifpga_monitor_start == 1) && ifpga_monitor_start_thread) {
> + ifpga_monitor_start = 0;
> +
> ret = pthread_cancel(ifpga_monitor_start_thread);
> if (ret)
> IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread");
>
> - ret = pthread_join(ifpga_monitor_start_thread, NULL);
> + ret = pthread_join(ifpga_monitor_start_thread, &status);
> if (ret)
> IFPGA_RAWDEV_PMD_ERR("Can't join the thread");
>
> - ifpga_monitor_start = 0;
> + ifpga_monitor_start_thread = 0;
>
> return ret;
> }
> --
> 1.8.3.1
>
--
David Marchand
next prev parent reply other threads:[~2022-01-20 8:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-19 5:54 [PATCH v1] " Wei Huang
2022-01-19 10:45 ` Xu, Rosen
2022-01-20 2:35 ` [PATCH v2] " Wei Huang
2022-01-20 5:58 ` [PATCH v3] " Wei Huang
2022-01-20 8:08 ` David Marchand [this message]
2022-01-20 15:46 ` Stephen Hemminger
2022-01-21 8:02 ` Zhang, Tianfei
2022-01-21 1:29 ` [PATCH v4] " Wei Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJFAV8y=DOUuULWCLVXex9LDBHOaSi45W2ZJ867_+ToH5+Vzcg@mail.gmail.com' \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=qi.z.zhang@intel.com \
--cc=rosen.xu@intel.com \
--cc=stable@dpdk.org \
--cc=tianfei.zhang@intel.com \
--cc=wei.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).