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 0CC69A0547; Mon, 19 Apr 2021 10:49:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC73440683; Mon, 19 Apr 2021 10:49:35 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 1EEAB40040 for ; Mon, 19 Apr 2021 10:49:33 +0200 (CEST) IronPort-SDR: mZDXzI5xafSaDBvxhwPGU9zxrwO3gzhZeurVvwAG5x6Ew75y4hC2e5+vPl+Fz87KUUQHBg5fT/ HOVCANqm/KLw== X-IronPort-AV: E=McAfee;i="6200,9189,9958"; a="194849787" X-IronPort-AV: E=Sophos;i="5.82,233,1613462400"; d="scan'208";a="194849787" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 01:49:33 -0700 IronPort-SDR: /qSevk00vQr11qwpqDRrsONb8dztXOQKewcn7c3Jj44l08jvUNaKOxx5HoFs+20TKxCF333PlJ s7PPlIeCo8Bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,233,1613462400"; d="scan'208";a="422621369" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga007.jf.intel.com with ESMTP; 19 Apr 2021 01:49:33 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 19 Apr 2021 01:49:32 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 19 Apr 2021 01:49:32 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Mon, 19 Apr 2021 01:49:32 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Mon, 19 Apr 2021 01:49:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=afYMQfOlN+pCUJ9ATVthHojAY3yVNxTqwNubeMkdeZXmB35ng3n+DDyJeeRWiO4sqU6spOLHCtrrXJa7V+pj0WnxoDgWVJ5VwIrgU2kLFHKMiMZSX6Z/V3cCzqVJpppbgfKlT0vhyWndS3n5nLd0zdHPotwmTZtMz050Y8btITAKMfW84xwtyOIRCwseP8KkfWWv2W0qBQhsvVIDuYNUB0mjN2ycww117tkTcRMf1o6I4t/uMdhl1G+vMIOhgO5B5qKDx3bnbuOkrOWzINQJiwwvflGeDOWDrcDlIl9uLfESrwxLv60kbgTZstHXw74bJDrDzi0S00AMgrHanhoCQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fQYp6c3vWJw1UMdkJy9RmowdF8eUpaM9vTyluxDhdpA=; b=Bqf70MSqDxXkvALyNsoSFuoMsYYirIoQlZZNcunetW36hlOdvvgJ7xfM9WOUOoYvOoIFiPHb0RqnS7C59NjTslj6+XE9yhigNU5h0+OTtsLH3wdcvxpVvL7BTsOXE6D37Un2XQrVNyjzL1zc8JWfI6p/GtEZ6vh1mFq/kKa9jg+oC/sEqIlp225YVc+zA9j6ODLBoswbSkNs7NXZx9HrmmmbN0c7nA7X8ldzKFjMlZ0oPqN6NaetpGxYf6WaIEy+bpvRdh7htQ9YmEzw7n2l9z/tuDUzSN3F7rJ34gSL90Of0x6feFFvaBXu7gCe+kRvBtYbcKT7zkSusxUUj9uyeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fQYp6c3vWJw1UMdkJy9RmowdF8eUpaM9vTyluxDhdpA=; b=xsoZ8RTEkI+jsRmm7Jxx9nYgHRh8YphMoP6qw5cHcaxbyQoaJkwpRbe5/3oLqeS8FX0cBvxE2lMxINUa8zoak12WHRVx04cHhJQpw+WQuDKa8Oi3oug5zq4j0OktHDoB/NNCvAhAAT9T8YRYMfGQHKCFhVMnvKBo/SM9ozD5UYk= Received: from MN2PR11MB3821.namprd11.prod.outlook.com (2603:10b6:208:f7::24) by MN2PR11MB3696.namprd11.prod.outlook.com (2603:10b6:208:f6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16; Mon, 19 Apr 2021 08:49:28 +0000 Received: from MN2PR11MB3821.namprd11.prod.outlook.com ([fe80::546c:75a5:fe9d:de32]) by MN2PR11MB3821.namprd11.prod.outlook.com ([fe80::546c:75a5:fe9d:de32%5]) with mapi id 15.20.4042.024; Mon, 19 Apr 2021 08:49:28 +0000 From: "Power, Ciara" To: "Min Hu (Connor)" , "dev@dpdk.org" , "david.marchand@redhat.com" CC: "Yigit, Ferruh" , "Pattan, Reshma" Thread-Topic: [PATCH v4 1/2] telemetry: fix missing check for thread creation Thread-Index: AQHXMpkcEHBTmHYAIUScxdSDbUCKs6q7ia7w Date: Mon, 19 Apr 2021 08:49:28 +0000 Message-ID: References: <1618051453-21264-1-git-send-email-humin29@huawei.com> <1618561106-26716-1-git-send-email-humin29@huawei.com> <1618561106-26716-2-git-send-email-humin29@huawei.com> In-Reply-To: <1618561106-26716-2-git-send-email-humin29@huawei.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [37.228.239.233] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 22b4842d-b13d-4afe-b69d-08d903100acb x-ms-traffictypediagnostic: MN2PR11MB3696: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:142; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: empQ4dwZkI/PpdV/L8CHnVMMFac3m86wmTiKuPxKRr/C8AW1r6BrBFHWTG5YxDX1DulJPD5glHCMhtJT78NHrxWCF858I0dgcC9uhJC6FbK8vgbPiWxeyELk11ZMZ5C/XJFRsTTu3Dh04OP7C7/oxewZqJdtVEOOL0WExgi1S3s23l862uR5hHI6b21TMouddXlsa7fvGQNEsV7VkeM3nbW1o/C0PlHvz2ovKravNkie97Jaf31WAnXHjkIYRDC2IsjY8PV3H7CvFCIUcuF9uYx5JOiYQAQKubYLWTPWTgYQ5vGJeC+ZS206iiyAEoY+Wgek5pIqy6AcyDxJyP1nvfcC2kyHDZ8WZdJRwiIhU4G/T47aFTP3nFY+AT+qNz9+F9PrSYbmKzmWhJJkKbM+PiVW7vW34q5Wh7O4xGbhas32E0MXNT0faFT5UWPMhpbj02Twvo4Lgvp6oHN1V2sc+52VM8j3agIa0xk3yuCUyq1SAYvOTStfm1gFk8KPIbBuBASa2OWfvx2TGhPVMwVx0ZLpjGsR/l4wk7yM5QSQA/FQSvpgAczfoTAHsp+lypDn7+J5GVV9itI1g6f234RXrZAvkcsEbuDXKCxnOUTFa4Q= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB3821.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(346002)(366004)(376002)(39860400002)(136003)(6506007)(83380400001)(33656002)(316002)(54906003)(7696005)(110136005)(71200400001)(5660300002)(8676002)(8936002)(38100700002)(2906002)(52536014)(478600001)(26005)(64756008)(186003)(122000001)(86362001)(66446008)(4326008)(66476007)(55016002)(76116006)(66556008)(9686003)(107886003)(66946007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?fXPVCY8HJRNeFd/lX17qZ6AyJeF2/ZqoGSq0z33uzxv4mKq/2MgeJaoB68Tj?= =?us-ascii?Q?6a3xY2YFB7XpP1dAv3HwNMrOMFSc6eH/AYeLxyXqfRJIL3VNCUt540m4cxnn?= =?us-ascii?Q?Yxm9aAFeU4JzEhhGhmlUTSAibroTBFRl5lAef7zv3oCk8wBAFQSUR0EwBw1T?= =?us-ascii?Q?YVXviSAzZLXl+0OqLXRJfUGafja4IBEGp34C97/XF8gQisPd5Ed5nhGJxKVf?= =?us-ascii?Q?OGkNjHfL4iyUDFED5g73al/FbudRTx+RKl13CtV1+9jWrYDBIeTyNa7G8PR0?= =?us-ascii?Q?SO74HWNi4VZHvxtbvdCe/ae0pPj5ZBOxTVv1izY7Mt5ybd1KaTzsPUVPN3z/?= =?us-ascii?Q?aByBL8q2ERTCH9r+OhxV8RV8uBu8b7sqGddcrlJOBDSDYgXPf8+Cwjsswgtu?= =?us-ascii?Q?cqMPclz0D8Ed5Pff31SrFe8bgmto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sZbenQHQ?= =?us-ascii?Q?LrxBUUw+Yxr35R4aD7rIGYp3?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR11MB3821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22b4842d-b13d-4afe-b69d-08d903100acb X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2021 08:49:28.3589 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GbxymmmOX7XfNS4XJ7kxxUuXTfohRtTsjv9tu5ruPV6NgBLL3QUtwM2A6f5r8BRcChNI3au3x5E/Hxcx6i3lGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3696 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v4 1/2] telemetry: fix missing check for thread creation 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 Connor, >-----Original Message----- >From: Min Hu (Connor) >Sent: Friday 16 April 2021 09:18 >To: dev@dpdk.org >Cc: Yigit, Ferruh ; Power, Ciara >; Pattan, Reshma ; >david.marchand@redhat.com >Subject: [PATCH v4 1/2] telemetry: fix missing check for thread creation > >From: Chengwen Feng > >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 >Signed-off-by: Min Hu (Connor) >--- > 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 =3D (struct socket *)socket; > int s_accepted =3D 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 =3D pthread_create(&th, NULL, s->fn, >+ (void *)(uintptr_t)s_accepted); >+ if (rc !=3D 0) { >+ TMTY_LOG(ERR, "Error with create client thread: >%s\n", >+ strerror(rc)); >+ close(s_accepted); >+ if (s->num_clients !=3D 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 =3D=3D 1) { > TMTY_LOG(WARNING, "No legacy callbacks, legacy socket >not created\n"); @@ -440,7 +452,16 @@ telemetry_legacy_init(void) > v1_socket.sock =3D create_socket(v1_socket.path); > if (v1_socket.sock < 0) > return -1; >- pthread_create(&t_old, NULL, socket_listener, &v1_socket); >+ rc =3D pthread_create(&t_old, NULL, socket_listener, &v1_socket); >+ if (rc !=3D 0) { >+ TMTY_LOG(ERR, "Error with create legcay socket thread: >%s\n", >+ strerror(rc)); >+ close(v1_socket.sock); >+ v1_socket.sock =3D -1; >+ unlink(v1_socket.path); >+ v1_socket.path[0] =3D '\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 =3D &v2_clients; > rte_telemetry_register_cmd("/", list_commands, @@ -469,7 +491,16 >@@ telemetry_v2_init(void) > v2_socket.sock =3D create_socket(v2_socket.path); > if (v2_socket.sock < 0) > return -1; >- pthread_create(&t_new, NULL, socket_listener, &v2_socket); >+ rc =3D pthread_create(&t_new, NULL, socket_listener, &v2_socket); >+ if (rc !=3D 0) { >+ TMTY_LOG(ERR, "Error with create socket thread: %s\n", >+ strerror(rc)); >+ close(v2_socket.sock); >+ v2_socket.sock =3D -1; >+ unlink(v2_socket.path); >+ v2_socket.path[0] =3D '\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 =3D pthread_create(&th, NULL, &legacy_client_handler, >+ (void *)(uintptr_t)fd); >+ if (rc !=3D 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 =20 Thanks!