From patchwork Sat Dec 17 15:38:19 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: 13075860 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 26113C3DA6E for ; Sat, 17 Dec 2022 15:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229659AbiLQPzH (ORCPT ); Sat, 17 Dec 2022 10:55:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbiLQPyj (ORCPT ); Sat, 17 Dec 2022 10:54:39 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA7EB28E30; Sat, 17 Dec 2022 07:38:28 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so8937574pje.5; Sat, 17 Dec 2022 07:38:28 -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=uediP+nXqszD82iggm8JfD1AiyDXDZ52s2ztBKGez2M=; b=JWv9ZTrEUm3pRQH1VfpkVHn+OcACgUJJzKpnaFMH6T6XzHAh7m84EwiahnOtkVM8rY jkYBmQSS/XYz+0BBTaUEZzUdRD2B+ut6oaBtkUldibK6KWAIYppANfWk/5F7TEV0xXBM 8UKSogxtIYz+C/Qq7iHSICY3/mVKxberoLMfN8YpS5/r8fsizBimeWtT0ndHRb+NQ5MV NwqJ3iKNElngy+N0rmVX9+Dj8guDWK6QROeyF49Ew2HS9dy5xggvxjD871D4d6o3pNZg aGZJ7ZZrtCEiIWpz+vzvm1VcJ41Urp/mv13+roRIhLQN/bqooeJAoxOzbh3hZIBwOYFA DD/Q== 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=uediP+nXqszD82iggm8JfD1AiyDXDZ52s2ztBKGez2M=; b=7EUVBEPqdPO0njsZz4cfTZbkwgHWr6MsumCOEA/YtXcWbo95JwhMFCu/lH03l9UXsv 8hDZvFf5rmHiVMCDaSCGa1wGWBtLO6uagUdWbsnXZmi0J6td13mzrnUc5jK3k1iV8EZb sZ5XDdPtqMq8LIDqVc02MYw3nayS8vKcgv5LldOL1BikdScfMqBsCR2cJ6/9SsMXpLRB LFFNv5YR4AWd1kEp1ZHf4Pdbh8U3NirI4TvzOgjRu8SHtQ7vUAOrQ8t4TwMuvqlfBbZf wTOc1BjQwCX2PwhX77k2XNeBrlbc34qpOy92jGbX9fGqPpMCg56qvSpj0BIPgBO/vgEq z3pw== X-Gm-Message-State: AFqh2kq+Wh3N9/6njO5CPhzZvgaQqGAAxqzDlTKUDx8YCwRYv60pqwGh KQ8u1rA2F4o3AzCgRtsJxQ== X-Google-Smtp-Source: AMrXdXs33Hzc0q7XWbqBLKfKes3e8RZeAY85ie+MzTdRfLYsZhj+oyetH9qxyus0JpGk6GjNnFhkqg== X-Received: by 2002:a17:90a:69e5:b0:20d:bd60:adab with SMTP id s92-20020a17090a69e500b0020dbd60adabmr2738748pjj.39.1671291508492; Sat, 17 Dec 2022 07:38:28 -0800 (PST) Received: from WDIR.. ([182.209.58.25]) by smtp.gmail.com with ESMTPSA id u31-20020a63235f000000b00488b8ad57bfsm732039pgm.54.2022.12.17.07.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 07:38:28 -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 1/3] samples/bpf: remove unused function with test_lru_dist Date: Sun, 18 Dec 2022 00:38:19 +0900 Message-Id: <20221217153821.2285-2-danieltimlee@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221217153821.2285-1-danieltimlee@gmail.com> References: <20221217153821.2285-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 Sat Dec 17 15:38:20 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: 13075861 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 E9358C3DA6E for ; Sat, 17 Dec 2022 15:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbiLQPzT (ORCPT ); Sat, 17 Dec 2022 10:55:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiLQPys (ORCPT ); Sat, 17 Dec 2022 10:54:48 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D45B8BABF; Sat, 17 Dec 2022 07:38:32 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id n4so5119210plp.1; Sat, 17 Dec 2022 07:38:32 -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=Iup7qw0+rj8DaZBRvEJ2soCZA1zKqIHJImQRSJG43gk=; b=K/+sKSytvNZOquFT4/eSf556X0cE/H3UeTVU7N+Phf2GjRaHXnJjwmpAOnDksKhVL2 /09jixdjrCLSiTsCJGDY2928IftwBe8idg4IISV3Ym/qLpgmU+sKiAOynNhrpJVm85Lb 8wrtlu9l3Kzetmhw9U/tNjsrdfoaByOFyp3WPTreYpn7s2pvCFGWpcErNFIteb6fDQh9 gUt6RfDhB9bbzFxbSPp2l/iK6jVFGvKYw8Dtj0myDyJP6qJB5MV3IKmsoVckGMscE0Ra nUhBQskUeJh8zvXS0CoduwVJy9Ttg7nvzH3NgyC/VnEQo5c+D7t/txK8m1XZic416Jzb dnMA== 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=Iup7qw0+rj8DaZBRvEJ2soCZA1zKqIHJImQRSJG43gk=; b=HT3ZkLMmHpHNLqxrUyhxnaHdiDJobkrInKXDE6XPuxVu/TSfBHiOJMm0t2SNbfLNjK o+UeIWVG2Y0WVqBzUsZNY34t5iyG3n89fyZs8O4t/Ipvha5MlU78NUGJCGRruxS7p2YQ jy3nB2dfIBx3XrSo9JFhZe+oQC20w92lO7eV+N6zBMrpZB+xgag7kY3FpMGa9tcpkj9v 2HwYImYLvYhd6+5dfgLofGTSTS+/Hto+D7d7rSfDe6qUE9H/FGWHaOSm1LVM7CzTCDe+ aUV+O0Fk8j9Sv7JBOIBmBgEnWwcAdkDRAnELFSrZoquqDZi1kUW2WqpKQQ3L3gOeZxVn uenQ== X-Gm-Message-State: ANoB5plKwGIENN/vxoTiqbMMDZ4mNS64PJDIS/sHToWdNe6AmSpShZvr 2aWQKfzt1UP+5wDUbHndAJ8e/HTvw0zu X-Google-Smtp-Source: AA0mqf4G0aH5VznYgXb3khbLrXri8FJjJMAHHJob89tT7oFB9UObGnKvA2L6adL0BubvepuNT6VnhA== X-Received: by 2002:a17:90a:e010:b0:21a:1291:e80f with SMTP id u16-20020a17090ae01000b0021a1291e80fmr37141631pjy.33.1671291510824; Sat, 17 Dec 2022 07:38:30 -0800 (PST) Received: from WDIR.. ([182.209.58.25]) by smtp.gmail.com with ESMTPSA id u31-20020a63235f000000b00488b8ad57bfsm732039pgm.54.2022.12.17.07.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 07:38:30 -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 2/3] samples/bpf: replace meaningless counter with tracex4 Date: Sun, 18 Dec 2022 00:38:20 +0900 Message-Id: <20221217153821.2285-3-danieltimlee@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221217153821.2285-1-danieltimlee@gmail.com> References: <20221217153821.2285-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 Sat Dec 17 15:38:21 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: 13075862 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 DBE42C4332F for ; Sat, 17 Dec 2022 15:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231142AbiLQPzY (ORCPT ); Sat, 17 Dec 2022 10:55:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbiLQPyu (ORCPT ); Sat, 17 Dec 2022 10:54:50 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1063C8F949; Sat, 17 Dec 2022 07:38:36 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id 4so5106834plj.3; Sat, 17 Dec 2022 07:38:36 -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=5scM6H1KR3NuFmM3GwXtJX6bswpVcFplxcFPcjKDe2U=; b=jq6flea9qTjKTF/FvXfXoU9MrQ5CKJYqBaS6574qrCv7EQLL4LZDlfuV4sLcvwrXVZ 7vmfLlesI9hGuUXobscqKMJUQDN9y47/lJFu0F5uFbMmGgqDm/ci2/XEt+gX4OYvmDVH nRNfXhlBI1d5bAJ2sQuIxyV9gKuBroYJ5zeV8sflYsi/11M1ATkzZXLrnzgS/kj7LCwj VYYKKtKjX2h8EQIC4+Nv238uYW2QbFKeukgPfMH/EdIXTtIMllmiqA9VeOJfHNaX1jXe euXDg9zhcDS2j61tUR0dfMYQTF81Wa4xxT9uVKVhnLiEYdk+W5aLu1ISTwuvjoU0qlN8 N3qA== 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=5scM6H1KR3NuFmM3GwXtJX6bswpVcFplxcFPcjKDe2U=; b=US0dJojPuhZ2ZQ4CiYAXma/M8Tc3w0ScKw8jKq4UlDRjIhddL95a4JAx7Gk4dutXjh BYS0KXuB2Db8yazU+mJqhekZkTTPX+5y8zvXHlkitmB2PfqVvGz6SCuGI6F33bj68a+K /h7SOAMfh1JTwXfz99lhn3rHgMfK2goEAKpsBU0Wn1HHfYQX4zPTtQ26eMVfHem7e7aC yk2ha+QbAgw+WgeSKqwzQ1FZrtc5lz+DUXxy95793cuQ43cWL0VN6Me4AgBiBZ215xX4 HOvyfBNRa0bsRudqmOsCM1StJfeYSz70AS6jOK886LevnMFpFjDmX3tg07GcRl4E9URl kIxQ== X-Gm-Message-State: ANoB5pn1C+BEgIW+kByEXWZEuKO7NVtomafc74yx8pLPKpTPKsSLK8FQ nHsMS2TOmwpQTzk2dgYUig== X-Google-Smtp-Source: AA0mqf5vOszpsJtqyXdwLB4RjTNnV/6d/iUcQUwpegI0nSpAp2zb8BalkBbC8zVPO8JhVdc5HUDIOQ== X-Received: by 2002:a17:902:d412:b0:18f:37ec:9675 with SMTP id b18-20020a170902d41200b0018f37ec9675mr24605055ple.21.1671291513143; Sat, 17 Dec 2022 07:38:33 -0800 (PST) Received: from WDIR.. ([182.209.58.25]) by smtp.gmail.com with ESMTPSA id u31-20020a63235f000000b00488b8ad57bfsm732039pgm.54.2022.12.17.07.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 07:38:32 -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 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Date: Sun, 18 Dec 2022 00:38:21 +0900 Message-Id: <20221217153821.2285-4-danieltimlee@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221217153821.2285-1-danieltimlee@gmail.com> References: <20221217153821.2285-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: