All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: [kkdwivedi:xdp-round 101/158] kernel/bpf/kthread.c:269:19: sparse: sparse: Initializer entry defined twice
Date: Fri, 04 Dec 2026 00:56:09 +0100	[thread overview]
Message-ID: <20261204005014.pxLkWuMq-lkp@intel.com> (raw)

:::::: 
:::::: Manual check reason: "sparse: Initializer entry defined twice"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Kumar Kartikeya Dwivedi <memxor@gmail.com>

tree:   https://github.com/kkdwivedi/linux xdp-round
head:   361f52ba3cbe52e09f9c24068695693baef5ba3c
commit: 77abcab07231b6d85931d3b241d932d172eadb3d [101/158] bpf: Add BPF kthreads for syscall programs
:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
config: parisc-randconfig-r2311-20261203 (https://download.01.org/0day-ci/archive/20261204/20261204005014.pxLkWuMq-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 8.5.0
sparse: v0.6.5-rc1-94-g0d159c10
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261204/20261204005014.pxLkWuMq-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/r/20261204005014.pxLkWuMq-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> kernel/bpf/kthread.c:269:19: sparse: sparse: Initializer entry defined twice
   kernel/bpf/kthread.c:269:19: sparse:   also defined here

vim +269 kernel/bpf/kthread.c

77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  233  
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  234  /**
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  235   * bpf_kthread_create - Create a kernel thread that runs a BPF callback
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  236   * @callback_fn: the thread's body, run once; its return ends the thread
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  237   * @arg: passed to @callback_fn as its only argument
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  238   * @flags: must be 0
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  239   * @aux: the calling program, set by the verifier
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  240   *
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  241   * Creates a kernel thread named bpfk/<program id>:<index> without starting it,
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  242   * the index counting the program's creations so that its threads are told
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  243   * apart in ps, top and traces; the prefix is short so that both numbers fit
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  244   * the comm that tracepoints and perf report as long as they have nine digits
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  245   * between them, where /proc shows the full name in any case. bpf_kthread_start()
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  246   * runs @callback_fn on it with @arg. The thread ends when the callback returns,
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  247   * when bpf_kthread_stop() stops it, or with the last reference on the program
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  248   * that created it. A thread whose callback has returned keeps its return value
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  249   * until bpf_kthread_stop() collects it.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  250   *
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  251   * The creation waits for kthreadd with migration enabled, so the caller may
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  252   * return on another CPU.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  253   *
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  254   * Return: the thread's task with a reference the program must release, or NULL
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  255   * if @flags is not 0, the thread could not be created, or the program is being
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  256   * freed.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  257   */
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  258  __bpf_kfunc struct task_struct *bpf_kthread_create(int (callback_fn)(u64 arg), u64 arg,
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  259  						   u64 flags, struct bpf_prog_aux *aux)
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  260  {
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  261  	struct bpf_kthread *kthread;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  262  	unsigned long irqflags;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  263  	struct task_struct *task;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  264  	struct bpf_prog *prog;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  265  
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  266  	if (flags)
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  267  		return NULL;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  268  
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22 @269  	kthread = kzalloc_obj(*kthread, GFP_KERNEL_ACCOUNT);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  270  	if (!kthread)
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  271  		return NULL;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  272  	kthread->aux = aux;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  273  	kthread->callback_fn = callback_fn;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  274  	kthread->arg = arg;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  275  
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  276  	/*
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  277  	 * The creation waits for kthreadd, and kthreadd's fork takes the
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  278  	 * threadgroup rwsem that a cgroup move of this task holds while it
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  279  	 * waits for this task to enable migration: see the comment at the top.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  280  	 */
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  281  	migrate_enable();
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  282  	task = kthread_create(bpf_kthread_fn, kthread, "bpfk/%u:%u", aux->id,
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  283  			      atomic_fetch_inc(&aux->kthread_seq));
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  284  	if (IS_ERR(task)) {
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  285  		bpf_kthread_wait_end(aux);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  286  		kfree(kthread);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  287  		return NULL;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  288  	}
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  289  	kthread->task = get_task_struct(task);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  290  	/*
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  291  	 * The program's reference is the kind bpf_task_acquire() takes and
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  292  	 * bpf_task_release() drops; the object's own, above, is the kind
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  293  	 * kthread_stop_put() drops. Take it before the thread is published:
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  294  	 * from then on any program may stop it, and a stopped thread's exit
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  295  	 * drops the last reference the task had of its own.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  296  	 */
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  297  	refcount_inc(&task->rcu_users);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  298  
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  299  	/*
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  300  	 * Run the thread up to its park. The generic kthread prologue, which
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  301  	 * runs first, resets the affinity to the default for the thread's
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  302  	 * node, so that an affinity set from now on sticks.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  303  	 */
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  304  	kthread_park(task);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  305  	bpf_kthread_wait_end(aux);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  306  
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  307  	/*
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  308  	 * Publish the thread while the program has a reference left to take.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  309  	 * Once it has none, the release of its last reference is pending or
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  310  	 * under way, and a thread published after that release looked would
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  311  	 * survive the program. The reference taken here is dropped again at
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  312  	 * once: the release cannot start before it is, and the thread is on
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  313  	 * the lists by then.
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  314  	 */
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  315  	raw_spin_lock_irqsave(&bpf_kthreads_lock, irqflags);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  316  	prog = bpf_prog_inc_not_zero(aux->prog);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  317  	if (IS_ERR(prog)) {
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  318  		raw_spin_unlock_irqrestore(&bpf_kthreads_lock, irqflags);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  319  		migrate_enable();
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  320  		bpf_kthread_stop_and_free(kthread);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  321  		bpf_kthread_wait_end(aux);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  322  		put_task_struct_rcu_user(task);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  323  		return NULL;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  324  	}
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  325  	list_add_tail(&kthread->node, &bpf_kthreads);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  326  	list_add_tail(&kthread->prog_node, &aux->kthreads);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  327  	raw_spin_unlock_irqrestore(&bpf_kthreads_lock, irqflags);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  328  	bpf_prog_put(prog);
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  329  	return task;
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  330  }
77abcab07231b6d Kumar Kartikeya Dwivedi 2026-10-22  331  

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

                 reply	other threads:[~2026-12-03 23:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261204005014.pxLkWuMq-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=oe-kbuild@lists.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.