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 8C15D43FF3 for ; Fri, 10 May 2024 10:39:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 83842402F0; Fri, 10 May 2024 10:39:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id D88B3402BB; Fri, 10 May 2024 10:39:44 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44A0CTFM000765; Fri, 10 May 2024 01:39:15 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3y18tx96xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 May 2024 01:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kfxxb1FOyZsHWKy/9NkKOlE+8wHl60tE7CuxrJSSrdKhnmfFBDmdH9AsV4XD09NzHdnSFYjiPVyfFPUEizCSnK2VwZZ4njN1md9aLQWONydAcEDRBFwmuM7y8MeryMK/V6NSI1dvxNTtNVt84W19Wob9QOJo1xEB8CLEIKSYYFOT3JM20BHyjonFldltxiVseejuGCttiM1PDdrLY/5camxsPvGOmnrj52MME2uAC4r8TjQ9PS8i/idkbhtwp699EUz/vNNiuQD7ZUoxYYAPGlJmTcCht7zK65kiG1RHwrhFMdrLE9fhESvwBjFMLgq/nLiYiOVUuS6NMp/jkpOnKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A2MJjlrsK2wFdWOXvkABowBMAYRS1KL6adEom9mTBLE=; b=l22Msf057P8b2QsVFRf3VRRct3E+pFm6byPo4Q5GkOAPbswcI5WDybwrlO4ebD6gxVsAU1Nk8u2NKt4uPjwK650WDeE2rhR85HDtbN5uoldiLGfdssqdJ/ATZ6C6KZyxZSO2k4m/16xQ+Y1rj6OeK5MWurqb5i8xSkxQuzrPNSmaPOV8kPGxtm8QulBqHHDFKjgy09LnJWkojik+Q9qq0LmLk2mBg4p6uDeQ5bOpCNSMUrOmM0aJHHxhDMZmcq2KehSEmG6+dUr5IUxvkpMXTfSm9F/RN5ocYn9Z/x3PXkkJD9r9EUB1K2DN9wxQ1cyPXLV5tD0JsMMIMT9dIzIlhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A2MJjlrsK2wFdWOXvkABowBMAYRS1KL6adEom9mTBLE=; b=V3skFe7XgFEE6YNOdjBULVCDFIFgvvElRWbjEc23iumzDzmXp3lAoYiFXMyGw9xBNwwXg0nkAHIcKszsfjUJCUwyIJuF7o+h7oFL7R3mLMWsjerLzXAP4V/HxCS5PgZw3lLBX4uJ09MSeI3OEcUVOMdW+DavlCBmwm7Ap3ie360= Received: from PH0PR18MB5071.namprd18.prod.outlook.com (2603:10b6:510:16b::15) by SJ0PR18MB4089.namprd18.prod.outlook.com (2603:10b6:a03:2c9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48; Fri, 10 May 2024 08:39:11 +0000 Received: from PH0PR18MB5071.namprd18.prod.outlook.com ([fe80::b2bd:bab4:73f2:6c52]) by PH0PR18MB5071.namprd18.prod.outlook.com ([fe80::b2bd:bab4:73f2:6c52%7]) with mapi id 15.20.7544.047; Fri, 10 May 2024 08:39:10 +0000 From: Kiran Kumar Kokkilagadda To: Gongming Chen , Jerin Jacob , Nithin Kumar Dabilpuram , "yanzhirun_163@163.com" , Robin Jarry CC: "dev@dpdk.org" , Gongming Chen , "stable@dpdk.org" , Fan Yin Subject: RE: [EXTERNAL] [PATCH v2] graph: fix does not return the unique id when create graph Thread-Topic: [EXTERNAL] [PATCH v2] graph: fix does not return the unique id when create graph Thread-Index: AQHaoqciLKsxtjyuVUKhG2XunhEsV7GQJUmQ Date: Fri, 10 May 2024 08:39:10 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR18MB5071:EE_|SJ0PR18MB4089:EE_ x-ms-office365-filtering-correlation-id: d70fb99e-89d2-46a9-c44a-08dc70cca9a4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|366007|376005|1800799015|38070700009; x-microsoft-antispam-message-info: =?us-ascii?Q?SEMpzX6cvRfwzDdJoQTTSUowcELdKTVk+9WNZyYBIGRANt3L6Ivb92FJXKns?= =?us-ascii?Q?kTXv/duBdavcE1KYZ0/wmJI8SkS8EqhWXM+QfFrF1GtcDV+SQKgSQLsXl/vu?= =?us-ascii?Q?lYj3Ex2VyeOTP3UKuP39fpjynYmn+eos6XwivhWrE1lUILCIRrOgT/PRNxZz?= =?us-ascii?Q?5rz95G6LtiMcIlUNX1702YJ71alNhdBWts1+QIwgU9vBYZVANc1rjcPm/kYy?= =?us-ascii?Q?SG0iiACmwfC8o23K72gNkncpEwZqirCGWJY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Xy8n354zqOcpw436qB9XAPW81uxT5rBZL0f5pK+ZsxDtTC?= =?us-ascii?Q?UvYPx7q1Eln0w3wbYe6Rg/l+oSIm9qqBSzR2ZUDRVbLNA/hvtNxkT8d1RX00?= =?us-ascii?Q?pgLpSsS0+FB8/n+GsG6hYlKfEcp0yakdmq0/CU24Pw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR18MB5071.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(376005)(1800799015)(38070700009); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Vo8gST5NYqrzTvm35ATDLLkfvXSX1nIhDSDB9KRavC6tOn5nrXAdbJAyt5PK?= =?us-ascii?Q?2azpMuL6RQtdgdB4xx/JriQqpPU2+uL+uo68nk8z1IRijyVQon0YFiiGm8Am?= =?us-ascii?Q?ju3NX7/OHCfM+Y1edlXjbLECXIDOF7mnZsZGPXILPtwHV9SqXIE5BCeWrBrb?= =?us-ascii?Q?wrxJ099UoxZMOsJQbo+IYJfRW1rBPym/LbA9DPfjT8tajg3iDr7j98jdRK6j?= =?us-ascii?Q?BpDyWy079hFIzEuvVbYkUpFkY9ovpaRcnn6mcTAKhdt73HyT4VrNrmbPxSGs?= =?us-ascii?Q?0cON8ZbGQSHb5Tpl6cufbgEhwlxwZZIIL+8YmsFmM0+ORQa1mUdaztm+rUWs?= =?us-ascii?Q?TKqX9lJvxbclhdGZx93Eeh5d2psMg5nJ5ccRa3ArpRiDpJSyZA2JvKEuthr2?= =?us-ascii?Q?Eg9Tj5VKFJQaiSUo3hFqyXgPtOy3Zzc3zuhpb+I4AJrUx/mFXzBlWzDxCOrn?= =?us-ascii?Q?DmFt/UXsZewfEZSR9UdGdVQyg9SWg7ejPft+JoWACIbfX/iQBmzgYHVS+YZG?= =?us-ascii?Q?XL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xvmYaS+97Q?= =?us-ascii?Q?G10LM0kYP7B3O1uL9DOh6d4AF2w0BRQYWjJ5BItMLyzVbmVdVHqcMV7lOyLP?= =?us-ascii?Q?nxqiq5iU0e2V9E3dv82klDRG9yvoYoAZVFd3LrUv09vzS6kv+1fbgy1oNrGH?= =?us-ascii?Q?lORiRqtHpEaoOGxUdK86K1mMHevV5fOnHDm56SA6?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR18MB5071.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d70fb99e-89d2-46a9-c44a-08dc70cca9a4 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 May 2024 08:39:10.1430 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: hA+8aQD4nHpU/9tqDgdczZy3V2JcGV0EEzLK1HWkhv5Ub8BL5uZ/fH+GFhSkD346BVNnRppRUws2u/g7eEsE4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR18MB4089 X-Proofpoint-GUID: m7ARI-RM0C_5aVk7orfh8PNY9Y4dYo9B X-Proofpoint-ORIG-GUID: m7ARI-RM0C_5aVk7orfh8PNY9Y4dYo9B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-10_06,2024-05-10_01,2023-05-22_02 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org > -----Original Message----- > From: Gongming Chen > Sent: Friday, May 10, 2024 12:26 PM > To: Jerin Jacob ; Kiran Kumar Kokkilagadda > ; Nithin Kumar Dabilpuram > ; yanzhirun_163@163.com > Cc: dev@dpdk.org; Gongming Chen ; > stable@dpdk.org; Fan Yin > Subject: [EXTERNAL] [PATCH v2] graph: fix does not return the unique id > when create graph >=20 > Prioritize security for external emails: Confirm sender and content safet= y > before clicking links or opening attachments >=20 > ---------------------------------------------------------------------- > From: Gongming Chen >=20 > When the order of graph destroy is not the reverse order of create, that = is, > when it is destroyed at will, the newly created graph id will be the same= as > the existing graph id, which is not the expected unique graph id. This gr= aph > id incorrectly corresponds to multiple graphs. >=20 > Fixes: a91fecc19c5c ("graph: implement create and destroy") > Cc: stable@dpdk.org >=20 > Reported-by: Fan Yin > Signed-off-by: Gongming Chen > Signed-off-by: Fan Yin > --- There is a similar patch from robin in review. https://patchwork.dpdk.org/project/dpdk/patch/20240326154936.1132201-1-rjar= ry@redhat.com/ I already Acked it. It is ready for merge. > lib/graph/graph.c | 163 ++++++++++++++++++++++++++-------------------- > 1 file changed, 94 insertions(+), 69 deletions(-) >=20 > diff --git a/lib/graph/graph.c b/lib/graph/graph.c index > 26f0968a97..b8fecd9c6a 100644 > --- a/lib/graph/graph.c > +++ b/lib/graph/graph.c > @@ -19,9 +19,6 @@ >=20 > static struct graph_head graph_list =3D STAILQ_HEAD_INITIALIZER(graph_li= st); > static rte_spinlock_t graph_lock =3D RTE_SPINLOCK_INITIALIZER; -static > rte_graph_t graph_id; > - > -#define GRAPH_ID_CHECK(id) ID_CHECK(id, graph_id) >=20 > /* Private functions */ > struct graph_head * > @@ -217,6 +214,46 @@ graph_node_fini(struct graph *graph) > graph_node->node- > >name)); > } >=20 > +static struct graph * > +graph_find_by_id(rte_graph_t id) > +{ > + struct graph *graph; > + > + STAILQ_FOREACH(graph, &graph_list, next) > + if (graph->id =3D=3D id) > + return graph; > + return NULL; > +} > + > +static struct graph * > +graph_find_by_name(const char *name) > +{ > + struct graph *graph; > + > + STAILQ_FOREACH(graph, &graph_list, next) > + if (strncmp(graph->name, name, RTE_GRAPH_NAMESIZE) =3D=3D > 0) > + return graph; > + return NULL; > +} > + > +static rte_graph_t > +graph_free_id_find(void) > +{ > + static rte_graph_t graph_id; > + if (graph_id =3D=3D RTE_GRAPH_ID_INVALID) > + graph_id++; > + > + rte_graph_t end_id =3D graph_id; > + do { > + if (!graph_find_by_id(graph_id)) > + return graph_id++; > + if (++graph_id =3D=3D RTE_GRAPH_ID_INVALID) > + graph_id++; > + } while (graph_id !=3D end_id); > + > + return RTE_GRAPH_ID_INVALID; > +} > + > static struct rte_graph * > graph_mem_fixup_node_ctx(struct rte_graph *graph) { @@ -279,13 +316,12 > @@ rte_graph_model_mcore_dispatch_core_bind(rte_graph_t id, int lcore) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > if (!rte_lcore_is_enabled(lcore)) > SET_ERR_JMP(ENOLINK, fail, "lcore %d not enabled", lcore); >=20 > - STAILQ_FOREACH(graph, &graph_list, next) > - if (graph->id =3D=3D id) > - break; > + graph =3D graph_find_by_id(id); > + if (!graph) > + goto fail; >=20 > if (graph->graph->model !=3D RTE_GRAPH_MODEL_MCORE_DISPATCH) > goto fail; > @@ -309,15 +345,12 @@ > rte_graph_model_mcore_dispatch_core_unbind(rte_graph_t id) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > - STAILQ_FOREACH(graph, &graph_list, next) > - if (graph->id =3D=3D id) > - break; > + graph =3D graph_find_by_id(id); > + if (!graph) > + return; >=20 > graph->lcore_id =3D RTE_MAX_LCORE; > graph->graph->dispatch.lcore_id =3D RTE_MAX_LCORE; > - > -fail: > return; > } >=20 > @@ -352,10 +385,8 @@ rte_graph_create(const char *name, struct > rte_graph_param *prm) > SET_ERR_JMP(EINVAL, fail, "Graph name should not be > NULL"); >=20 > /* Check for existence of duplicate graph */ > - STAILQ_FOREACH(graph, &graph_list, next) > - if (strncmp(name, graph->name, RTE_GRAPH_NAMESIZE) =3D=3D > 0) > - SET_ERR_JMP(EEXIST, fail, "Found duplicate graph > %s", > - name); > + if (graph_find_by_name(name)) > + SET_ERR_JMP(EEXIST, fail, "Found duplicate graph %s", > name); >=20 > /* Create graph object */ > graph =3D calloc(1, sizeof(*graph)); > @@ -403,10 +434,12 @@ rte_graph_create(const char *name, struct > rte_graph_param *prm) > graph_pcap_enable(prm->pcap_enable); >=20 > /* Initialize graph object */ > + graph->id =3D graph_free_id_find(); > + if (graph->id =3D=3D RTE_GRAPH_ID_INVALID) > + goto graph_cleanup; > graph->socket =3D prm->socket_id; > graph->src_node_count =3D src_node_count; > graph->node_count =3D graph_nodes_count(graph); > - graph->id =3D graph_id; > graph->parent_id =3D RTE_GRAPH_ID_INVALID; > graph->lcore_id =3D RTE_MAX_LCORE; > graph->num_pkt_to_capture =3D prm->num_pkt_to_capture; @@ - > 422,7 +455,6 @@ rte_graph_create(const char *name, struct > rte_graph_param *prm) > goto graph_mem_destroy; >=20 > /* All good, Lets add the graph to the list */ > - graph_id++; > STAILQ_INSERT_TAIL(&graph_list, graph, next); >=20 > graph_spinlock_unlock(); > @@ -467,7 +499,6 @@ rte_graph_destroy(rte_graph_t id) > graph_cleanup(graph); > STAILQ_REMOVE(&graph_list, graph, graph, next); > free(graph); > - graph_id--; > goto done; > } > graph =3D tmp; > @@ -515,12 +546,14 @@ graph_clone(struct graph *parent_graph, const > char *name, struct rte_graph_param > goto graph_cleanup; >=20 > /* Initialize the graph object */ > + graph->id =3D graph_free_id_find(); > + if (graph->id =3D=3D RTE_GRAPH_ID_INVALID) > + goto graph_cleanup; > graph->src_node_count =3D parent_graph->src_node_count; > graph->node_count =3D parent_graph->node_count; > graph->parent_id =3D parent_graph->id; > graph->lcore_id =3D parent_graph->lcore_id; > graph->socket =3D parent_graph->socket; > - graph->id =3D graph_id; >=20 > /* Allocate the Graph fast path memory and populate the data */ > if (graph_fp_mem_create(graph)) > @@ -539,7 +572,6 @@ graph_clone(struct graph *parent_graph, const char > *name, struct rte_graph_param > goto graph_mem_destroy; >=20 > /* All good, Lets add the graph to the list */ > - graph_id++; > STAILQ_INSERT_TAIL(&graph_list, graph, next); >=20 > graph_spinlock_unlock(); > @@ -561,12 +593,10 @@ rte_graph_clone(rte_graph_t id, const char *name, > struct rte_graph_param *prm) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > - STAILQ_FOREACH(graph, &graph_list, next) > - if (graph->id =3D=3D id) > - return graph_clone(graph, name, prm); > + graph =3D graph_find_by_id(id); > + if (graph) > + return graph_clone(graph, name, prm); >=20 > -fail: > return RTE_GRAPH_ID_INVALID; > } >=20 > @@ -575,9 +605,9 @@ rte_graph_from_name(const char *name) { > struct graph *graph; >=20 > - STAILQ_FOREACH(graph, &graph_list, next) > - if (strncmp(graph->name, name, RTE_GRAPH_NAMESIZE) =3D=3D > 0) > - return graph->id; > + graph =3D graph_find_by_name(name); > + if (graph) > + return graph->id; >=20 > return RTE_GRAPH_ID_INVALID; > } > @@ -587,12 +617,10 @@ rte_graph_id_to_name(rte_graph_t id) { > struct graph *graph; >=20 > - GRAPH_ID_CHECK(id); > - STAILQ_FOREACH(graph, &graph_list, next) > - if (graph->id =3D=3D id) > - return graph->name; > + graph =3D graph_find_by_id(id); > + if (graph) > + return graph->name; >=20 > -fail: > return NULL; > } >=20 > @@ -604,17 +632,13 @@ rte_graph_node_get(rte_graph_t gid, uint32_t nid) > rte_graph_off_t off; > rte_node_t count; >=20 > - GRAPH_ID_CHECK(gid); > - STAILQ_FOREACH(graph, &graph_list, next) > - if (graph->id =3D=3D gid) { > - rte_graph_foreach_node(count, off, graph->graph, > - node) { > - if (node->id =3D=3D nid) > - return node; > - } > - break; > + graph =3D graph_find_by_id(gid); > + if (graph) > + rte_graph_foreach_node(count, off, graph->graph, node) { > + if (node->id =3D=3D nid) > + return node; > } > -fail: > + > return NULL; > } >=20 > @@ -626,15 +650,11 @@ rte_graph_node_get_by_name(const char > *graph_name, const char *node_name) > rte_graph_off_t off; > rte_node_t count; >=20 > - STAILQ_FOREACH(graph, &graph_list, next) > - if (!strncmp(graph->name, graph_name, > RTE_GRAPH_NAMESIZE)) { > - rte_graph_foreach_node(count, off, graph->graph, > - node) { > - if (!strncmp(node->name, node_name, > - RTE_NODE_NAMESIZE)) > - return node; > - } > - break; > + graph =3D graph_find_by_name(graph_name); > + if (graph) > + rte_graph_foreach_node(count, off, graph->graph, node) { > + if (!strncmp(node->name, node_name, > RTE_NODE_NAMESIZE)) > + return node; > } >=20 > return NULL; > @@ -713,13 +733,10 @@ rte_graph_export(const char *name, FILE *f) > struct graph *graph; > int rc =3D ENOENT; >=20 > - STAILQ_FOREACH(graph, &graph_list, next) { > - if (strncmp(graph->name, name, RTE_GRAPH_NAMESIZE) =3D=3D > 0) { > - rc =3D graph_to_dot(f, graph); > - goto end; > - } > - } > -end: > + graph =3D graph_find_by_name(name); > + if (graph) > + rc =3D graph_to_dot(f, graph); > + > return -rc; > } >=20 > @@ -729,17 +746,16 @@ graph_scan_dump(FILE *f, rte_graph_t id, bool all) > struct graph *graph; >=20 > RTE_VERIFY(f); > - GRAPH_ID_CHECK(id); >=20 > - STAILQ_FOREACH(graph, &graph_list, next) { > - if (all =3D=3D true) { > + if (all =3D=3D true) { > + STAILQ_FOREACH(graph, &graph_list, next) > graph_dump(f, graph); > - } else if (graph->id =3D=3D id) { > + } else { > + graph =3D graph_find_by_id(id); > + if (graph) > graph_dump(f, graph); > - return; > - } > } > -fail: > + > return; > } >=20 > @@ -758,7 +774,16 @@ rte_graph_list_dump(FILE *f) rte_graph_t > rte_graph_max_count(void) > { > - return graph_id; > + struct graph *graph; > + rte_graph_t count =3D 0; > + > + graph_spinlock_lock(); > + > + STAILQ_FOREACH(graph, &graph_list, next) > + count++; > + > + graph_spinlock_unlock(); > + return count; > } >=20 > RTE_LOG_REGISTER_DEFAULT(rte_graph_logtype, INFO); > -- > 2.32.1 (Apple Git-133)