On Fri, Sep 22, 2023 at 04:39:15PM +0200, Fabrice Gasnier wrote: > This adds a new counter tool to be able to test various watch events. > A flexible watch array can be populated from command line, each field > may be tuned with a dedicated command line sub-option in "--watch" string. > Several watch events can be defined, each can have specific watch options, > by using "--watch <watch 1 options> --watch <watch 2 options>". > Watch options is a comma separated list. > > It also comes with a simple default watch (to monitor overflow/underflow > events), used when no watch parameters are provided. It's equivalent to: > counter_watch_events -w comp_count,scope_count,evt_ovf_udf > > The print_usage() routine proposes another example, from the command line, > which generates a 2 elements watch array, to monitor: > - overflow underflow events > - capture events, on channel 3, that reads read captured data by > specifying the component id (capture3_component_id being 7 here). > > Signed-off-by: Fabrice Gasnier <fabrice.gasnier@xxxxxxxxxxx> Hi Fabrice, This tool is independent from the rest of the patches in this patchset, so I suggest separating and submitting the next revision of this patch independently. > --- > Changes in v2: > Review comments from William: > - revisit watch options to be less error prone: add --watch with > sub-options to properly define each watch one by one, as a comma > separated list > - by the way, drop string/array parsing routines, replaced by getsubopt() > - Improve command-line interface descriptions, e.g. like "-h, --help" > - Makefile: adopt ARRAY_SIZE from tools/include/linux.kernel.h (via CFLAG) > - remove reference to counter_example > - clarify commit message, code comment: Index/overflow/underflow event > - check calloc return value > - Makefile: sort count_watch_events in alphabetic order > - Makefile: add a clean rule to delete .*.o.cmd files It looks like you implemented all the changes I requested in the first review so I don't have much to comment inline for this revision. It looks like the memory allocated (via calloc()) for the watches array is never freed, so fix that in the next revision. Also, add a MAINTAINERS entry with at least you as the point of contact or someone else (an ST engineer?) who is willing to respond to any bug reports the mailing list could get for this utility. Regarding watch options, I looked up how a few other utilities handle similar situations. Some utilities like the nftables nft command line utility takes in a configuration file where you can specify the verbose rule-sets, while others such as bfptrace allows entire programs to be specified via one-liner constructs passed in a single option ("-e"). Although powerful, I found those approaches to be far too complex for our simple test utility here. Instead, uilities with a simpler interface take an approach similar to yours by providing several well-defined sub-options; for example, to filter tcpdump packets users can provide the particular sub-options they desire ("-i eth0 port 22"). The watch option solution here with sub-options is simple and clear, so for now let's go with it as you have it. If the need arises in the future for a more complex option interface, we'll tackle it as it comes. Thanks, William Breathitt Gray
Attachment:
signature.asc
Description: PGP signature