From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00C67A0529; Fri, 10 Jul 2020 11:46:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 973041DB6C; Fri, 10 Jul 2020 11:46:01 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 8691E1DB57 for ; Fri, 10 Jul 2020 11:46:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594374359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A2W6EprvqBC7CjkwlN2VGDS5gfKrOMoFiErYu4oV8Lg=; b=MgNFwt9Gjw8y4JOXeWASRK4IPjJk0OVGvO/+3XTVJjSjV7Bw32HC7siJ6jZIx2RkVFyl4+ anSiVXMY6sW8pUoEsv6tjp/0Q7GnZfls6bWZtreYqpmd4bFDYKecbLLPA5O+uxddINwo3k h5i1zB4xBcz1KlBVxQVu3S7dlN9/Nmc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-92-xDPJLIZDOf-AOjOdHtjL2A-1; Fri, 10 Jul 2020 05:45:58 -0400 X-MC-Unique: xDPJLIZDOf-AOjOdHtjL2A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 437C1800C64; Fri, 10 Jul 2020 09:45:57 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.195.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5EF460E1C; Fri, 10 Jul 2020 09:45:55 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net Date: Fri, 10 Jul 2020 11:45:50 +0200 Message-Id: <20200710094551.3716-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] eal/linux: truncate thread name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" pthread_setname_np refuses names larger than 16 bytes (\0 included). Rather than return an error, truncate the name to this limit in the rte_thread_setname helper. Caught with ixgbe which creates control thread with name "ixgbe-link-handler": Configuring Port 0 (socket 0) EAL: Cannot set name for ctrl thread ... EAL: Cannot set name for ctrl thread Port 0: link state change event ... EAL: Cannot set name for ctrl thread Port 0: link state change event Note: before this change, the thread would keep its original name, which meant in my test for the ixgbe handler either "dpdk-testpmd" or "eal-intr-thread". Signed-off-by: David Marchand --- lib/librte_eal/linux/eal_thread.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linux/eal_thread.c b/lib/librte_eal/linux/eal_thread.c index 48a2c1124b..068de25595 100644 --- a/lib/librte_eal/linux/eal_thread.c +++ b/lib/librte_eal/linux/eal_thread.c @@ -153,7 +153,10 @@ int rte_thread_setname(pthread_t id, const char *name) int ret = ENOSYS; #if defined(__GLIBC__) && defined(__GLIBC_PREREQ) #if __GLIBC_PREREQ(2, 12) - ret = pthread_setname_np(id, name); + char truncated[16]; + + strlcpy(truncated, name, sizeof(truncated)); + ret = pthread_setname_np(id, truncated); #endif #endif RTE_SET_USED(id); -- 2.23.0