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 1BD9AA0093; Mon, 15 Jun 2020 08:40:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1FE1754AE; Mon, 15 Jun 2020 08:40:54 +0200 (CEST) Received: from qrelay69.mxroute.com (qrelay69.mxroute.com [172.82.139.69]) by dpdk.org (Postfix) with ESMTP id 4C7114C9D for ; Mon, 15 Jun 2020 08:40:52 +0200 (CEST) Received: from filter003.mxroute.com ([168.235.111.26] 168-235-111-26.cloud.ramnode.com) (Authenticated sender: mN4UYu2MZsgR) by qrelay69.mxroute.com (ZoneMTA) with ESMTPA id 172b6b586fa0004840.001 for ; Mon, 15 Jun 2020 06:40:49 +0000 X-Zone-Loop: e6525fe94f2d92d8e6852c7841968d8ac89c456c0bb6 X-Originating-IP: [168.235.111.26] Received: from echo.mxrouting.net (echo.mxrouting.net [116.202.222.109]) by filter003.mxroute.com (Postfix) with ESMTPS id 3C1616003B; Mon, 15 Jun 2020 06:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ashroe.eu; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ye0JnPG1gx0OyNa/PL4hCwqXvmgWVQGBNhE+C0WiY5U=; b=A7DWV/BVeGBKHLwdnPNckU8ZcL yLPjsRQT0LEGtxAmgNuQ0zuyQ/a5ObdEqHlX6bU9v1C0Kl5mF9ylM98enHB4HoBh2VICK0IxKIi50 WJhpLl/V2HgpwTMnXzEVAFrWmCuL0hrxaDLMt5jtMWoxQchsoQOH2dW/kwjcYuCc3HS2Rrm1Vhxlf F6jwsoFVfCqG+lNKNqF8Rk1wbudghl9kAWjDRWl62nYKK0rXlkYVRgXzIVfZlGDN3Pyig4NPWi2px negSNuDx/b2C/fAqV7zrvKDF6ayVvkFOkfv5jQnhEzp20qx/iRq3IgB3z95jTdF1sx4uWoiMJN7no DxpHh73A==; To: David Marchand , dev@dpdk.org Cc: Bruce Richardson , Neil Horman References: <20200610144506.30505-1-david.marchand@redhat.com> <20200610144506.30505-7-david.marchand@redhat.com> From: "Kinsella, Ray" Autocrypt: addr=mdr@ashroe.eu; keydata= mQINBFv8B3wBEAC+5ImcgbIvadt3axrTnt7Sxch3FsmWTTomXfB8YiuHT8KL8L/bFRQSL1f6 ASCHu3M89EjYazlY+vJUWLr0BhK5t/YI7bQzrOuYrl9K94vlLwzD19s/zB/g5YGGR5plJr0s JtJsFGEvF9LL3e+FKMRXveQxBB8A51nAHfwG0WSyx53d61DYz7lp4/Y4RagxaJoHp9lakn8j HV2N6rrnF+qt5ukj5SbbKWSzGg5HQF2t0QQ5tzWhCAKTfcPlnP0GymTBfNMGOReWivi3Qqzr S51Xo7hoGujUgNAM41sxpxmhx8xSwcQ5WzmxgAhJ/StNV9cb3HWIoE5StCwQ4uXOLplZNGnS uxNdegvKB95NHZjRVRChg/uMTGpg9PqYbTIFoPXjuk27sxZLRJRrueg4tLbb3HM39CJwSB++ YICcqf2N+GVD48STfcIlpp12/HI+EcDSThzfWFhaHDC0hyirHxJyHXjnZ8bUexI/5zATn/ux TpMbc/vicJxeN+qfaVqPkCbkS71cHKuPluM3jE8aNCIBNQY1/j87k5ELzg3qaesLo2n1krBH bKvFfAmQuUuJT84/IqfdVtrSCTabvDuNBDpYBV0dGbTwaRfE7i+LiJJclUr8lOvHUpJ4Y6a5 0cxEPxm498G12Z3NoY/mP5soItPIPtLR0rA0fage44zSPwp6cQARAQABtBxSYXkgS2luc2Vs bGEgPG1kckBhc2hyb2UuZXU+iQJUBBMBC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4y5Phuv2IRR+x1wTey1U1RaEPgN8xq0LQ1OitX4t2mQwjdPihZQBCnZ wzOrkbzlJMNrMKJpEgulmxAHmYJKgvZHXZXtLJSejFjR0GdHJcL5rwVOMWB8cg== Message-ID: <25cc63b0-bb46-e4ea-33aa-bab1a6375f77@ashroe.eu> Date: Mon, 15 Jun 2020 07:40:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200610144506.30505-7-david.marchand@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-AuthUser: mdr@ashroe.eu Subject: Re: [dpdk-dev] [PATCH 6/7] eal: dump lcores 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" On 10/06/2020 15:45, David Marchand wrote: > Add a little helper to dump all lcores. > > Signed-off-by: David Marchand > --- > lib/librte_eal/common/eal_common_lcore.c | 32 +++++++++++++++++++++++ > lib/librte_eal/common/eal_common_thread.c | 16 ++++++++---- > lib/librte_eal/common/eal_thread.h | 13 +++++++-- > lib/librte_eal/freebsd/eal.c | 2 +- > lib/librte_eal/freebsd/eal_thread.c | 2 +- > lib/librte_eal/include/rte_lcore.h | 10 +++++++ > lib/librte_eal/linux/eal.c | 2 +- > lib/librte_eal/linux/eal_thread.c | 2 +- > lib/librte_eal/rte_eal_version.map | 1 + > 9 files changed, 69 insertions(+), 11 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/common/eal_common_lcore.c > index 35d6c1295e..6aca1b2fee 100644 > --- a/lib/librte_eal/common/eal_common_lcore.c > +++ b/lib/librte_eal/common/eal_common_lcore.c > @@ -245,3 +245,35 @@ eal_lcore_external_release(unsigned int lcore_id) > } > rte_spinlock_unlock(&external_lcore_lock); > } > + > +void > +rte_lcore_dump(FILE *f) > +{ > + char cpuset[RTE_CPU_AFFINITY_STR_LEN]; > + unsigned int lcore_id; > + const char *role; > + int ret; > + > + rte_spinlock_lock(&external_lcore_lock); > + for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { > + switch (rte_eal_lcore_role(lcore_id)) { > + case ROLE_RTE: > + role = "RTE"; > + break; > + case ROLE_SERVICE: > + role = "SERVICE"; > + break; > + case ROLE_EXTERNAL: > + role = "EXTERNAL"; > + break; > + default: > + continue; > + } > + > + ret = eal_thread_dump_affinity(&lcore_config[lcore_id].cpuset, > + cpuset, sizeof(cpuset)); > + fprintf(f, "lcore %u, role %s, cpuset %s%s\n", lcore_id, role, > + cpuset, ret == 0 ? "" : "..."); Out of interest - why fprintf instead of rte_log? > + } > + rte_spinlock_unlock(&external_lcore_lock); > +} > diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c > index d57a6ec797..a81b192ff3 100644 > --- a/lib/librte_eal/common/eal_common_thread.c > +++ b/lib/librte_eal/common/eal_common_thread.c > @@ -118,17 +118,14 @@ rte_thread_get_affinity(rte_cpuset_t *cpusetp) > } > > int > -eal_thread_dump_affinity(char *str, unsigned size) > +eal_thread_dump_affinity(rte_cpuset_t *cpuset, char *str, unsigned int size) > { > - rte_cpuset_t cpuset; > unsigned cpu; > int ret; > unsigned int out = 0; > > - rte_thread_get_affinity(&cpuset); > - > for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { > - if (!CPU_ISSET(cpu, &cpuset)) > + if (!CPU_ISSET(cpu, cpuset)) > continue; > > ret = snprintf(str + out, > @@ -151,6 +148,15 @@ eal_thread_dump_affinity(char *str, unsigned size) > return ret; > } > > +int > +eal_thread_dump_current_affinity(char *str, unsigned int size) > +{ > + rte_cpuset_t cpuset; > + > + rte_thread_get_affinity(&cpuset); > + return eal_thread_dump_affinity(&cpuset, str, size); > +} > + > void > rte_thread_init(unsigned int lcore_id, rte_cpuset_t *cpuset) > { > diff --git a/lib/librte_eal/common/eal_thread.h b/lib/librte_eal/common/eal_thread.h > index 4ecd8fd53a..13ec252e01 100644 > --- a/lib/librte_eal/common/eal_thread.h > +++ b/lib/librte_eal/common/eal_thread.h > @@ -47,13 +47,15 @@ unsigned eal_cpu_socket_id(unsigned cpu_id); > #define RTE_CPU_AFFINITY_STR_LEN 256 > > /** > - * Dump the current pthread cpuset. > + * Dump the cpuset as a human readable string. > * This function is private to EAL. > * > * Note: > * If the dump size is greater than the size of given buffer, > * the string will be truncated and with '\0' at the end. > * > + * @param cpuset > + * The CPU affinity object to dump. > * @param str > * The string buffer the cpuset will dump to. > * @param size > @@ -62,6 +64,13 @@ unsigned eal_cpu_socket_id(unsigned cpu_id); > * 0 for success, -1 if truncation happens. > */ > int > -eal_thread_dump_affinity(char *str, unsigned size); > +eal_thread_dump_affinity(rte_cpuset_t *cpuset, char *str, unsigned int size); > + > +/** > + * Dump the current thread cpuset. > + * This is a wrapper on eal_thread_dump_affinity(). > + */ > +int > +eal_thread_dump_current_affinity(char *str, unsigned int size); > > #endif /* EAL_THREAD_H */ > diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c > index b5ea11df16..69a6f7d8c4 100644 > --- a/lib/librte_eal/freebsd/eal.c > +++ b/lib/librte_eal/freebsd/eal.c > @@ -886,7 +886,7 @@ rte_eal_init(int argc, char **argv) > rte_thread_init(rte_config.master_lcore, > &lcore_config[rte_config.master_lcore].cpuset); > > - ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset)); > + ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset)); > > RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%p;cpuset=[%s%s])\n", > rte_config.master_lcore, thread_id, cpuset, > diff --git a/lib/librte_eal/freebsd/eal_thread.c b/lib/librte_eal/freebsd/eal_thread.c > index c1fb8eb2d8..b1a3619f51 100644 > --- a/lib/librte_eal/freebsd/eal_thread.c > +++ b/lib/librte_eal/freebsd/eal_thread.c > @@ -92,7 +92,7 @@ eal_thread_loop(__rte_unused void *arg) > > rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset); > > - ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset)); > + ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset)); > RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n", > lcore_id, thread_id, cpuset, ret == 0 ? "" : "..."); > > diff --git a/lib/librte_eal/include/rte_lcore.h b/lib/librte_eal/include/rte_lcore.h > index d59c4edc67..9cf34efef4 100644 > --- a/lib/librte_eal/include/rte_lcore.h > +++ b/lib/librte_eal/include/rte_lcore.h > @@ -228,6 +228,16 @@ unsigned int rte_get_next_lcore(unsigned int i, int skip_master, int wrap); > i i = rte_get_next_lcore(i, 1, 0)) > > +/** > + * List all lcores. > + * > + * @param f > + * The output stream where the dump should be sent. > + */ > +__rte_experimental > +void > +rte_lcore_dump(FILE *f); > + > /** > * Set core affinity of the current thread. > * Support both EAL and non-EAL thread and update TLS. > diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c > index 8638376b8a..2f0efd7cd3 100644 > --- a/lib/librte_eal/linux/eal.c > +++ b/lib/librte_eal/linux/eal.c > @@ -1214,7 +1214,7 @@ rte_eal_init(int argc, char **argv) > rte_thread_init(rte_config.master_lcore, > &lcore_config[rte_config.master_lcore].cpuset); > > - ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset)); > + ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset)); > RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%zx;cpuset=[%s%s])\n", > rte_config.master_lcore, (uintptr_t)thread_id, cpuset, > ret == 0 ? "" : "..."); > diff --git a/lib/librte_eal/linux/eal_thread.c b/lib/librte_eal/linux/eal_thread.c > index 07aec0c44d..22d9bc8c01 100644 > --- a/lib/librte_eal/linux/eal_thread.c > +++ b/lib/librte_eal/linux/eal_thread.c > @@ -92,7 +92,7 @@ eal_thread_loop(__rte_unused void *arg) > > rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset); > > - ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset)); > + ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset)); > RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n", > lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "..."); > > diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map > index f5b68d2815..6754d52543 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -395,6 +395,7 @@ EXPERIMENTAL { > rte_trace_save; > > # added in 20.08 > + rte_lcore_dump; > rte_thread_register; > rte_thread_unregister; > };