Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp55345rda; Fri, 20 Oct 2023 20:47:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEl9+2jxP3mvkVoPYYUz77JVWVJCQimtw41s1LprvU6ZlUlEnTalI4VSdGUjkB7JvwxTMky X-Received: by 2002:aa7:9718:0:b0:6be:25c5:4f74 with SMTP id a24-20020aa79718000000b006be25c54f74mr3436354pfg.13.1697860029375; Fri, 20 Oct 2023 20:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697860029; cv=none; d=google.com; s=arc-20160816; b=VtEJNp5ft06RlM7h884kSsXB4gVNWccBL2dc5mJ8jHDZs0kyZuMUbvZUp00vWzBFum MQ5EGFzNAyFWsAy2XuS7NWs7VIN3XgT8LgfILFgssznequyEkfcx7Jj2KjrhCmOJhyF7 7EyV9mtN8+mL5OyDAfQNq+7QeY3waq934FSxnk3f0Oll2EdZoh9BzRuu1Fl6ecMlVh5S hZ+LowrO2oltT0lWxihCLB3j6ZZajwWyIZD6iszkwK0PlqsvwKRUenNZdE0UksUjY/mZ 0pZLdu/1CvhAb7gON+GQc7CIAR1EEVY6dCIX/wZttX6TZCpT4ZQAZbfbHIDD1B3woWX4 j09g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=U9uxYMKTxKvAZ2PVIZvEz2M4dTYUC9IaNrlDNTSDoYg=; fh=4VQRH8VqWwCB3xQ35rnPhjZYOAT9/EX0NaN9uCKR07Y=; b=bhSnIPIhjl7WlgJVXYa+a0s0mY8bGir7g0Jo+wzan7ViebKysPGlPQMsbWU56TRwNe JyxBAPGvCPWCVIcm8+u648ri4/Dma007vHRi2YrGJ4ApIl5GDSQtN78dVr2tXgH3K8lL Qwb8A0Nc7wEdNLth6u9cYWkqLkCz4P4JfpzIF9+imliktSIfbjbkg0vFfKCYzdagBIfV u+u9swADms83/woMKV7jKwJZYBoZ0s2FXQhMS28KxTiWZHWBT9gTUnXNfWBoMpFuOlYS PJITCZhF+SfgVv7Buens9uzUSv54JmKpkAawM8/aiThC91trLtEngw9lrU4cQi3A6s0k 1ejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=ex1dqEKM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z10-20020aa79f8a000000b006b798c24276si2956374pfr.348.2023.10.20.20.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 20:47:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=ex1dqEKM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 14F1F8057B16; Fri, 20 Oct 2023 20:47:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbjJUDqM (ORCPT + 99 others); Fri, 20 Oct 2023 23:46:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjJUDqJ (ORCPT ); Fri, 20 Oct 2023 23:46:09 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AF6ED78 for ; Fri, 20 Oct 2023 20:45:42 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c87a85332bso12183125ad.2 for ; Fri, 20 Oct 2023 20:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697859942; x=1698464742; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=U9uxYMKTxKvAZ2PVIZvEz2M4dTYUC9IaNrlDNTSDoYg=; b=ex1dqEKMLN36xWxNpX9ZptBr9UAwkDSyicEz7Ay8j6TIooDUx7yX6BlHICwcvd0TUT b7DbyXuNr5pLIXeb+0fVOWLRtgkMQ3hEfWmyHzDAvST5h3c+nEjfNy2CCpJVobczXg26 WXNhLkRgWwn4ylYU5WNuXh0x07gkbUNvBICZR0IIGAP3Qnp/BfBLTln98wh8GVpqv2fO IgAtILmt6Can+N8QDIvmzl52ssD9D65W7IGFjRPgT7+wP2VHqVWwA2IEswjfBI+pwmn5 rdqESWgsMUgWdkBUG+d649VqXMEt6uJ2LhQkUdf5oaPZcoAT0NcxIismPDcziYXQijX0 0qFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697859942; x=1698464742; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=U9uxYMKTxKvAZ2PVIZvEz2M4dTYUC9IaNrlDNTSDoYg=; b=WnpuIqtrUBjY4LBzNP1bAOXmhgtIPFWvs3REQFRqRLcGMx3WPvvyGRE7ohxemuxzdX 4iZlhhaFWHW9h0YCRZKJ8XDUO7VcUlkvfzLr6JK6t90ZCcvLCce1Sqi3DxT1Jy6rjJtI tVoHzK/1DW0RH1liwEW3CbBTMzVOSvdVbuvzCr5jwQ8d1RJIIp8gK4F7qxD57qxGsvSB BtDPC/GDpf6rCfjQ6qsKx9Od/HmHnLe40Z66EXCLQKL3scycQk7jd3SPaEzZhVLNRoD5 Z0qRDmCg93wz2DJK4QwegFF83IVG2Qwboa7Xx3uFYZNZdvSR4VxL92Lpm2htOq471fSZ HKTg== X-Gm-Message-State: AOJu0YwPUVBxfzwFD46aoQ+KIiySkCWIzO2LUOxYc/eQgCZa1PpZ5xXE BqKxTtbz8nWAakRdvcEEu/45ig== X-Received: by 2002:a17:902:d0c2:b0:1ca:b26a:9729 with SMTP id n2-20020a170902d0c200b001cab26a9729mr3692531pln.38.1697859941685; Fri, 20 Oct 2023 20:45:41 -0700 (PDT) Received: from [10.254.107.145] ([139.177.225.237]) by smtp.gmail.com with ESMTPSA id h14-20020a170902f54e00b001c62e3e1286sm2245528plf.166.2023.10.20.20.45.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Oct 2023 20:45:41 -0700 (PDT) Message-ID: Date: Sat, 21 Oct 2023 11:45:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] bpf: hide cgroup functions for configs without cgroups To: Arnd Bergmann , Alexei Starovoitov , Arnd Bergmann Cc: Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Tejun Heo , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Oleg Nesterov , bpf , LKML References: <20231020132749.1398012-1-arnd@kernel.org> <5e45b11b-853d-49e6-a355-251dc1362676@app.fastmail.com> From: Chuyi Zhou In-Reply-To: <5e45b11b-853d-49e6-a355-251dc1362676@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 20 Oct 2023 20:47:06 -0700 (PDT) Hello, 在 2023/10/21 04:06, Arnd Bergmann 写道: > On Fri, Oct 20, 2023, at 19:26, Alexei Starovoitov wrote: >> On Fri, Oct 20, 2023 at 6:27 AM Arnd Bergmann wrote: >>> @@ -904,6 +904,7 @@ __diag_push(); >>> __diag_ignore_all("-Wmissing-prototypes", >>> "Global functions as their definitions will be in vmlinux BTF"); >>> >>> +#ifdef CONFIG_CGROUPS >>> __bpf_kfunc int bpf_iter_css_task_new(struct bpf_iter_css_task *it, >>> struct cgroup_subsys_state *css, unsigned int flags) >>> { >>> @@ -947,6 +948,7 @@ __bpf_kfunc void bpf_iter_css_task_destroy(struct bpf_iter_css_task *it) >>> css_task_iter_end(kit->css_it); >>> bpf_mem_free(&bpf_global_ma, kit->css_it); >>> } >>> +#endif >> >> Did you actually test build it without cgroups and with bpf+btf? >> I suspect the resolve_btfid step should be failing the build. >> It needs >> #ifdef CONFIG_CGROUPS >> around BTF_ID_FLAGS(func, bpf_iter_css_task* > > No, I did test with a few hundred random configurations, but it > looks like CONFIG_DEBUG_INFO_BTF is always disabled > in my builds because I force-disable CONFIG_DEBUG_INFO > to speed up my builds. > > I tried reproducing it with CONFIG_DEBUG_INFO_BTF enabled > and it didn't immediately fail but it clearly makes sense that > we'd need another #ifdef. > > Arnd seems the same problem also reported by kernel-robot: tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 2030579113a1b1b5bfd7ff24c0852847836d8fd1 commit: 9c66dc94b62aef23300f05f63404afb8990920b4 [13777/13906] bpf: Introduce css_task open-coded iterator kfuncs config: hexagon-randconfig-r003-20230725 (https://download.01.org/0day-ci/archive/20231021/202310211011.pTzXR2o9-lkp@intel.com/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231021/202310211011.pTzXR2o9-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202310211011.pTzXR2o9-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from kernel/bpf/task_iter.c:9: In file included from include/linux/filter.h:9: In file included from include/linux/bpf.h:31: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/hexagon/include/asm/io.h:337: include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) ^ In file included from kernel/bpf/task_iter.c:9: In file included from include/linux/filter.h:9: In file included from include/linux/bpf.h:31: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/hexagon/include/asm/io.h:337: include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) ^ In file included from kernel/bpf/task_iter.c:9: In file included from include/linux/filter.h:9: In file included from include/linux/bpf.h:31: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/hexagon/include/asm/io.h:337: include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ >> kernel/bpf/task_iter.c:919:7: error: use of undeclared identifier 'CSS_TASK_ITER_PROCS' case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED: ^ >> kernel/bpf/task_iter.c:919:29: error: use of undeclared identifier 'CSS_TASK_ITER_THREADED' case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED: ^ kernel/bpf/task_iter.c:920:7: error: use of undeclared identifier 'CSS_TASK_ITER_PROCS' case CSS_TASK_ITER_PROCS: ^ >> kernel/bpf/task_iter.c:927:46: error: invalid application of 'sizeof' to an incomplete type 'struct css_task_iter' kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter)); ^ ~~~~~~~~~~~~~~~~~~~~~~ kernel/bpf/task_iter.c:902:9: note: forward declaration of 'struct css_task_iter' struct css_task_iter *css_it; ^ >> kernel/bpf/task_iter.c:930:2: error: call to undeclared function 'css_task_iter_start'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] css_task_iter_start(css, flags, kit->css_it); ^ kernel/bpf/task_iter.c:930:2: note: did you mean '__sg_page_iter_start'? include/linux/scatterlist.h:573:6: note: '__sg_page_iter_start' declared here void __sg_page_iter_start(struct sg_page_iter *piter, ^ >> kernel/bpf/task_iter.c:940:9: error: call to undeclared function 'css_task_iter_next'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] return css_task_iter_next(kit->css_it); ^ >> kernel/bpf/task_iter.c:940:9: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'struct task_struct *' [-Wint-conversion] return css_task_iter_next(kit->css_it); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> kernel/bpf/task_iter.c:949:2: error: call to undeclared function 'css_task_iter_end'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] css_task_iter_end(kit->css_it); ^ 6 warnings and 8 errors generated. vim +/CSS_TASK_ITER_PROCS +919 kernel/bpf/task_iter.c 904 905 __diag_push(); 906 __diag_ignore_all("-Wmissing-prototypes", 907 "Global functions as their definitions will be in vmlinux BTF"); 908 909 __bpf_kfunc int bpf_iter_css_task_new(struct bpf_iter_css_task *it, 910 struct cgroup_subsys_state *css, unsigned int flags) 911 { 912 struct bpf_iter_css_task_kern *kit = (void *)it; 913 914 BUILD_BUG_ON(sizeof(struct bpf_iter_css_task_kern) != sizeof(struct bpf_iter_css_task)); 915 BUILD_BUG_ON(__alignof__(struct bpf_iter_css_task_kern) != 916 __alignof__(struct bpf_iter_css_task)); 917 kit->css_it = NULL; 918 switch (flags) { > 919 case CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED: > 920 case CSS_TASK_ITER_PROCS: 921 case 0: 922 break; 923 default: 924 return -EINVAL; 925 } 926 > 927 kit->css_it = bpf_mem_alloc(&bpf_global_ma, sizeof(struct css_task_iter)); 928 if (!kit->css_it) 929 return -ENOMEM; > 930 css_task_iter_start(css, flags, kit->css_it); 931 return 0; 932 } 933 934 __bpf_kfunc struct task_struct *bpf_iter_css_task_next(struct bpf_iter_css_task *it) 935 { 936 struct bpf_iter_css_task_kern *kit = (void *)it; 937 938 if (!kit->css_it) 939 return NULL; > 940 return css_task_iter_next(kit->css_it); 941 } 942 943 __bpf_kfunc void bpf_iter_css_task_destroy(struct bpf_iter_css_task *it) 944 { 945 struct bpf_iter_css_task_kern *kit = (void *)it; 946 947 if (!kit->css_it) 948 return; > 949 css_task_iter_end(kit->css_it); 950 bpf_mem_free(&bpf_global_ma, kit->css_it); 951 } 952 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki