DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Power, Ciara" <ciara.power@intel.com>
To: "Min Hu (Connor)" <humin29@huawei.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>
Cc: "Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"Pattan, Reshma" <reshma.pattan@intel.com>
Subject: Re: [dpdk-dev] [PATCH v4 1/2] telemetry: fix missing check for thread creation
Date: Mon, 19 Apr 2021 08:49:28 +0000
Message-ID: <MN2PR11MB38217D6D7BDE83D7CE388DD0E6499@MN2PR11MB3821.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1618561106-26716-2-git-send-email-humin29@huawei.com>

Hi Connor,

>-----Original Message-----
>From: Min Hu (Connor) <humin29@huawei.com>
>Sent: Friday 16 April 2021 09:18
>To: dev@dpdk.org
>Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Power, Ciara
><ciara.power@intel.com>; Pattan, Reshma <reshma.pattan@intel.com>;
>david.marchand@redhat.com
>Subject: [PATCH v4 1/2] telemetry: fix missing check for thread creation
>
>From: Chengwen Feng <fengchengwen@huawei.com>
>
>Add result check and message print out for thread creation after failure.
>
>Fixes: b80fe1805eee ("telemetry: introduce backward compatibility")
>Cc: stable@dpdk.org
>
>Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>---
> lib/librte_telemetry/telemetry.c        | 37
>++++++++++++++++++++++++++++++---
> lib/librte_telemetry/telemetry_legacy.c | 11 ++++++++--
> 2 files changed, 43 insertions(+), 5 deletions(-)
>
>diff --git a/lib/librte_telemetry/telemetry.c
>b/lib/librte_telemetry/telemetry.c
>index 7e08afd..08ce189 100644
>--- a/lib/librte_telemetry/telemetry.c
>+++ b/lib/librte_telemetry/telemetry.c
>@@ -350,6 +350,7 @@ socket_listener(void *socket)  {
> 	while (1) {
> 		pthread_t th;
>+		int rc;
> 		struct socket *s = (struct socket *)socket;
> 		int s_accepted = accept(s->sock, NULL, NULL);
> 		if (s_accepted < 0) {
>@@ -366,7 +367,17 @@ socket_listener(void *socket)
> 			__atomic_add_fetch(s->num_clients, 1,
> 					__ATOMIC_RELAXED);
> 		}
>-		pthread_create(&th, NULL, s->fn, (void
>*)(uintptr_t)s_accepted);
>+		rc = pthread_create(&th, NULL, s->fn,
>+				    (void *)(uintptr_t)s_accepted);
>+		if (rc != 0) {
>+			TMTY_LOG(ERR, "Error with create client thread:
>%s\n",
>+				 strerror(rc));
>+			close(s_accepted);
>+			if (s->num_clients != NULL)
>+				__atomic_sub_fetch(s->num_clients, 1,
>+						   __ATOMIC_RELAXED);
>+			continue;
>+		}
> 		pthread_detach(th);
> 	}
> 	return NULL;
>@@ -425,6 +436,7 @@ static int
> telemetry_legacy_init(void)
> {
> 	pthread_t t_old;
>+	int rc;
>
> 	if (num_legacy_callbacks == 1) {
> 		TMTY_LOG(WARNING, "No legacy callbacks, legacy socket
>not created\n"); @@ -440,7 +452,16 @@ telemetry_legacy_init(void)
> 	v1_socket.sock = create_socket(v1_socket.path);
> 	if (v1_socket.sock < 0)
> 		return -1;
>-	pthread_create(&t_old, NULL, socket_listener, &v1_socket);
>+	rc = pthread_create(&t_old, NULL, socket_listener, &v1_socket);
>+	if (rc != 0) {
>+		TMTY_LOG(ERR, "Error with create legcay socket thread:
>%s\n",
>+			 strerror(rc));
>+		close(v1_socket.sock);
>+		v1_socket.sock = -1;
>+		unlink(v1_socket.path);
>+		v1_socket.path[0] = '\0';
>+		return -1;
>+	}
> 	pthread_setaffinity_np(t_old, sizeof(*thread_cpuset), thread_cpuset);
>
> 	TMTY_LOG(DEBUG, "Legacy telemetry socket initialized ok\n"); @@
>-451,6 +472,7 @@ static int
> telemetry_v2_init(void)
> {
> 	pthread_t t_new;
>+	int rc;
>
> 	v2_socket.num_clients = &v2_clients;
> 	rte_telemetry_register_cmd("/", list_commands, @@ -469,7 +491,16
>@@ telemetry_v2_init(void)
> 	v2_socket.sock = create_socket(v2_socket.path);
> 	if (v2_socket.sock < 0)
> 		return -1;
>-	pthread_create(&t_new, NULL, socket_listener, &v2_socket);
>+	rc = pthread_create(&t_new, NULL, socket_listener, &v2_socket);
>+	if (rc != 0) {
>+		TMTY_LOG(ERR, "Error with create socket thread: %s\n",
>+			 strerror(rc));
>+		close(v2_socket.sock);
>+		v2_socket.sock = -1;
>+		unlink(v2_socket.path);
>+		v2_socket.path[0] = '\0';
>+		return -1;
>+	}
> 	pthread_setaffinity_np(t_new, sizeof(*thread_cpuset),
>thread_cpuset);
> 	atexit(unlink_sockets);
>
>diff --git a/lib/librte_telemetry/telemetry_legacy.c
>b/lib/librte_telemetry/telemetry_legacy.c
>index 5e9af37..b7cd1bd 100644
>--- a/lib/librte_telemetry/telemetry_legacy.c
>+++ b/lib/librte_telemetry/telemetry_legacy.c
>@@ -83,6 +83,7 @@ register_client(const char *cmd __rte_unused, const
>char *params,
> 	pthread_t th;
> 	char data[BUF_SIZE];
> 	int fd;
>+	int rc;
> 	struct sockaddr_un addrs;
> #endif /* !RTE_EXEC_ENV_WINDOWS */
>
>@@ -112,8 +113,14 @@ register_client(const char *cmd __rte_unused,
>const char *params,
> 		close(fd);
> 		return -1;
> 	}
>-	pthread_create(&th, NULL, &legacy_client_handler,
>-			(void *)(uintptr_t)fd);
>+	rc = pthread_create(&th, NULL, &legacy_client_handler,
>+				(void *)(uintptr_t)fd);
>+	if (rc != 0) {
>+		fprintf(stderr, "Failed to create legacy client thread: %s\n",
>+			strerror(rc));
>+		close(fd);
>+		return -1;
>+	}
> #endif /* !RTE_EXEC_ENV_WINDOWS */
> 	return 0;
> }
>--
>2.7.4

I think there is a Fixes tag missing for commit:
Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality")

With that added in, the code changes look good to me,
Acked-by: Ciara Power <ciara.power@intel.com> 

Thanks!



  reply	other threads:[~2021-04-19  8:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10 10:44 [dpdk-dev] [PATCH 0/2] " Min Hu (Connor)
2021-04-10 10:44 ` [dpdk-dev] [PATCH 1/2] telemetry: " Min Hu (Connor)
2021-04-10 10:44 ` [dpdk-dev] [PATCH 2/2] test: " Min Hu (Connor)
2021-04-12  0:32 ` [dpdk-dev] [PATCH v2 0/2] " Min Hu (Connor)
2021-04-12  0:32   ` [dpdk-dev] [PATCH v2 1/2] telemetry: " Min Hu (Connor)
2021-04-12  7:48     ` David Marchand
2021-04-15 11:53       ` Min Hu (Connor)
2021-04-12  0:32   ` [dpdk-dev] [PATCH v2 2/2] test: " Min Hu (Connor)
2021-04-15 11:50 ` [dpdk-dev] [PATCH v3 0/2] " Min Hu (Connor)
2021-04-15 11:50   ` [dpdk-dev] [PATCH v3 1/2] telemetry: " Min Hu (Connor)
2021-04-15 14:55     ` David Marchand
2021-04-16  8:21       ` Min Hu (Connor)
2021-04-15 16:11     ` Power, Ciara
2021-04-16  8:19       ` Min Hu (Connor)
2021-04-15 11:50   ` [dpdk-dev] [PATCH v3 2/2] test: " Min Hu (Connor)
2021-04-15 17:05     ` Pattan, Reshma
2021-04-16  8:21       ` Min Hu (Connor)
2021-04-16  8:34         ` Ferruh Yigit
2021-04-16  9:16           ` Min Hu (Connor)
2021-04-16  8:18 ` [dpdk-dev] [PATCH v4 0/2] " Min Hu (Connor)
2021-04-16  8:18   ` [dpdk-dev] [PATCH v4 1/2] telemetry: " Min Hu (Connor)
2021-04-19  8:49     ` Power, Ciara [this message]
2021-04-16  8:18   ` [dpdk-dev] [PATCH v4 2/2] test: " Min Hu (Connor)
2021-04-19  9:33     ` Pattan, Reshma
2021-04-21 14:32   ` [dpdk-dev] [PATCH v4 0/2] " Thomas Monjalon

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=MN2PR11MB38217D6D7BDE83D7CE388DD0E6499@MN2PR11MB3821.namprd11.prod.outlook.com \
    --to=ciara.power@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=humin29@huawei.com \
    --cc=reshma.pattan@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git