Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2765283rwb; Thu, 17 Nov 2022 16:02:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf7HNgFsaLPTdLWsru1MpMPVD2H5sDTa4lQvVADutH0Ca5OCW+c97D/kV0n6zndEs7K314YW X-Received: by 2002:a17:906:c7d1:b0:7ae:fdcd:8198 with SMTP id dc17-20020a170906c7d100b007aefdcd8198mr4117314ejb.475.1668729774749; Thu, 17 Nov 2022 16:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668729774; cv=none; d=google.com; s=arc-20160816; b=BF8i+/mA/BzV5oNvBePg0xUjDLWszPPt/9+47SPKJiK360qyHJkOtPB8/r1GIMdMMO UEuVTWJfDwbkNELVoh04mSTagX/DHk6kFzu20K8ZdM0pGYbXQFORjBqn/0UEgaomK1M6 CfRF6swTuiPEIb6/TYOZlp73q5QMn9uUIyBIo+nLrVBr3JuvM7uADzGJnmxAAIgNvOcA R7a+jTGOQ+E0KvSIRTQ8cmDvLQFf910z7jdqEUYDEncA2TPXS6kGqTBxiuGhlK5WhttM C61c9ujXSH0pG8nz3puvEl/AwXNkBRujY858/0vErZrGjEejx72eIG1yRo9oc0l4uOt+ kpAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yJfiRY/THrfxp68on+xM5wu4YptIc+9/TjEbNBRuQSI=; b=ZHcJeqfQzKVIqoyPuIydN0iNjI0SCUNhXMdxsmyxS89wyKvhwCbqUJZrbPzrvnLecr kaeR8n3bn5BZdJrJ1y2X09PhqV8GDYpOY8l7m84rw6xU3bNiLhaXm/iu/p8Wd9nK4Cp0 FhUjjPCy0+ZdRoujufS/Vqae3cMpxe4aCka9Sb4qORa1toEs5BD8vhrm0AUqSMKus+d5 2BaNpHn7PoMOgCIPz7o7gmH3erZD9KBjL8TtlIhY/PQLT8YehebBAQIpDMnE/jdKMSMM FonkEcKaUpefw4vX5r2yc0HJwYFkehpBPbm0mKqtuuo1Jg9pDkkEGGdavuHaMmD+fWXA Df7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BmgiDAN0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a05640227d400b004542e6bd242si2010109ede.621.2022.11.17.16.02.09; Thu, 17 Nov 2022 16:02:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BmgiDAN0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234794AbiKQX0o (ORCPT + 91 others); Thu, 17 Nov 2022 18:26:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234063AbiKQX0m (ORCPT ); Thu, 17 Nov 2022 18:26:42 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8C82F5; Thu, 17 Nov 2022 15:26:41 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id z18so4824420edb.9; Thu, 17 Nov 2022 15:26:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=yJfiRY/THrfxp68on+xM5wu4YptIc+9/TjEbNBRuQSI=; b=BmgiDAN02XbAyzBOe34n5+NOE6w9YZ8LMptFPoYxXM6PNZKL3DLbi+vpeoHRTQxr6k rdeMU5nVWaqNtIRxmhwCCNeUBn++qOZXyCbcOUctlMW5BWUqc6zX/c8sql959SoWNiD2 fIrmG0HCV37/1kZzyVOYlUTUZzby2UUd7xgdNCNqKlLcxLD57xLmtCMvv5gkeI3PXMvd zJKq3X8JUss1ZiAsRtnalKG4LptBFy5w2YX5RwdhwwXpcu3MBa8khNZTN5P2zFbSXnwz plx66DkH55omoPOMZHu1MTJ2UcuxfCBA9bSdobgTNXuvCM9F9VN9yZkoJl/oyAwtReR+ i7JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yJfiRY/THrfxp68on+xM5wu4YptIc+9/TjEbNBRuQSI=; b=Zp+ySitHxRWV1HnSHVw/TAyMuwzLoEZxJhy0OKm1ojSJ+1HX11IBIdQiIX62fL7+82 PvHUO6XkFuEWQHJdEhAGn78njWe4PXRCZBlvMPh7z6wFpQn4lYGC0izP7htasRugdpSg 8RLe5Oy0chYMWp7xUCHvggaatza+J4967hZhWNsdnjDEZaV1qkhLjKC/IaP7qtw3ZJi7 EQsCqMaXRfi4WLsXWCvkGx+M5kKU9iSnCMHf0N2aOwqFnt96U+zd7m77VJ7bgf14KeNZ Susm75JKlBceh7yNKn6hd8hxFlYsVrW0zeQeLK9cRDu6XEeVIhdxZ0UkLqrqbFlUIsU3 YO4w== X-Gm-Message-State: ANoB5pkUiEp4J2K9EBBcE3e3e2TT80jXwnxTi3yArkdl2Cbef6o0xbbS OuBVabmXwaXKG2ExBB4pC9D7+sktI8J+jCfbsIU= X-Received: by 2002:a05:6402:2075:b0:457:1323:1b7e with SMTP id bd21-20020a056402207500b0045713231b7emr3922238edb.311.1668727600375; Thu, 17 Nov 2022 15:26:40 -0800 (PST) MIME-Version: 1.0 References: <20221116064631.16224-1-tegongkang@gmail.com> In-Reply-To: <20221116064631.16224-1-tegongkang@gmail.com> From: Andrii Nakryiko Date: Thu, 17 Nov 2022 15:26:28 -0800 Message-ID: Subject: Re: [PATCH] samples, bpf: Add duration option D for sampleip To: Kang Minchul Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 15, 2022 at 10:46 PM Kang Minchul wrote: > > Although sampleip program can handle three options, > (-F for frequency, duration, and -h for help) > currently there is no independent option for duration. Because it's positional argument, which is very clearly documented by usage(). What's wrong with that and why do you want to change this? > > 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 > --- > 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 >