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 DDDA14240D; Wed, 18 Jan 2023 15:51:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E5DD400D6; Wed, 18 Jan 2023 15:51:00 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id A13F94003F for ; Wed, 18 Jan 2023 15:50:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674053459; 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: in-reply-to:in-reply-to:references:references; bh=QXTe4EBOaZ0LmS0ZTL0hxWWL2HEOIwLxtTq29C5K99I=; b=cmmYAQHa6qFYZdfjfiy/U79f45s9RF9pBuKPfpbHuivbmK3A1LwvmXpIalnu93ogODuXHL D+KJUg9rGhyZWehC0luIGO0jwiYVGDzLS914bBN4Re2TfF97+K7p0z1a3pbbxlPiatYmaY TvkxeZQBEqr6DgMOFYLy9lbKrtM3LzA= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-544-CHYhmalGOQmLnprveO-_UQ-1; Wed, 18 Jan 2023 09:50:56 -0500 X-MC-Unique: CHYhmalGOQmLnprveO-_UQ-1 Received: by mail-pl1-f198.google.com with SMTP id p15-20020a170902a40f00b00192b2bbb7f8so23936273plq.14 for ; Wed, 18 Jan 2023 06:50:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QXTe4EBOaZ0LmS0ZTL0hxWWL2HEOIwLxtTq29C5K99I=; b=Kt93dU3LPV+emOr1OeNm4rN9hq54wWICnaNqEWFI4YxRS2w8xqnSWnI6/fxfocFfVM 8OiC2Kquf/dnmF12oi3g0Zdk+gXwmarBePmrWVa0TXT+vPe71p1h5aa9h8iKuRVW0x2+ +qTWwcBNrwrh0TQsaunwPJrruimzLfSzp/Xb7BHd37VaAG78a/1VXqdnNwwnFSpK21zl IER42Cwi2ZxgkYUaNJ0wES2dvHG6i8ONcU+MV2xhJ1w0A41xDc6VVo210oVMZwly0bg1 bDNcZPZ/yfdB7we1aa4vV8ek/OTXhMKUIjqbzlsMhOJgyPUYkOPPXli8sZa5ea7XhhwM H1MA== X-Gm-Message-State: AFqh2krqwvH+opJtOIpyIoMyD8ITyecluASlsI2YueIPjuhNCT195pJL 9yVkQh7vycRIi/SbvxxuImnpLUibt9fg3ahpF/A+aCV8jWVTfTdLUH/UXyF4Cs61Eso3p5UbkTY brfCkmCX76ZrgUidFHyU= X-Received: by 2002:a63:a514:0:b0:4cf:8d6b:94ca with SMTP id n20-20020a63a514000000b004cf8d6b94camr434786pgf.144.1674053455545; Wed, 18 Jan 2023 06:50:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWaukcHgCBQDYX4xMY6KNGVk/sTc5PLmnOI/hE8h9kRiu55nbyJJQPyOCr75JL1QWmL3WbdfRwaQNoWBsEeiY= X-Received: by 2002:a63:a514:0:b0:4cf:8d6b:94ca with SMTP id n20-20020a63a514000000b004cf8d6b94camr434782pgf.144.1674053455257; Wed, 18 Jan 2023 06:50:55 -0800 (PST) MIME-Version: 1.0 References: <1670439617-9054-1-git-send-email-roretzla@linux.microsoft.com> <1673979709-8613-1-git-send-email-roretzla@linux.microsoft.com> <1673979709-8613-2-git-send-email-roretzla@linux.microsoft.com> In-Reply-To: <1673979709-8613-2-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Wed, 18 Jan 2023 15:50:43 +0100 Message-ID: Subject: Re: [PATCH v5 1/4] eal: add thread set name API operating on rte thread To: Tyler Retzlaff Cc: dev@dpdk.org, thomas@monjalon.net, mb@smartsharesystems.com, jerinjacobk@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Jan 17, 2023 at 7:21 PM Tyler Retzlaff wrote: > > Add a rte_thread_set_name that sets the name of an rte_thread_t thread. > This is a replacement for the rte_thread_setname(pthread_t, ...) which > exposes platform-specific details. > > Signed-off-by: Tyler Retzlaff > --- > > Series-acked-by: Morten Br=C3=B8rup > > lib/eal/common/eal_common_thread.c | 9 +++----- > lib/eal/freebsd/eal.c | 4 +++- > lib/eal/freebsd/eal_thread.c | 11 +++++++++ > lib/eal/include/rte_thread.h | 17 ++++++++++++++ > lib/eal/linux/eal.c | 8 +++---- > lib/eal/linux/eal_thread.c | 22 ++++++++++++++++++ > lib/eal/version.map | 3 +++ > lib/eal/windows/rte_thread.c | 46 ++++++++++++++++++++++++++++++++= ++++++ > 8 files changed, 108 insertions(+), 12 deletions(-) > [snip] There is no update in lib/eal/windows/eal.c. Windows worker threads are not renamed like on Linux/FreeBSD. I'd rather fix this in this series now that Windows EAL offers such facilit= y. Either in this current patch, or a followup patch, as you prefer. > diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c > index 1c1e9d0..c26659d 100644 > --- a/lib/eal/windows/rte_thread.c > +++ b/lib/eal/windows/rte_thread.c > @@ -4,7 +4,9 @@ > */ > > #include > +#include > > +#include > #include > #include > #include > @@ -305,6 +307,50 @@ struct thread_routine_ctx { > return thread_id; > } > > +void > +rte_thread_set_name(rte_thread_t thread_id, const char *thread_name) > +{ > + int ret =3D 0; > + wchar_t wname[RTE_MAX_THREAD_NAME_LEN]; > + mbstate_t state =3D {0}; > + size_t rv; > + HANDLE thread_handle; > + > + thread_handle =3D OpenThread(THREAD_ALL_ACCESS, FALSE, > + thread_id.opaque_id); > + if (thread_handle =3D=3D NULL) { > + ret =3D thread_log_last_error("OpenThread()"); > + goto cleanup; > + } > + > + memset(wname, 0, sizeof(wname)); > + rv =3D mbsrtowcs(wname, &thread_name, RTE_DIM(wname) - 1, &state)= ; > + if (rv =3D=3D (size_t)-1) { > + ret =3D EILSEQ; > + goto cleanup; > + } > + > + if (wcslen(wname) < strlen(thread_name)) > + RTE_LOG(DEBUG, EAL, "Truncated thread name\n"); > + > +#ifndef RTE_TOOLCHAIN_GCC > + if (FAILED(SetThreadDescription(thread_handle, wname))) { > + ret =3D EINVAL; > + goto cleanup; > + } > +#else > + ret =3D ENOTSUP; > + goto cleanup; > +#endif > + > +cleanup: > + if (thread_handle !=3D NULL) > + CloseHandle(thread_handle); > + > + if (ret !=3D 0) > + RTE_LOG(DEBUG, EAL, "Failed to set thread name\n"); > +} > + > int > rte_thread_get_priority(rte_thread_t thread_id, > enum rte_thread_priority *priority) > -- > 1.8.3.1 > --=20 David Marchand