From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <dev@dpdk.org>, <stable@dpdk.org>,
Ciara Power <ciara.power@intel.com>,
Declan Doherty <declan.doherty@intel.com>,
Radu Nicolau <radu.nicolau@intel.com>
Subject: Re: [PATCH] telemetry: fix autotest failures on Alpine
Date: Mon, 13 Mar 2023 09:38:41 +0000 [thread overview]
Message-ID: <ZA7vIRdik8mAkNEn@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <20230310110832.1cfa47e5@hermes.local>
On Fri, Mar 10, 2023 at 11:08:32AM -0800, Stephen Hemminger wrote:
> On Fri, 10 Mar 2023 18:18:36 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
>
> > On Alpine linux, the telemetry_data_autotest was failing for the
> > test where we had dictionaries embedded in other dictionaries up
> > to three levels deep. Indications are that this issue is due to
> > excess data being stored on the stack, so replace stack-allocated
> > buffer data with dynamically allocated data in the case where we
> > are doing recursive processing of telemetry data structures into
> > json.
> >
> > Bugzilla ID: 1177
> > Fixes: c933bb5177ca ("telemetry: support array values in data object")
> > Fixes: d2671e642a8e ("telemetry: support dict of dicts")
> > Cc: stable@dpdk.org
>
> Looking at the telemetry code:
>
> - why so many temporary buffers, could this be streamed or redesigned
> so that an allocated buffer is returned.
>
This is largely what the fix patch does. The temporary buffers are used to
ensure we never end up with a partially written buffer from any truncated
snprintf, since that could cause us to emit invalid json. I think as a
scheme it works well enough for what it was designed for, but this
particular test case has more levels of recursion than was expected, so the
limit of the design are showing. The downside of using memory allocation
using malloc as here, is just more failure cases.
> - why is rte_tel_json_XXX all inline? These should just be internal
> functions and not in a .h file.
>
Sure. Since these are all just internal functions used by the library, I'm
not sure it really matters.
> FYI - if this library reused existing json writer it would have
> been much simpler.
> https://github.com/shemminger/iproute2/blob/main/lib/json_writer.c
Yep. Looked at that previously, but it's at a lower level than what we
have. IMHO, the complicated bit of producing json output is not the
formatting characters for each data-type but ensuring correct termination
of the json string even in case of errors, so each function in our
telemetry json code always includes correct terminators at all points, i.e.
we have no separate functions to be called for terminating objects, arrays
etc. - they are always included in the output of the items. This is why so
many temporary buffers are used - the input string to a function is
well-formed json, and we only actually append to that buffer by copying
from the temporary buffer once we are sure that the output will also be
similarly well-formed.
That said, if you want to replace the current json implementation with a
better one, I'm not opposed to it. [though I'd definitely rather no
external dependencies which would mean we could no longer rely on it always
being available in default builds]
/Bruce
next prev parent reply other threads:[~2023-03-13 9:39 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 18:18 Bruce Richardson
2023-03-10 19:08 ` Stephen Hemminger
2023-03-13 9:38 ` Bruce Richardson [this message]
2023-04-05 15:44 ` [PATCH v2 0/5] telemetry: remove variable length arrays Bruce Richardson
2023-04-05 15:44 ` [PATCH v2 1/5] telemetry: fix autotest failures on Alpine Bruce Richardson
2023-04-07 19:21 ` Tyler Retzlaff
2023-04-11 8:43 ` Bruce Richardson
2023-04-05 15:44 ` [PATCH v2 2/5] telemetry: remove variable length array in printf fn Bruce Richardson
2023-04-05 15:44 ` [PATCH v2 3/5] telemetry: split out body of json string format fn Bruce Richardson
2023-04-05 15:44 ` [PATCH v2 4/5] telemetry: rename local variables Bruce Richardson
2023-04-05 15:44 ` [PATCH v2 5/5] telemetry: remove VLA in json string format function Bruce Richardson
2023-04-05 16:03 ` [PATCH v3 0/5] telemetry: remove variable length arrays Bruce Richardson
2023-04-05 16:03 ` [PATCH v3 1/5] telemetry: fix autotest failures on Alpine Bruce Richardson
2023-04-07 19:22 ` Tyler Retzlaff
2023-04-05 16:03 ` [PATCH v3 2/5] telemetry: remove variable length array in printf fn Bruce Richardson
2023-04-07 19:25 ` Tyler Retzlaff
2023-04-05 16:03 ` [PATCH v3 3/5] telemetry: split out body of json string format fn Bruce Richardson
2023-04-07 19:28 ` Tyler Retzlaff
2023-04-05 16:03 ` [PATCH v3 4/5] telemetry: rename local variables Bruce Richardson
2023-04-07 19:50 ` Tyler Retzlaff
2023-04-11 8:58 ` Bruce Richardson
2023-04-05 16:03 ` [PATCH v3 5/5] telemetry: remove VLA in json string format function Bruce Richardson
2023-04-07 19:54 ` Tyler Retzlaff
2023-05-25 7:12 ` David Marchand
2023-05-24 20:47 ` [PATCH v3 0/5] telemetry: remove variable length arrays Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZA7vIRdik8mAkNEn@bricha3-MOBL.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=ciara.power@intel.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=radu.nicolau@intel.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).