bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Menglong Dong <menglong8.dong@gmail.com>,
	alexei.starovoitov@gmail.com, rostedt@goodmis.org,
	jolsa@kernel.org
Cc: oe-kbuild-all@lists.linux.dev, bpf@vger.kernel.org,
	Menglong Dong <dongml2@chinatelecom.cn>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 01/18] bpf: add function hash table for tracing-multi
Date: Sat, 5 Jul 2025 00:07:05 +0800	[thread overview]
Message-ID: <202507042321.HJfEZMgT-lkp@intel.com> (raw)
In-Reply-To: <20250703121521.1874196-2-dongml2@chinatelecom.cn>

Hi Menglong,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Menglong-Dong/bpf-add-function-hash-table-for-tracing-multi/20250703-203035
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20250703121521.1874196-2-dongml2%40chinatelecom.cn
patch subject: [PATCH bpf-next v2 01/18] bpf: add function hash table for tracing-multi
config: i386-randconfig-062-20250704 (https://download.01.org/0day-ci/archive/20250704/202507042321.HJfEZMgT-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250704/202507042321.HJfEZMgT-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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507042321.HJfEZMgT-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> kernel/bpf/kfunc_md.c:14:23: sparse: sparse: symbol 'default_mds' was not declared. Should it be static?
>> kernel/bpf/kfunc_md.c:21:43: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected struct kfunc_md_array [noderef] __rcu *[addressable] [toplevel] kfunc_mds @@     got struct kfunc_md_array * @@
   kernel/bpf/kfunc_md.c:21:43: sparse:     expected struct kfunc_md_array [noderef] __rcu *[addressable] [toplevel] kfunc_mds
   kernel/bpf/kfunc_md.c:21:43: sparse:     got struct kfunc_md_array *
>> kernel/bpf/kfunc_md.c:186:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct atomic_t const [usertype] *v @@     got struct atomic_t [noderef] __rcu * @@
   kernel/bpf/kfunc_md.c:186:26: sparse:     expected struct atomic_t const [usertype] *v
   kernel/bpf/kfunc_md.c:186:26: sparse:     got struct atomic_t [noderef] __rcu *
>> kernel/bpf/kfunc_md.c:111:32: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct kfunc_md_array *mds @@     got struct kfunc_md_array [noderef] __rcu *extern [addressable] [toplevel] kfunc_mds @@
   kernel/bpf/kfunc_md.c:111:32: sparse:     expected struct kfunc_md_array *mds
   kernel/bpf/kfunc_md.c:111:32: sparse:     got struct kfunc_md_array [noderef] __rcu *extern [addressable] [toplevel] kfunc_mds
>> kernel/bpf/kfunc_md.c:153:17: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct kfunc_md_array *old_mds @@     got struct kfunc_md_array [noderef] __rcu *extern [addressable] [toplevel] kfunc_mds @@
   kernel/bpf/kfunc_md.c:153:17: sparse:     expected struct kfunc_md_array *old_mds
   kernel/bpf/kfunc_md.c:153:17: sparse:     got struct kfunc_md_array [noderef] __rcu *extern [addressable] [toplevel] kfunc_mds
   kernel/bpf/kfunc_md.c:194:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct atomic_t const [usertype] *v @@     got struct atomic_t [noderef] __rcu * @@
   kernel/bpf/kfunc_md.c:194:26: sparse:     expected struct atomic_t const [usertype] *v
   kernel/bpf/kfunc_md.c:194:26: sparse:     got struct atomic_t [noderef] __rcu *
>> kernel/bpf/kfunc_md.c:214:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct atomic_t [usertype] *v @@     got struct atomic_t [noderef] __rcu * @@
   kernel/bpf/kfunc_md.c:214:21: sparse:     expected struct atomic_t [usertype] *v
   kernel/bpf/kfunc_md.c:214:21: sparse:     got struct atomic_t [noderef] __rcu *
   kernel/bpf/kfunc_md.c:238:30: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct atomic_t const [usertype] *v @@     got struct atomic_t [noderef] __rcu * @@
   kernel/bpf/kfunc_md.c:238:30: sparse:     expected struct atomic_t const [usertype] *v
   kernel/bpf/kfunc_md.c:238:30: sparse:     got struct atomic_t [noderef] __rcu *
>> kernel/bpf/kfunc_md.c:126:21: sparse: sparse: dereference of noderef expression
   kernel/bpf/kfunc_md.c:139:31: sparse: sparse: dereference of noderef expression
   kernel/bpf/kfunc_md.c:140:17: sparse: sparse: dereference of noderef expression
   kernel/bpf/kfunc_md.c:186:57: sparse: sparse: dereference of noderef expression
   kernel/bpf/kfunc_md.c:194:57: sparse: sparse: dereference of noderef expression
   kernel/bpf/kfunc_md.c:197:13: sparse: sparse: dereference of noderef expression
   kernel/bpf/kfunc_md.c:248:35: sparse: sparse: dereference of noderef expression
   kernel/bpf/kfunc_md.c:249:17: sparse: sparse: dereference of noderef expression

vim +/default_mds +14 kernel/bpf/kfunc_md.c

    12	
    13	#define MIN_KFUNC_MD_ARRAY_BITS 4
  > 14	struct kfunc_md_array default_mds = {
    15		.used = ATOMIC_INIT(0),
    16		.hash_bits = MIN_KFUNC_MD_ARRAY_BITS,
    17		.mds = {
    18			[0 ... ((1 << MIN_KFUNC_MD_ARRAY_BITS) - 1)] = HLIST_HEAD_INIT,
    19		},
    20	};
  > 21	struct kfunc_md_array __rcu *kfunc_mds = &default_mds;
    22	EXPORT_SYMBOL_GPL(kfunc_mds);
    23	
    24	static DEFINE_MUTEX(kfunc_md_mutex);
    25	
    26	static int kfunc_md_array_inc(void);
    27	
    28	static void kfunc_md_release_rcu(struct rcu_head *rcu)
    29	{
    30		struct kfunc_md *md;
    31	
    32		md = container_of(rcu, struct kfunc_md, rcu);
    33		/* Step 4, free the md */
    34		kfree(md);
    35	}
    36	
    37	static void kfunc_md_release_rcu_tasks(struct rcu_head *rcu)
    38	{
    39		struct kfunc_md *md;
    40	
    41		md = container_of(rcu, struct kfunc_md, rcu);
    42		/* Step 3, wait for the nornal progs and bfp_global_caller to finish */
    43		call_rcu_tasks(&md->rcu, kfunc_md_release_rcu);
    44	}
    45	
    46	static void kfunc_md_release(struct percpu_ref *pcref)
    47	{
    48		struct kfunc_md *md;
    49	
    50		md = container_of(pcref, struct kfunc_md, pcref);
    51		percpu_ref_exit(&md->pcref);
    52	
    53		/* Step 2, wait for sleepable progs to finish. */
    54		call_rcu_tasks_trace(&md->rcu, kfunc_md_release_rcu_tasks);
    55	}
    56	
    57	struct kfunc_md *kfunc_md_get(unsigned long ip)
    58	{
    59		struct kfunc_md_array *mds;
    60		struct kfunc_md *md;
    61	
    62		rcu_read_lock();
    63		mds = rcu_dereference(kfunc_mds);
    64		md = __kfunc_md_get(mds, ip);
    65		rcu_read_unlock();
    66	
    67		return md;
    68	}
    69	EXPORT_SYMBOL_GPL(kfunc_md_get);
    70	
    71	static struct kfunc_md *__kfunc_md_create(struct kfunc_md_array *mds, unsigned long ip,
    72						  int nr_args)
    73	{
    74		struct kfunc_md *md = __kfunc_md_get(mds, ip);
    75		int err;
    76	
    77		if (md) {
    78			md->users++;
    79			return md;
    80		}
    81	
    82		md = kzalloc(sizeof(*md), GFP_KERNEL);
    83		if (!md)
    84			return NULL;
    85	
    86		md->users = 1;
    87		md->func = ip;
    88		md->nr_args = nr_args;
    89	
    90		err = percpu_ref_init(&md->pcref, kfunc_md_release, 0, GFP_KERNEL);
    91		if (err) {
    92			kfree(md);
    93			return NULL;
    94		}
    95	
    96		hlist_add_head_rcu(&md->hash, kfunc_md_hash_head(mds, ip));
    97		atomic_inc(&mds->used);
    98	
    99		return md;
   100	}
   101	
   102	struct kfunc_md *kfunc_md_create(unsigned long ip, int nr_args)
   103	{
   104		struct kfunc_md *md = NULL;
   105	
   106		mutex_lock(&kfunc_md_mutex);
   107	
   108		if (kfunc_md_array_inc())
   109			goto out;
   110	
 > 111		md = __kfunc_md_create(kfunc_mds, ip, nr_args);
   112	out:
   113		mutex_unlock(&kfunc_md_mutex);
   114	
   115		return md;
   116	}
   117	EXPORT_SYMBOL_GPL(kfunc_md_create);
   118	
   119	static int kfunc_md_array_adjust(bool inc)
   120	{
   121		struct kfunc_md_array *new_mds, *old_mds;
   122		struct kfunc_md *md, *new_md;
   123		struct hlist_node *n;
   124		int size, hash_bits, i;
   125	
 > 126		hash_bits = kfunc_mds->hash_bits;
   127		hash_bits += inc ? 1 : -1;
   128	
   129		size = sizeof(*new_mds) + sizeof(struct hlist_head) * (1 << hash_bits);
   130		new_mds = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
   131		if (!new_mds)
   132			return -ENOMEM;
   133	
   134		new_mds->hash_bits = hash_bits;
   135		for (i = 0; i < (1 << new_mds->hash_bits); i++)
   136			INIT_HLIST_HEAD(&new_mds->mds[i]);
   137	
   138		/* copy all the mds from kfunc_mds to new_mds */
   139		for (i = 0; i < (1 << kfunc_mds->hash_bits); i++) {
   140			hlist_for_each_entry(md, &kfunc_mds->mds[i], hash) {
   141				new_md = __kfunc_md_create(new_mds, md->func, md->nr_args);
   142				if (!new_md)
   143					goto err_out;
   144	
   145				new_md->bpf_prog_cnt = md->bpf_prog_cnt;
   146				new_md->bpf_origin_call = md->bpf_origin_call;
   147				new_md->users = md->users;
   148	
   149				memcpy(new_md->bpf_progs, md->bpf_progs, sizeof(md->bpf_progs));
   150			}
   151		}
   152	
 > 153		old_mds = kfunc_mds;
   154		rcu_assign_pointer(kfunc_mds, new_mds);
   155		synchronize_rcu();
   156	
   157		/* free all the mds in the old_mds. See kfunc_md_put() for the
   158		 * complete release process.
   159		 */
   160		for (i = 0; i < (1 << old_mds->hash_bits); i++) {
   161			hlist_for_each_entry_safe(md, n, &old_mds->mds[i], hash) {
   162				percpu_ref_kill(&md->pcref);
   163				hlist_del(&md->hash);
   164			}
   165		}
   166	
   167		if (old_mds != &default_mds)
   168			kfree_rcu(old_mds, rcu);
   169	
   170		return 0;
   171	
   172	err_out:
   173		for (i = 0; i < (1 << new_mds->hash_bits); i++) {
   174			hlist_for_each_entry_safe(md, n, &new_mds->mds[i], hash) {
   175				percpu_ref_exit(&md->pcref);
   176				hlist_del(&md->hash);
   177				kfree(md);
   178			}
   179		}
   180		return -ENOMEM;
   181	}
   182	
   183	static int kfunc_md_array_inc(void)
   184	{
   185		/* increase the hash table if greater than 90% */
 > 186		if (atomic_read(&kfunc_mds->used) * 10 < (1 << (kfunc_mds->hash_bits)) * 9)
   187			return 0;
   188		return kfunc_md_array_adjust(true);
   189	}
   190	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

  reply	other threads:[~2025-07-04 16:07 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 12:15 [PATCH bpf-next v2 00/18] bpf: tracing multi-link support Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 01/18] bpf: add function hash table for tracing-multi Menglong Dong
2025-07-04 16:07   ` kernel test robot [this message]
2025-07-15  1:55   ` Alexei Starovoitov
2025-07-15  2:37     ` Menglong Dong
2025-07-15  2:49       ` Alexei Starovoitov
2025-07-15  3:13         ` Menglong Dong
2025-07-15  9:06           ` Menglong Dong
2025-07-15 16:22             ` Alexei Starovoitov
2025-07-03 12:15 ` [PATCH bpf-next v2 02/18] x86,bpf: add bpf_global_caller for global trampoline Menglong Dong
2025-07-15  2:25   ` Alexei Starovoitov
2025-07-15  8:36     ` Menglong Dong
2025-07-15  9:30       ` Menglong Dong
2025-07-16 16:56         ` Inlining migrate_disable/enable. Was: " Alexei Starovoitov
2025-07-16 18:24           ` Peter Zijlstra
2025-07-16 22:35             ` Alexei Starovoitov
2025-07-16 22:49               ` Steven Rostedt
2025-07-16 22:50                 ` Steven Rostedt
2025-07-28  9:20               ` Menglong Dong
2025-07-31 16:15                 ` Alexei Starovoitov
2025-08-01  1:42                   ` Menglong Dong
2025-08-06  8:44                   ` Menglong Dong
2025-08-08  0:58                     ` Alexei Starovoitov
2025-08-08  5:48                       ` Menglong Dong
2025-08-08  6:32                       ` Menglong Dong
2025-08-08 15:47                         ` Alexei Starovoitov
2025-07-15 16:35       ` Alexei Starovoitov
2025-07-16 13:05         ` Menglong Dong
2025-07-17  0:59           ` multi-fentry proposal. Was: " Alexei Starovoitov
2025-07-17  1:50             ` Menglong Dong
2025-07-17  2:13               ` Alexei Starovoitov
2025-07-17  2:37                 ` Menglong Dong
2025-07-16 14:40         ` Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 03/18] ftrace: factor out ftrace_direct_update from register_ftrace_direct Menglong Dong
2025-07-05  2:41   ` kernel test robot
2025-07-03 12:15 ` [PATCH bpf-next v2 04/18] ftrace: add reset_ftrace_direct_ips Menglong Dong
2025-07-03 15:30   ` Steven Rostedt
2025-07-04  1:54     ` Menglong Dong
2025-07-07 18:52       ` Steven Rostedt
2025-07-08  1:26         ` Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 05/18] bpf: introduce bpf_gtramp_link Menglong Dong
2025-07-04  7:00   ` kernel test robot
2025-07-04  7:52   ` kernel test robot
2025-07-03 12:15 ` [PATCH bpf-next v2 06/18] bpf: tracing: add support to record and check the accessed args Menglong Dong
2025-07-14 22:07   ` Andrii Nakryiko
2025-07-14 23:45     ` Menglong Dong
2025-07-15 17:11       ` Andrii Nakryiko
2025-07-16 12:50         ` Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 07/18] bpf: refactor the modules_array to ptr_array Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 08/18] bpf: verifier: add btf to the function args of bpf_check_attach_target Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 09/18] bpf: verifier: move btf_id_deny to bpf_check_attach_target Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 10/18] x86,bpf: factor out arch_bpf_get_regs_nr Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 11/18] bpf: tracing: add multi-link support Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 12/18] libbpf: don't free btf if tracing_multi progs existing Menglong Dong
2025-07-14 22:07   ` Andrii Nakryiko
2025-07-15  1:15     ` Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 13/18] libbpf: support tracing_multi Menglong Dong
2025-07-14 22:07   ` Andrii Nakryiko
2025-07-15  1:58     ` Menglong Dong
2025-07-15 17:20       ` Andrii Nakryiko
2025-07-16 12:43         ` Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 14/18] libbpf: add btf type hash lookup support Menglong Dong
2025-07-14 22:07   ` Andrii Nakryiko
2025-07-15  4:40     ` Menglong Dong
2025-07-15 17:20       ` Andrii Nakryiko
2025-07-16 11:53         ` Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 15/18] libbpf: add skip_invalid and attach_tracing for tracing_multi Menglong Dong
2025-07-14 22:07   ` Andrii Nakryiko
2025-07-15  5:48     ` Menglong Dong
2025-07-15 17:23       ` Andrii Nakryiko
2025-07-16 11:46         ` Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 16/18] selftests/bpf: move get_ksyms and get_addrs to trace_helpers.c Menglong Dong
2025-07-03 12:15 ` [PATCH bpf-next v2 17/18] selftests/bpf: add basic testcases for tracing_multi Menglong Dong
2025-07-08 20:07   ` Alexei Starovoitov
2025-07-09  1:33     ` Menglong Dong
2025-07-14 23:49     ` Ihor Solodrai
2025-07-16  0:26       ` Ihor Solodrai
2025-07-16  0:31         ` Alexei Starovoitov
2025-07-16  0:34           ` Ihor Solodrai
2025-07-03 12:15 ` [PATCH bpf-next v2 18/18] selftests/bpf: add bench tests " Menglong Dong
2025-07-04  8:47 ` [PATCH bpf-next v2 00/18] bpf: tracing multi-link support Jiri Olsa
2025-07-04  8:52   ` Menglong Dong
2025-07-04  8:58     ` Menglong Dong
2025-07-04  9:12       ` Jiri Olsa
2025-07-15  2:31 ` Alexei Starovoitov
2025-07-15  2:44   ` Menglong Dong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202507042321.HJfEZMgT-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=dongml2@chinatelecom.cn \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=menglong8.dong@gmail.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).