From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mail.toke.dk (Postfix) with ESMTPS id A75C3982E39 for ; Tue, 28 Jun 2022 21:49:47 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lPl8ie1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656445787; x=1687981787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dB3Xt0F7hnoEevA2MD5Np5ujq3lddankoDvz3+hjrx0=; b=lPl8ie1F5PhdyBIzIYkUlLMij9iwXb+wwVPOXnxrc/pe4jjdUdBezQk9 D88JugOAyL7lv/fem1CIA/FGlfQEpuIxbzK1YY7+wu0WsT0sRg2aH0qQc kXVd+kYNYH75wgBidKwA4J4o2BNlFEEXyspXyrBLz8NUPlpL38mKW+BOE OMe1xtPewBtMqgKGezx5Lq2UBL3sWAFNQzvkXjMh/JMV0kkiWnVNi8lBU R6Ggc1xGwtTK+34r3UyIbI/aq033IRjsuIwopcaDhIzIXEst0Y6RbxueG IAFzki5bO6mGkqr+TibaeE1laNZ8PO0Hmy+hlaE/mybx8E8mIwUtFfe6w Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="307319660" X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="307319660" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 12:49:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="717555210" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga004.jf.intel.com with ESMTP; 28 Jun 2022 12:49:41 -0700 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 25SJmr9Y022013; Tue, 28 Jun 2022 20:49:39 +0100 From: Alexander Lobakin To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Date: Tue, 28 Jun 2022 21:47:54 +0200 Message-Id: <20220628194812.1453059-35-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628194812.1453059-1-alexandr.lobakin@intel.com> References: <20220628194812.1453059-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 26L4HIGZ5PHOYVVY7LAQANCVYVPEQVZY X-Message-ID-Hash: 26L4HIGZ5PHOYVVY7LAQANCVYVPEQVZY X-MailFrom: alexandr.lobakin@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Alexander Lobakin , Larysa Zaremba , Michal Swiatkowski , Jesper Dangaard Brouer , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Toke Hoiland-Jorgensen , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesse Brandeburg , John Fastabend , Yajun Deng , Willem de Bruijn , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] [PATCH RFC bpf-next 34/52] samples/bpf: add 'timeout' option to xdp_redirect_cpu List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add ability to specify a deferred flush timeout (in usec, not nsec!) when setting up a cpumap in xdp_redirect_cpu sample. Signed-off-by: Alexander Lobakin --- samples/bpf/xdp_redirect_cpu_user.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c index ca457c34eb0f..d184c3fcab53 100644 --- a/samples/bpf/xdp_redirect_cpu_user.c +++ b/samples/bpf/xdp_redirect_cpu_user.c @@ -34,6 +34,8 @@ static const char *__doc__ = #include "xdp_sample_user.h" #include "xdp_redirect_cpu.skel.h" +#define NSEC_PER_USEC 1000UL + static int map_fd; static int avail_fd; static int count_fd; @@ -61,6 +63,7 @@ static const struct option long_options[] = { { "redirect-device", required_argument, NULL, 'r' }, { "redirect-map", required_argument, NULL, 'm' }, { "meta-thresh", optional_argument, NULL, 'M' }, + { "timeout", required_argument, NULL, 't'}, {} }; @@ -128,9 +131,10 @@ static int create_cpu_entry(__u32 cpu, struct bpf_cpumap_val *value, } } - printf("%s CPU: %u as idx: %u qsize: %d cpumap_prog_fd: %d (cpus_count: %u)\n", + printf("%s CPU: %u as idx: %u qsize: %d timeout: %llu cpumap_prog_fd: %d (cpus_count: %u)\n", new ? "Add new" : "Replace", cpu, avail_idx, - value->qsize, value->bpf_prog.fd, curr_cpus_count); + value->qsize, value->timeout, value->bpf_prog.fd, + curr_cpus_count); return 0; } @@ -346,6 +350,7 @@ int main(int argc, char **argv) * tuned-adm profile network-latency */ qsize = 2048; + value.timeout = 0; /* Defaults to 0 to mimic the previous behaviour. */ skel = xdp_redirect_cpu__open(); if (!skel) { @@ -383,7 +388,7 @@ int main(int argc, char **argv) } prog = skel->progs.xdp_prognum5_lb_hash_ip_pairs; - while ((opt = getopt_long(argc, argv, "d:si:Sxp:f:e:r:m:c:q:FMvh", + while ((opt = getopt_long(argc, argv, "d:si:Sxp:f:e:r:m:c:q:FMt:vh", long_options, &longindex)) != -1) { switch (opt) { case 'd': @@ -466,6 +471,10 @@ int main(int argc, char **argv) opts.meta_thresh = optarg ? strtoul(optarg, NULL, 0) : 1; break; + case 't': + value.timeout = strtoull(optarg, NULL, 0) * + NSEC_PER_USEC; + break; case 'h': error = false; default: -- 2.36.1