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 AF74E4248B; Thu, 26 Jan 2023 12:19:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B3B040A79; Thu, 26 Jan 2023 12:19:51 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 6310440697 for ; Thu, 26 Jan 2023 12:19:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674731988; 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=D6OHVG41rnb9g2SQrmEzWphubuoqa+CSUBVqj6KwYtk=; b=iC4GTSMDVugSv4nNStBiTfZIlfHquDyQocHzrnJNwPgC5n42oIef79Tt+uaO9oS8E/XDzw wdAly4OHz3/8oKhr8gr14g+19XhQSt+HdFcJdVnzr6kzp5a3s5CDgRCtxsMD31fAxT2L00 HnbmOJz4+hhQ/y4pZGOnLJ6oXEkovt8= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-589-Tk_uYYAvPQCck0evydyWtw-1; Thu, 26 Jan 2023 06:19:47 -0500 X-MC-Unique: Tk_uYYAvPQCck0evydyWtw-1 Received: by mail-ej1-f71.google.com with SMTP id hr22-20020a1709073f9600b0086ffb73ac1cso1059659ejc.23 for ; Thu, 26 Jan 2023 03:19:47 -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=D6OHVG41rnb9g2SQrmEzWphubuoqa+CSUBVqj6KwYtk=; b=55ui4jzUoKt3r5aRpsCWrASkwPwqVPAxgR544xP993+VfhcamdD3F06IH5CcuvtXlP /AzXzYtKU/rZcm9MHOPZM/6Fsk2xQ695qddcMTu1LGo9TtbwVHFWin7/2BCaFFah2L/s xW79vI3/e0d5G84i/AdQ9sPtupe22WZInK+8/wMi8b+/4DZsN4Lyez2hbeQgsD2EJQdr Z4oTEn0y9GQwwofjAPonSfjuUxZc3W9a86R1SrOcNotk+GC8Zk0z1DCNuHg08rv2CWil rdyblVG0BrVPvPag+a+nxmVY7/fMwiB7SzEAJh1CNxLSjdozho+XdBJD3R+oOMuh6OeV CdMQ== X-Gm-Message-State: AFqh2krqWRyTEDFZLRjpsL/a6DfpXiU9S6cK72TTLWT1/23jvqnogE9l 8CkZMOyuU15s4Y3XDw6jXfRuSdSOMfXncqabm4akDBCk9y1iLSif9hxdc4tbi26co8IvaGJ0eBs hmFB/AbhlUzz8ro4ui8U= X-Received: by 2002:a17:907:7894:b0:839:74cf:7c4c with SMTP id ku20-20020a170907789400b0083974cf7c4cmr5121734ejc.265.1674731986621; Thu, 26 Jan 2023 03:19:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXsQ9KWOkNx80kArpUFj9P40D0LVuU056dmcESm1gdjumGM95FlwoB43G2GM0BmgGqeYvqTpnq0SmJg51vOHciw= X-Received: by 2002:a17:907:7894:b0:839:74cf:7c4c with SMTP id ku20-20020a170907789400b0083974cf7c4cmr5121728ejc.265.1674731986381; Thu, 26 Jan 2023 03:19:46 -0800 (PST) MIME-Version: 1.0 References: <20221123102612.1688865-1-rjarry@redhat.com> <20230119150656.418404-1-rjarry@redhat.com> <20230119150656.418404-2-rjarry@redhat.com> In-Reply-To: <20230119150656.418404-2-rjarry@redhat.com> From: David Marchand Date: Thu, 26 Jan 2023 12:19:33 +0100 Message-ID: Subject: Re: [PATCH v6 1/5] eal: add lcore info in telemetry To: Robin Jarry Cc: dev@dpdk.org, Tyler Retzlaff , Kevin Laatz , =?UTF-8?Q?Morten_Br=C3=B8rup?= 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 Thu, Jan 19, 2023 at 4:08 PM Robin Jarry wrote: > > Report the same information than rte_lcore_dump() in the telemetry > API into /eal/lcore/list and /eal/lcore/info,ID. > > Example: > > --> /eal/lcore/info,3 > { > "/eal/lcore/info": { > "lcore_id": 3, > "socket": 0, > "role": "RTE", > "cpuset": [ > 3 > ] > } > } > > Signed-off-by: Robin Jarry > Acked-by: Morten Br=C3=B8rup > --- > > Notes: > v5 -> v6: No change > > lib/eal/common/eal_common_lcore.c | 96 +++++++++++++++++++++++++++++++ > 1 file changed, 96 insertions(+) > > diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_commo= n_lcore.c > index 06c594b0224f..16548977dce8 100644 > --- a/lib/eal/common/eal_common_lcore.c > +++ b/lib/eal/common/eal_common_lcore.c > @@ -10,6 +10,9 @@ > #include > #include > #include > +#ifndef RTE_EXEC_ENV_WINDOWS > +#include > +#endif > > #include "eal_private.h" > #include "eal_thread.h" > @@ -456,3 +459,96 @@ rte_lcore_dump(FILE *f) > { > rte_lcore_iterate(lcore_dump_cb, f); > } > + > +#ifndef RTE_EXEC_ENV_WINDOWS > +static int > +lcore_telemetry_id_cb(unsigned int lcore_id, void *arg) > +{ > + struct rte_tel_data *d =3D arg; > + return rte_tel_data_add_array_int(d, lcore_id); > +} > + > +static int > +handle_lcore_list(const char *cmd __rte_unused, > + const char *params __rte_unused, > + struct rte_tel_data *d) Indent should be single tab. > +{ > + int ret =3D rte_tel_data_start_array(d, RTE_TEL_INT_VAL); > + if (ret) > + return ret; > + return rte_lcore_iterate(lcore_telemetry_id_cb, d); > +} > + > +struct lcore_telemetry_info { > + unsigned int lcore_id; > + struct rte_tel_data *d; > +}; > + > +static int > +lcore_telemetry_info_cb(unsigned int lcore_id, void *arg) > +{ > + struct lcore_telemetry_info *info =3D arg; > + struct rte_config *cfg =3D rte_eal_get_configuration(); > + struct rte_tel_data *cpuset; > + const char *role; > + unsigned int cpu; When possible, reverse xmas tree please. > + > + if (info->lcore_id !=3D lcore_id) > + return 0; > + > + switch (cfg->lcore_role[lcore_id]) { > + case ROLE_RTE: > + role =3D "RTE"; > + break; > + case ROLE_SERVICE: > + role =3D "SERVICE"; > + break; > + case ROLE_NON_EAL: > + role =3D "NON_EAL"; > + break; > + default: > + role =3D "UNKNOWN"; > + break; > + } Please put this translation block in a helper to avoid duplicating with lcore_dump_cb. > + rte_tel_data_start_dict(info->d); > + rte_tel_data_add_dict_int(info->d, "lcore_id", lcore_id); > + rte_tel_data_add_dict_int(info->d, "socket", rte_lcore_to_socket_= id(lcore_id)); > + rte_tel_data_add_dict_string(info->d, "role", role); > + cpuset =3D rte_tel_data_alloc(); > + if (!cpuset) > + return -ENOMEM; > + rte_tel_data_start_array(cpuset, RTE_TEL_INT_VAL); > + for (cpu =3D 0; cpu < CPU_SETSIZE; cpu++) > + if (CPU_ISSET(cpu, &lcore_config[lcore_id].cpuset)) > + rte_tel_data_add_array_int(cpuset, cpu); > + rte_tel_data_add_dict_container(info->d, "cpuset", cpuset, 0); > + > + return 0; > +} > + > +static int > +handle_lcore_info(const char *cmd __rte_unused, const char *params, stru= ct rte_tel_data *d) > +{ > + struct lcore_telemetry_info info =3D { .d =3D d }; > + char *endptr =3D NULL; Missing a newline. > + if (params =3D=3D NULL || strlen(params) =3D=3D 0) > + return -EINVAL; > + errno =3D 0; > + info.lcore_id =3D strtoul(params, &endptr, 10); > + if (errno) > + return -errno; > + if (endptr =3D=3D params) > + return -EINVAL; > + return rte_lcore_iterate(lcore_telemetry_info_cb, &info); > +} > + > +RTE_INIT(lcore_telemetry) > +{ > + rte_telemetry_register_cmd( > + "/eal/lcore/list", handle_lcore_list, > + "List of lcore ids. Takes no parameters"); Please fix indent. > + rte_telemetry_register_cmd( > + "/eal/lcore/info", handle_lcore_info, > + "Returns lcore info. Parameters: int lcore_id"); > +} > +#endif /* !RTE_EXEC_ENV_WINDOWS */ > -- > 2.39.0 > --=20 David Marchand