From patchwork Wed Apr 19 01:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Songtao Zhan X-Patchwork-Id: 1770470 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q1Nk64L6yz1ybC for ; Wed, 19 Apr 2023 11:39:10 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7E26A82040; Wed, 19 Apr 2023 01:39:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7E26A82040 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KJyx7B97hBXQ; Wed, 19 Apr 2023 01:39:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id BD0C58202F; Wed, 19 Apr 2023 01:39:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org BD0C58202F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8EADFC007A; Wed, 19 Apr 2023 01:39:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6F72BC002A for ; Wed, 19 Apr 2023 01:39:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 344CF40930 for ; Wed, 19 Apr 2023 01:39:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 344CF40930 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5KBJIl3icViy for ; Wed, 19 Apr 2023 01:39:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5BC1C4091F Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.223]) by smtp4.osuosl.org (Postfix) with ESMTP id 5BC1C4091F for ; Wed, 19 Apr 2023 01:39:01 +0000 (UTC) HMM_SOURCE_IP: 172.18.0.48:39237.1978260208 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-36.111.64.84 (unknown [172.18.0.48]) by chinatelecom.cn (HERMES) with SMTP id 48A662800CC for ; Wed, 19 Apr 2023 09:38:52 +0800 (CST) X-189-SAVE-TO-SEND: zhanst1@chinatelecom.cn Received: from ([36.111.64.84]) by app0024 with ESMTP id fe152a45a3124823b4b6293d5c849da6 for dev@openvswitch.org; Wed, 19 Apr 2023 09:38:54 CST X-Transaction-ID: fe152a45a3124823b4b6293d5c849da6 X-Real-From: zhanst1@chinatelecom.cn X-Receive-IP: 36.111.64.84 X-MEDUSA-Status: 0 Date: Wed, 19 Apr 2023 09:38:52 +0800 From: "Songtao Zhan" To: dev X-Priority: 3 X-GUID: DF92FAE4-1C66-4A17-BE8D-649F8258EE3A X-Has-Attach: no X-Mailer: Foxmail 7.2.19.158[cn] Mime-Version: 1.0 Message-ID: <202304190938517979390@chinatelecom.cn> X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [ovs-dev] [PATCH v5] util: fix an issue that thread name cannot be set X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" To: dev@openvswitch.org, i.maximets@ovn.org The name of the current thread consists of a name with a maximum length of 16 bytes and a thread ID. The final name may be longer than 16 bytes. If the name is longer than 16 bytes, the thread name will fail to be set Signed-off-by: Songtao Zhan Acked-by: Eelco Chaudron --- lib/util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/util.c b/lib/util.c index 96a71550d..5f230f5eb 100644 --- a/lib/util.c +++ b/lib/util.c @@ -645,6 +645,12 @@ set_subprogram_name(const char *subprogram_name) free(subprogram_name_set(pname)); #if HAVE_GLIBC_PTHREAD_SETNAME_NP + /* The maximum thead name including '\0' supported is 16. + * add '>' at 0th position to highlight that the name was truncated. */ + if (strlen(pname) > 15) { + memmove(pname, &pname[strlen(pname) - 15], 15 + 1); + pname[0] = '>'; + } pthread_setname_np(pthread_self(), pname); #elif HAVE_NETBSD_PTHREAD_SETNAME_NP pthread_setname_np(pthread_self(), "%s", pname);