From: Kang Minchul <tegongkang@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
Kang Minchul <tegongkang@gmail.com>
Subject: [PATCH] samples, bpf: Add duration option D for sampleip
Date: Wed, 16 Nov 2022 15:46:31 +0900 [thread overview]
Message-ID: <20221116064631.16224-1-tegongkang@gmail.com> (raw)
Although sampleip program can handle three options,
(-F for frequency, duration, and -h for help)
currently there is no independent option for duration.
This patch adds option -D for duration like below:
$ sudo ./samples/bpf/sampleip -h
USAGE: sampleip [-F freq] [-D duration]
-F freq # sample frequency (Hertz), default 99
-D duration # sampling duration (seconds), default 5
$ sudo ./samples/bpf/sampleip -F 120
Sampling at 120 Hertz for 5 seconds. Ctrl-C also ends.
ADDR KSYM COUNT
...
$ sudo ./samples/bpf/sampleip -D 7
Sampling at 99 Hertz for 7 seconds. Ctrl-C also ends.
ADDR KSYM COUNT
...
$ sudo ./samples/bpf/sampleip -F 120 -D 7
Sampling at 120 Hertz for 7 seconds. Ctrl-C also ends.
ADDR KSYM COUNT
...
Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
samples/bpf/sampleip_user.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/samples/bpf/sampleip_user.c b/samples/bpf/sampleip_user.c
index 921c505bb567..ce6aadd496e1 100644
--- a/samples/bpf/sampleip_user.c
+++ b/samples/bpf/sampleip_user.c
@@ -28,9 +28,9 @@ static int nr_cpus;
static void usage(void)
{
- printf("USAGE: sampleip [-F freq] [duration]\n");
- printf(" -F freq # sample frequency (Hertz), default 99\n");
- printf(" duration # sampling duration (seconds), default 5\n");
+ printf("USAGE: sampleip [-F freq] [-D duration]\n");
+ printf(" -F freq # sample frequency (Hertz), default 99\n");
+ printf(" -D duration # sampling duration (seconds), default 5\n");
}
static int sampling_start(int freq, struct bpf_program *prog,
@@ -145,19 +145,20 @@ int main(int argc, char **argv)
char filename[256];
/* process arguments */
- while ((opt = getopt(argc, argv, "F:h")) != -1) {
+ while ((opt = getopt(argc, argv, "F:D:h")) != -1) {
switch (opt) {
case 'F':
freq = atoi(optarg);
break;
+ case 'D':
+ secs = atoi(optarg);
+ break;
case 'h':
default:
usage();
return 0;
}
}
- if (argc - optind == 1)
- secs = atoi(argv[optind]);
if (freq == 0 || secs == 0) {
usage();
return 1;
--
2.34.1
next reply other threads:[~2022-11-16 6:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 6:46 Kang Minchul [this message]
2022-11-17 23:26 ` [PATCH] samples, bpf: Add duration option D for sampleip Andrii Nakryiko
2022-11-19 16:05 ` Kang Minchul
2022-11-23 21:38 ` Andrii Nakryiko
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=20221116064631.16224-1-tegongkang@gmail.com \
--to=tegongkang@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=song@kernel.org \
--cc=yhs@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox