From patchwork Sun Dec 18 00:43:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel T. Lee" X-Patchwork-Id: 13075958 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFF5AC4167B for ; Sun, 18 Dec 2022 00:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230051AbiLRAnT (ORCPT ); Sat, 17 Dec 2022 19:43:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbiLRAnQ (ORCPT ); Sat, 17 Dec 2022 19:43:16 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2C2BC99; Sat, 17 Dec 2022 16:43:15 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id q17-20020a17090aa01100b002194cba32e9so9679874pjp.1; Sat, 17 Dec 2022 16:43:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OwH5tFkWHdn/+lF5Hxhm4OSnjJliIWhDkkxbcoccv1A=; b=AMkq2CfWXDm6PmbXHdaYfCgWsCLizpHlyeMDNVowfxkuEo9GgbjabtQ7Oxz2pUDTMH cRY3N6mF3Mxs/gnI31LMgra2GzY+Eaqwry5sIfE48Rosw0o3jm3gmZXnAq2am9LPq0+7 NPsP+PAf9uVGa8X6ZdhZgYDWgWtXTOi868ud5g5CkdYeHFzojjyv2K2MGDOMzGgXgS03 lyxdnq7gc3CFwabL1R5e2GWRgTd5ZJQvPujXeZboMEiQ7bDmD+YZ2/ug/jgjVYofHXP1 5AcCRztQWFnGZtsiFR7h8FulWp18a7O2rDNUst90laIcs+EEZcdvBBJCXE/Op4j7+2gC zQUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OwH5tFkWHdn/+lF5Hxhm4OSnjJliIWhDkkxbcoccv1A=; b=eI0M5VXnjxqTspdQN/gykFQ2qjLDHzIiXPC1v/cHujcRp55Y9CU4L7YJI38FpF2XHa qUS4NzxNtYVcAApLTlu7GvpH7/ZqzpLgapPkfEgkjhv5U4r3QMliyLW9a7J8HA/HJDYn Wua/35dMTzYPy5hOTsnT6TVgsxbZqx6UP701k32nZHrw0qkPGvPpPfeuUjIZ0aP7IxmV USvZ9ScDobSIlgxa3hsHNWGqRKIm+uj5GYM4+WyQI8WlFXnfzky9ObEo2RU+PmXg2iet 9EPN+paIhkgQvz/pagtnzyqzt085I/JlcULHP4gbhyd2X38i/ifM3vQxOdi5ULRw4R19 00mQ== X-Gm-Message-State: ANoB5plSfG6CrRYcawoO8IJBEvoP1gnUpxQqKyNe0SCGLezrvJ0JCd5O 5Xxr9HRdl6nixRUuWsAFdA== X-Google-Smtp-Source: AA0mqf6g9DhvCdAqiakC4Y5DkW1WlAp5FfgR/PGx7yeOMtfP+BbZ6AWR4G0fsZ31/N6gWax53cQZfQ== X-Received: by 2002:a05:6a20:a591:b0:af:6d40:9883 with SMTP id bc17-20020a056a20a59100b000af6d409883mr19906943pzb.18.1671324195214; Sat, 17 Dec 2022 16:43:15 -0800 (PST) Received: from WDIR.. ([182.209.58.25]) by smtp.gmail.com with ESMTPSA id k10-20020a63ff0a000000b0047048c201e3sm3639458pgi.33.2022.12.17.16.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 16:43:14 -0800 (PST) From: "Daniel T. Lee" To: Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Yonghong Song Cc: bpf@vger.kernel.org, netdev@vger.kernel.org Subject: [bpf-next v3 1/3] samples/bpf: remove unused function with test_lru_dist Date: Sun, 18 Dec 2022 09:43:05 +0900 Message-Id: <20221218004307.4872-2-danieltimlee@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218004307.4872-1-danieltimlee@gmail.com> References: <20221218004307.4872-1-danieltimlee@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Currently, compiling samples/bpf with LLVM warns about the unused function with test_lru_dist. ./samples/bpf/test_lru_dist.c:45:19: warning: unused function 'list_empty' [-Wunused-function] static inline int list_empty(const struct list_head *head) ^ 1 warning generated. This commit resolve this compiler warning by removing the abandoned function. Signed-off-by: Daniel T. Lee Acked-by: Yonghong Song --- samples/bpf/test_lru_dist.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/samples/bpf/test_lru_dist.c b/samples/bpf/test_lru_dist.c index 5efb91763d65..1c161276d57b 100644 --- a/samples/bpf/test_lru_dist.c +++ b/samples/bpf/test_lru_dist.c @@ -42,11 +42,6 @@ static inline void INIT_LIST_HEAD(struct list_head *list) list->prev = list; } -static inline int list_empty(const struct list_head *head) -{ - return head->next == head; -} - static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) From patchwork Sun Dec 18 00:43:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel T. Lee" X-Patchwork-Id: 13075959 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96EDEC3DA6E for ; Sun, 18 Dec 2022 00:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbiLRAnU (ORCPT ); Sat, 17 Dec 2022 19:43:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbiLRAnS (ORCPT ); Sat, 17 Dec 2022 19:43:18 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ABADBE0F; Sat, 17 Dec 2022 16:43:18 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id d7so5777189pll.9; Sat, 17 Dec 2022 16:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oGJubt8HF7jBnIg3wM08JRpJ2gzwaKNjVWAVkyCf2Ao=; b=ZvIAwzTcU+CbYY5kUHU5e709XFUhpyoCNTswg6h0hSAHV3Pir3/Z/rxV+2Yq5/KfiC g+ohZ8h47zANPaA6e9QkNN0q6tT3M2D51diM+9TaZ1sAay42li2/gJAgV4MOcNxEmtgb qJ69WBoKaJm19RgsQfHULgfwwxKiTNd/yv7FeDsW1gPt0j0OxEnvVJM2JsIbX3hMOC9q k381oE7c+Vs8w1EbldQ/RT/FHJos6xt4JOekXNbrCAhj/5TZEOwBY7tkr+SPQFbK4aKI nxzRacvj/w5/rN1IN+VALOCendRgzof9Gj4Rqm/zd3oqmMIp1oz7KW2Y2i5E95owecHn LxYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oGJubt8HF7jBnIg3wM08JRpJ2gzwaKNjVWAVkyCf2Ao=; b=LoXlcWSyfzUzsqWMO7j0HRsFfdem3GQ1jBDe9cNNL1ZN2Jyj0i9BimASikW7YXarXy clUYHJAdqIfBrFm4UO+F/lH+CfzkaiWAUXqnsgNjc9HTkPKAsgvgL2zsVY4MJe/aHSe8 gCi62PcoYd9P7JrIRRqMonXNPYKosOkX25sK/W5BQC0zJhMmx8s8Ug3IisuHdmjh8aNH LEtezsVDODzLR4M0q8ONGp7kL83vYn0yjuN1eO8EB/Cc0TOTKxTS6g0/K42WM5pdlRgf XJkkIy3QAsWH9ZH6p20/UJ0aIyJFoOY/2r49dh1mstRdaKfAsWlNf+SDz5Cp2TrpISoR GwjA== X-Gm-Message-State: ANoB5pmRe+arlj738KrNuGWnCJUvTTqzYAbUctGCYEOIYJrbJL3wpDzK x2osWbnE0bL6zdRUMUYz+A== X-Google-Smtp-Source: AA0mqf5cYXpx7BMY7mQIfJg+ZejDxYTLXZYZUUDjroJAmpxKguBo5q82cn6W7jmDTUA6h0QowpOjXg== X-Received: by 2002:a05:6a20:9b9a:b0:ab:fe5a:df95 with SMTP id mr26-20020a056a209b9a00b000abfe5adf95mr43045423pzb.15.1671324197553; Sat, 17 Dec 2022 16:43:17 -0800 (PST) Received: from WDIR.. ([182.209.58.25]) by smtp.gmail.com with ESMTPSA id k10-20020a63ff0a000000b0047048c201e3sm3639458pgi.33.2022.12.17.16.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 16:43:17 -0800 (PST) From: "Daniel T. Lee" To: Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Yonghong Song Cc: bpf@vger.kernel.org, netdev@vger.kernel.org Subject: [bpf-next v3 2/3] samples/bpf: replace meaningless counter with tracex4 Date: Sun, 18 Dec 2022 09:43:06 +0900 Message-Id: <20221218004307.4872-3-danieltimlee@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218004307.4872-1-danieltimlee@gmail.com> References: <20221218004307.4872-1-danieltimlee@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Currently, compiling samples/bpf with LLVM warns about the unused but set variable with tracex4_user. ./samples/bpf/tracex4_user.c:54:14: warning: variable 'i' set but not used [-Wunused-but-set-variable] int map_fd, i, j = 0; ^ 1 warning generated. This commit resolve this compiler warning by replacing the meaningless counter. Signed-off-by: Daniel T. Lee Acked-by: Yonghong Song --- samples/bpf/tracex4_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/bpf/tracex4_user.c b/samples/bpf/tracex4_user.c index 227b05a0bc88..dee8f0a091ba 100644 --- a/samples/bpf/tracex4_user.c +++ b/samples/bpf/tracex4_user.c @@ -51,7 +51,7 @@ int main(int ac, char **argv) struct bpf_program *prog; struct bpf_object *obj; char filename[256]; - int map_fd, i, j = 0; + int map_fd, j = 0; snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); obj = bpf_object__open_file(filename, NULL); @@ -82,7 +82,7 @@ int main(int ac, char **argv) j++; } - for (i = 0; ; i++) { + while (1) { print_old_objects(map_fd); sleep(1); } From patchwork Sun Dec 18 00:43:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel T. Lee" X-Patchwork-Id: 13075960 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FE76C4167B for ; Sun, 18 Dec 2022 00:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbiLRAnX (ORCPT ); Sat, 17 Dec 2022 19:43:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbiLRAnU (ORCPT ); Sat, 17 Dec 2022 19:43:20 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FB31BC99; Sat, 17 Dec 2022 16:43:20 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id n4so5821909plp.1; Sat, 17 Dec 2022 16:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FF+eD2XRIoYlmEr/X2g308YQEbkC1R5Phje24seUWA4=; b=KcAn0d7idQOqi6LHRK6UIf0FLN/bRAgSckzYdGogxkVjyTElzaUYSalimwM8D45eI/ 1xSJo0eC7sf8WHdz4zg8lhYVqP6IqFmDD2LeIOROYX9zAi02KpZyfcntGUcKhQ/lwcHR DKIcBIfWGBs4XBoVrnsEEgHdf81vxvpRhYqA/RBaLf9aDj2SdHN0aLOVdK75tbMromFQ QzytLmpMIxc7zJaCcs/BFcAa4Fss1jO50me243Of5RSBWi0fjKMNZpMDP1HuWTPhSwps zGchAMxQF6me7Pu93/UZNGDbD/oEEeO8u5NAECpaHJeAXlpT57qqfodpC8DhPc2YLDAB DFbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FF+eD2XRIoYlmEr/X2g308YQEbkC1R5Phje24seUWA4=; b=WqmmiLJZL7M9tAzYhhu/MmrZM39Z+9Nu32f8K6SP2lMufYFUOPwE5soqUZzyn/qrt8 8hgPvydIw48Hl2dH+P4WGeegSZRcv1QrU4QOY3Dfe6kS+HD6BkNYWlrHu2WQ57/yQb5p uQiur3CXDfqCb/l5B8RqxNQCdFTGJmQuoB9GEXe0+AaJTUDkNZ6CfGqORhXe+m3pDPIS kuGVnRiCL8MKBfRfCWIR6I2ZClKcZB0w0RduoWZkvOnQzUoSbBR3w6q3VhCEzRUHDkjN YNtuDrwT+EVY0i8jglyPbvBfR1AosnLLnAcxBlhJadLTFEipnVf2+NBjVbL2jOKZ5Zn4 S3LQ== X-Gm-Message-State: AFqh2kqO0nih23ZOhIHb71zpR9pagBJ4g8UVuXZrNCbyRLH4JaDOTZ7t 9exoIaFDls7ADLJIprNeZA== X-Google-Smtp-Source: AMrXdXsX7/+2ElWg7Q/+7NITnKYX5cKiDXbTcTVPD5mtdxjZf4iohSKtwKd0RcS16VdVyFBKEYIF5w== X-Received: by 2002:a17:90b:3744:b0:219:89c2:b70b with SMTP id ne4-20020a17090b374400b0021989c2b70bmr4267106pjb.16.1671324199828; Sat, 17 Dec 2022 16:43:19 -0800 (PST) Received: from WDIR.. ([182.209.58.25]) by smtp.gmail.com with ESMTPSA id k10-20020a63ff0a000000b0047048c201e3sm3639458pgi.33.2022.12.17.16.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 16:43:19 -0800 (PST) From: "Daniel T. Lee" To: Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Yonghong Song Cc: bpf@vger.kernel.org, netdev@vger.kernel.org Subject: [bpf-next v3 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Date: Sun, 18 Dec 2022 09:43:07 +0900 Message-Id: <20221218004307.4872-4-danieltimlee@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221218004307.4872-1-danieltimlee@gmail.com> References: <20221218004307.4872-1-danieltimlee@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Currently, compiling samples/bpf with LLVM warns about the uninitialized use of variable with test_current_task_under_cgroup. ./samples/bpf/test_current_task_under_cgroup_user.c:57:6: warning: variable 'cg2' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (setup_cgroup_environment()) ^~~~~~~~~~~~~~~~~~~~~~~~~~ ./samples/bpf/test_current_task_under_cgroup_user.c:106:8: note: uninitialized use occurs here close(cg2); ^~~ ./samples/bpf/test_current_task_under_cgroup_user.c:57:2: note: remove the 'if' if its condition is always false if (setup_cgroup_environment()) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./samples/bpf/test_current_task_under_cgroup_user.c:19:9: note: initialize the variable 'cg2' to silence this warning int cg2, idx = 0, rc = 1; ^ = 0 1 warning generated. This commit resolve this compiler warning by pre-initialize the variable with error for safeguard. Signed-off-by: Daniel T. Lee Acked-by: Yonghong Song --- samples/bpf/test_current_task_under_cgroup_user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/bpf/test_current_task_under_cgroup_user.c b/samples/bpf/test_current_task_under_cgroup_user.c index ac251a417f45..6fb25906835e 100644 --- a/samples/bpf/test_current_task_under_cgroup_user.c +++ b/samples/bpf/test_current_task_under_cgroup_user.c @@ -14,9 +14,9 @@ int main(int argc, char **argv) { pid_t remote_pid, local_pid = getpid(); + int cg2 = -1, idx = 0, rc = 1; struct bpf_link *link = NULL; struct bpf_program *prog; - int cg2, idx = 0, rc = 1; struct bpf_object *obj; char filename[256]; int map_fd[2]; @@ -103,7 +103,9 @@ int main(int argc, char **argv) rc = 0; err: - close(cg2); + if (cg2 != -1) + close(cg2); + cleanup_cgroup_environment(); cleanup: