All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Monnet <quentin.monnet@netronome.com>
To: Stanislav Fomichev <sdf@fomichev.me>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, oss-drivers@netronome.com,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Stanislav Fomichev <sdf@google.com>
Subject: Re: [PATCH bpf-next 1/8] tools: bpftool: add basic probe capability, probe syscall and kversion
Date: Fri, 14 Dec 2018 11:27:49 +0000	[thread overview]
Message-ID: <4c13b081-43cc-54f7-6fe7-e8e8c5aaf33a@netronome.com> (raw)
In-Reply-To: <20181214025056.GC31012@mini-arch.hsd1.ca.comcast.net>

2018-12-13 18:50 UTC-0800 ~ Stanislav Fomichev <sdf@fomichev.me>
> On 12/13, Quentin Monnet wrote:
>> Add a new component and command for bpftool, in order to probe the
>> system to dump a set of eBPF-related parameters so that users can know
>> what features are available on the system.
>>
>> Parameters are dumped in plain or JSON output (with -j/-p options).
>> Additionally, a specific keyword can be used to provide a third possible
>> output so that the parameters are dumped as #define-d macros, ready to
>> be saved to a header file and included in an eBPF-based project.
>>
>> The current patch introduces probing of two simple parameters:
>> availability of the bpf() system call, and kernel version. Later commits
>> will add other probes.
>>
>> Sample output:
>>
>>     # bpftool feature probe kernel
>>     Scanning system call and kernel version...
>>     Kernel release is 4.19.0
>>     bpf() syscall is available
>>
>>     # bpftool --json --pretty feature probe kernel
>>     {
>>         "syscall_config": {
>>             "kernel_version_code": 267008,
>>             "have_bpf_syscall": true
>>         }
>>     }
>>
>>     # bpftool feature probe kernel macros prefix BPFTOOL_
>>     /*** System call and kernel version ***/
>>     #define BPFTOOL_LINUX_VERSION_CODE 267008
>>     #define BPFTOOL_BPF_SYSCALL
>>
>> The optional "kernel" keyword enforces probing of the current system,
>> which is the only possible behaviour at this stage. It can be safely
>> omitted.
>>
>> The feature comes with the relevant man page, but bash completion will
>> come in a dedicated commit.
>>
>> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
>> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>> ---

> 
> [..]
> 
>> +		printf("#define %s%s%s\n", define_prefix,
>> +		       res ? "" : "NO_", define_name);
> 
> Should we keep it autoconf style and do:
> #define XYZ 1 - in case of supported feature
> /* #undef XYZ */ - in case of unsupported feature
> 
> ?

But then if you include this as a header, you have no way to distinguish
the case when the feature is not supported from when bpftool did not
attempt to run the probe at all?

>> +	else
>> +		printf("%s is %savailable\n", plain_name, res ? "" : "NOT ");
> 
> Why not do printf("%s %s\n", feat_name, res ? "yes" : "no") instead?
> And not complicate (drop) the output with human readability. One
> possible (dis)advantage - scripts can use this.

I've been pondering about the interest of keeping human-readable output.
I think it helps users understand the output, especially for the procfs
parameters for example.

As for scripts, they can and should stick to JSON. Plain output from
bpftool is not meant to be reliable for scripting.

  reply	other threads:[~2018-12-14 11:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 12:19 [PATCH bpf-next 0/8] tools: bpftool: add probes for system and device Quentin Monnet
2018-12-13 12:19 ` [PATCH bpf-next 1/8] tools: bpftool: add basic probe capability, probe syscall and kversion Quentin Monnet
2018-12-14  2:50   ` Stanislav Fomichev
2018-12-14 11:27     ` Quentin Monnet [this message]
2018-12-14 18:45       ` Stanislav Fomichev
2018-12-15  3:31         ` Quentin Monnet
2018-12-14 23:35   ` Daniel Borkmann
2018-12-15  3:31     ` Quentin Monnet
2018-12-13 12:19 ` [PATCH bpf-next 2/8] tools: bpftool: add probes for /proc/ eBPF parameters Quentin Monnet
2018-12-14  2:58   ` Stanislav Fomichev
2018-12-14 11:27     ` Quentin Monnet
2018-12-14 23:40   ` Daniel Borkmann
2018-12-15  3:31     ` Quentin Monnet
2018-12-16  0:14       ` Daniel Borkmann
2018-12-17 10:44         ` Quentin Monnet
2018-12-17 11:11           ` Daniel Borkmann
2018-12-13 12:19 ` [PATCH bpf-next 3/8] tools: bpftool: add probes for kernel configuration options Quentin Monnet
2018-12-14 23:56   ` Daniel Borkmann
2018-12-15  3:32     ` Quentin Monnet
2018-12-19 18:49       ` Quentin Monnet
2018-12-13 12:19 ` [PATCH bpf-next 4/8] tools: bpftool: add probes for eBPF program types Quentin Monnet
2018-12-13 12:19 ` [PATCH bpf-next 5/8] tools: bpftool: add probes for eBPF map types Quentin Monnet
2018-12-13 12:19 ` [PATCH bpf-next 6/8] tools: bpftool: add probes for eBPF helper functions Quentin Monnet
2018-12-15  0:08   ` Daniel Borkmann
2018-12-15  3:32     ` Quentin Monnet
2018-12-15 23:57       ` Daniel Borkmann
2018-12-17 10:18         ` Quentin Monnet
2018-12-18  0:42           ` Daniel Borkmann
2018-12-19 19:02             ` Quentin Monnet
2018-12-13 12:19 ` [PATCH bpf-next 7/8] tools: bpftool: add probes for a network device Quentin Monnet
2018-12-13 12:19 ` [PATCH bpf-next 8/8] tools: bpftool: add bash completion for bpftool probes Quentin Monnet
2018-12-13 13:03 ` [PATCH bpf-next 0/8] tools: bpftool: add probes for system and device Arnaldo Carvalho de Melo
2018-12-13 13:49   ` Debugging eBPF was: " Arnaldo Carvalho de Melo
2018-12-13 20:55     ` Alexei Starovoitov
2018-12-14 13:39       ` Arnaldo Carvalho de Melo
2018-12-14 11:53 ` Quentin Monnet
2018-12-14 18:21   ` Stanislav Fomichev
2018-12-14 18:41     ` [oss-drivers] " Quentin Monnet
2018-12-14 14:00 ` Arnaldo Carvalho de Melo
2018-12-14 14:56   ` Quentin Monnet
2018-12-14 17:26     ` Arnaldo Carvalho de Melo

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=4c13b081-43cc-54f7-6fe7-e8e8c5aaf33a@netronome.com \
    --to=quentin.monnet@netronome.com \
    --cc=acme@kernel.org \
    --cc=ast@kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=sdf@fomichev.me \
    --cc=sdf@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.