<div dir="ltr"><div>Hi Konstantin<br></div><div><br></div><div>Thanks for the explanation and examples, I see I've misunderstood "node limit for tree split" to mean "the limit of the total number of nodes in a tree", rather than the intended logic of "the limit of new nodes that can be 
created 
in a trie as a result of merging". <br></div><div><br></div><div>Sorry for the bother, the patch can be closed as non-issue then.</div><div><br></div><div>Best,</div><div><br></div><div>Arthur<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 5, 2023 at 11:47 AM Konstantin Ananyev <<a href="mailto:konstantin.v.ananyev@yandex.ru" target="_blank">konstantin.v.ananyev@yandex.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
It is not really clear to me what is the actual problem<br>
and what are you trying to fix here...<br>
<br>
<br>
> When using a large number of ACL rules, the trie is supposed to split when there are over 2048 nodes.<br>
<br>
What do you mean by 'there'?<br>
As I remember, it decided to split set of rules, when trie starts to <br>
grow too fast: if merging of last rule creates more then cur_node_max <br>
new nodes, then it splits.<br>
<br>
> However, node_count is negative, so node_count > context->cur_node_max never actually runs, so all the nodes created from the rules end up being in one trie.<br>
<br>
Hmm... sentence that node count is negative is too cryptic for me.<br>
Obviously there are plenty examples with rule-sets that causes more then<br>
one trie to be created. Simplest way to check that, just run acl autotest:<br>
echo 'acl_autotest' | <br>
./x86_64-default-linuxapp-gcc-dbg/app/test/dpdk-test --lcores=15 <br>
--no-pci --no-huge --log-level=acl,debug<br>
...<br>
You will see that there are bunch of cases with more then one trie.<br>
Another way - try with dts test-cases for acl. few of them will create<br>
multiple tries:<br>
git clone -v <a href="http://dpdk.org/git/tools/dts/" rel="noreferrer" target="_blank">http://dpdk.org/git/tools/dts/</a><br>
cd dts<br>
gzip -cd dep/test-acl-input.tar.gz | tar xfv -<br>
./x86_64-default-linuxapp-gcc-dbg/app/dpdk-test-acl --lcores=15 --no-pci \<br>
--no-huge --log-level=acl,debug -- \<br>
--rulesf=/home/kananyev/devel/dts/test-acl-input/acl2v4_10k_rule \<br>
--tracef=/home/kananyev/devel/dts/test-acl-input/acl2v4_10k_trace \<br>
--verbose=0<br>
...<br>
dump_config:<br>
rulesf:/home/kananyev/devel/dts/test-acl-input/acl2v4_10k_rule<br>
tracef:/home/kananyev/devel/dts/test-acl-input/acl2v4_10k_trace<br>
rulenum:65536<br>
tracenum:65536<br>
tracestep:256<br>
bldcat:3<br>
runcat:1<br>
maxsize:0<br>
iter:1<br>
verbose:0<br>
alg:0(default)<br>
ipv6:0<br>
ACL: Gen phase for ACL "TESTACL":<br>
runtime memory footprint on socket -1:<br>
single nodes/bytes used: 54437/435496<br>
quad nodes/vectors/bytes used: 55775/189941/1519528<br>
DFA nodes/group64/bytes used: 9516/28940/14819336<br>
match nodes/bytes used: 9760/1249280<br>
total: 18027888 bytes<br>
max limit: 18446744073709551615 bytes<br>
ACL: Build phase for ACL "TESTACL":<br>
node limit for tree split: 2048<br>
nodes created: 129488<br>
memory consumed: 184549530<br>
ACL: trie 0: number of rules: 655, indexes: 4<br>
ACL: trie 1: number of rules: 9129, indexes: 4<br>
rte_acl_build(3) finished with 0<br>
acl context <TESTACL>@0x103adfa80<br>
   socket_id=-1<br>
   alg=3<br>
   first_load_sz=4<br>
   max_rules=65536<br>
   rule_size=96<br>
   num_rules=9784<br>
   num_categories=3<br>
   num_tries=2<br>
<br>
<br>
> <br>
> Original PR with sample files and test output can be found here:<br>
> <a href="https://github.com/DPDK/dpdk/pull/50" rel="noreferrer" target="_blank">https://github.com/DPDK/dpdk/pull/50</a><br>
> <br>
> Fixes: dc276b5780c2 ("acl: new library")<br>
> Signed-off-by: Arthur Leung <<a href="mailto:arcyleung@gmail.com" target="_blank">arcyleung@gmail.com</a>><br>
> ---<br>
>   app/test-acl/test-acl.sh | 2 +-<br>
>   lib/acl/acl_bld.c        | 9 +++------<br>
>   2 files changed, 4 insertions(+), 7 deletions(-)<br>
> <br>
> diff --git a/app/test-acl/test-acl.sh b/app/test-acl/test-acl.sh<br>
> index 30814f3fe2..59bfa121cf 100644<br>
> --- a/app/test-acl/test-acl.sh<br>
> +++ b/app/test-acl/test-acl.sh<br>
> @@ -17,7 +17,7 @@<br>
>   # <proto>'/'<mask><br>
>   # trace record format:<br>
>   # <src_ip_addr><space><dst_ip_addr><space> \<br>
> -# <src_port><space<dst_port><space><proto>...<rule_id><br>
> +# <src_port><space><dst_port><space><proto>...<rule_id><br>
>   #<br>
>   # As an example:<br>
>   # /bin/bash app/test-acl/test-acl.sh build/app/dpdk-test-acl \<br>
> diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c<br>
> index 2816632803..6064a8103b 100644<br>
> --- a/lib/acl/acl_bld.c<br>
> +++ b/lib/acl/acl_bld.c<br>
> @@ -946,7 +946,7 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,<br>
>       struct rte_acl_build_rule **last, uint32_t *count)<br>
>   {<br>
>       uint32_t n, m;<br>
> -     int field_index, node_count;<br>
> +     int field_index;<br>
>       struct rte_acl_node *trie;<br>
>       struct rte_acl_build_rule *prev, *rule;<br>
>       struct rte_acl_node *end, *merge, *root, *end_prev;<br>
> @@ -1048,15 +1048,13 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,<br>
>                       }<br>
>               }<br>
>   <br>
> -             node_count = context->num_nodes;<br>
>               (*count)++;<br>
>   <br>
>               /* merge this rule into the trie */<br>
>               if (acl_merge_trie(context, trie, root, 0, NULL))<br>
>                       return NULL;<br>
>   <br>
> -             node_count = context->num_nodes - node_count;<br>
> -             if (node_count > context->cur_node_max) {<br>
> +             if (context->num_nodes > (context->cur_node_max * context->num_tries)) {<br>
>                       *last = prev;<br>
>                       return trie;<br>
>               }<br>
> @@ -1368,6 +1366,7 @@ acl_build_tries(struct acl_build_context *context,<br>
>       for (n = 0;; n = num_tries) {<br>
>   <br>
>               num_tries = n + 1;<br>
> +             context->num_tries = num_tries;<br>
>   <br>
>               last = build_one_trie(context, rule_sets, n, context->node_max);<br>
>               if (context->bld_tries[n].trie == NULL) {<br>
> @@ -1411,8 +1410,6 @@ acl_build_tries(struct acl_build_context *context,<br>
>               }<br>
>   <br>
>       }<br>
> -<br>
> -     context->num_tries = num_tries;<br>
>       return 0;<br>
>   }<br>
>   <br>
<br>
</blockquote></div>