From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 496F0A0597;
	Wed,  8 Apr 2020 19:23:27 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id A9BEF1C18F;
	Wed,  8 Apr 2020 19:23:26 +0200 (CEST)
Received: from mail-il1-f193.google.com (mail-il1-f193.google.com
 [209.85.166.193]) by dpdk.org (Postfix) with ESMTP id 1BB941C0B7
 for <dev@dpdk.org>; Wed,  8 Apr 2020 19:23:25 +0200 (CEST)
Received: by mail-il1-f193.google.com with SMTP id f16so7495261ilj.9
 for <dev@dpdk.org>; Wed, 08 Apr 2020 10:23:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=yG1ad6TxFUEiknYypIfPsqRNqgEMHUSUxXJsZccZ7rU=;
 b=kyVSPQaPrKbvJK+GeRJtw4t0Iu6AZsCPUf7nTLyGawSdN28E04viYUeM1Il1nfYnPw
 0k/ulKIW+pmqe4gOAXNe/8i8r2bOqdWZj5nowtulkUPqEMnCRfAkGndBfcAyIptVL01m
 7B62b4rcabyEWm31hHEijGGDSCmdqyKmh7Zy+DlWCIXzcAVE7JM75ub/DxvpGqVT4mcT
 Ep3TPPAf+1Ymod79x9DnA2JVQdA+lHBnB5zLYFMoHEOa1b5YbDCxGTldwpCqSfbe1eXK
 KbFQ0g3Px9a7CG0EkQdCY0XQaKXNos2cEjGartCLa0YkbEaB4ZH9m3/5Rq6UIZGHnb2V
 i5yQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=yG1ad6TxFUEiknYypIfPsqRNqgEMHUSUxXJsZccZ7rU=;
 b=Dq6FAMLnxzGwXvnXCbFgAV26bKwl5zQACR/HplPxtlN+k5c1wn/CfYWTQP20xZMvoy
 3PK9SA8i04meY1YjRwfzNdPiX6czoxzc+pCMWDUqrVxNWYHFdM8Dj2BKd0L/clElDFuX
 G2vZnFdXUt5dnBwjvcATOIrfcNBTwH8cYGozcq4TLORumCBmbHqBYHeg1yg6L6Ejsx89
 In/TqJJ27fP0RX2Mk9t71wJm0P8ZUX83ail+GuIOEG+en3KO+Hvl/YZkmPtOUKKt99IW
 9xIqs4L6WxNxf6gnJIfm0yPrmmaeealCumO/qeFsj250TK52TnWjzp9QPmSIoqZuwnDc
 TQCw==
X-Gm-Message-State: AGi0PuZWTgehzY8i/DKPuLwcKs/pOtTjHEccs/+hoK/LEd8U3RGnW9vB
 3LKrOlO8Cc7XyT5CZGAUxdwxpbsUGh/+X2q0aUA=
X-Google-Smtp-Source: APiQypIIu35dgd5KFt4UJ7CkmB8/MSex4bNGMf/Z1qwF6bx8/XgtwkMwgoehoZepIK7Q91V3dKUaZkZPOSH/7CuoAqA=
X-Received: by 2002:a92:cecd:: with SMTP id z13mr3367983ilq.271.1586366604282; 
 Wed, 08 Apr 2020 10:23:24 -0700 (PDT)
MIME-Version: 1.0
References: <20200331192945.2466880-1-jerinj@marvell.com>
 <20200405085613.1336841-1-jerinj@marvell.com>
 <20200405085613.1336841-8-jerinj@marvell.com>
 <22dda6ca-abca-1514-95c9-ae5ec869add9@semihalf.com>
In-Reply-To: <22dda6ca-abca-1514-95c9-ae5ec869add9@semihalf.com>
From: Jerin Jacob <jerinjacobk@gmail.com>
Date: Wed, 8 Apr 2020 22:53:08 +0530
Message-ID: <CALBAE1MYweFO34jB91sHz1CcdUdiXdUGULQt1Gf8aupviWx07w@mail.gmail.com>
To: Andrzej Ostruszka <amo@semihalf.com>
Cc: dpdk-dev <dev@dpdk.org>
Content-Type: text/plain; charset="UTF-8"
Subject: Re: [dpdk-dev] [PATCH v4 07/29] graph: implement create and destroy
	APIs
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

> > +++ b/lib/librte_graph/graph.c
> [...]
> > +static int
> > +graph_node_add(struct graph *graph, struct node *node)
> > +{
> > +     struct graph_node *graph_node;
> > +     size_t sz;
> > +
> > +     /* Skip the duplicate nodes */
> > +     STAILQ_FOREACH(graph_node, &graph->node_list, next)
> > +             if (strncmp(node->name, graph_node->node->name,
> > +                         RTE_NODE_NAMESIZE) == 0)
>
> Is it not a "deficiency" of a program to attempt to add node twice?
> If it is, then maybe a warning here?

The library takes care of adding nodes the graph
- when user-specified
OR
- when a node depends on another node (gets the info from next nodes)
and it not specified by the user

So this internal function may be called with the same node.


>
> [...]
> > +rte_graph_t
> > +rte_graph_create(const char *name, struct rte_graph_param *prm)
> > +{
> > +     struct graph *graph;
> > +     const char *pattern;
> > +     uint16_t i;
> > +

> > +
> > +     /* Do BFS from src nodes on the graph to find isolated nodes */
> > +     if (graph_has_isolated_node(graph))
> > +             goto graph_cleanup;
> > +
> > +     /* Initialize graph object */
> > +     graph->socket = prm->socket_id;
> > +     graph->src_node_count = graph_src_nodes_count(graph);
>
> Maybe reuse value of previous call (above)?

Yep. I will change it in v5.

>
> > +     graph->node_count = graph_nodes_count(graph);
> > +     graph->id = graph_id;
> > +
> > +     /* Allocate the Graph fast path memory and populate the data */
> > +     if (graph_fp_mem_create(graph))
> > +             goto graph_cleanup;
> > +
> > +     /* Call init() of the all the nodes in the graph */
> > +     if (graph_node_init(graph))
> > +             goto graph_mem_destroy;
> > +
> > +     /* All good, Lets add the graph to the list */
> > +     graph_id++;
> > +     STAILQ_INSERT_TAIL(&graph_list, graph, next);
> > +
> > +     graph_spinlock_unlock();
> > +     return graph->id;
> > +
> > +graph_mem_destroy:
> > +     graph_fp_mem_destroy(graph);
> > +graph_cleanup:
> > +     graph_cleanup(graph);
> > +free:
> > +     free(graph);
> > +fail:
> > +     graph_spinlock_unlock();
> > +     return RTE_GRAPH_ID_INVALID;
> > +}
> > +
>
> With regards
> Andrzej Ostruszka
>