[android-common:android16-6.12 12/12] kernel/sched/test_ksched_football.c:55:10: sparse: sparse: symbol 'players_ready' was not declared. Should it be static?

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild-all
Message-ID <[email protected]>
tree:   https://android.googlesource.com/kernel/common android16-6.12
head:   0fd55a309793adc6b8cddb5c29e80caa545ba4bb
commit: 84f4417638e9588ebcb43c4ed0280d097c46abf9 [12/12] ANDROID: sched: Initial ksched_football test implementation
config: x86_64-randconfig-r111-20260716 (https://download.01.org/0day-ci/archive/20260720/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260720/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)
>> kernel/sched/test_ksched_football.c:55:10: sparse: sparse: symbol 'players_ready' was not declared. Should it be static?
>> kernel/sched/test_ksched_football.c:56:10: sparse: sparse: symbol 'ball_pos' was not declared. Should it be static?
>> kernel/sched/test_ksched_football.c:57:15: sparse: sparse: symbol 'players_per_team' was not declared. Should it be static?
>> kernel/sched/test_ksched_football.c:58:6: sparse: sparse: symbol 'game_over' was not declared. Should it be static?
>> kernel/sched/test_ksched_football.c:78:17: sparse: sparse: symbol 'mutex_low_list' was not declared. Should it be static?
>> kernel/sched/test_ksched_football.c:79:17: sparse: sparse: symbol 'mutex_mid_list' was not declared. Should it be static?
>> kernel/sched/test_ksched_football.c:216:19: sparse: sparse: symbol 'referee_done' was not declared. Should it be static?

vim +/players_ready +55 kernel/sched/test_ksched_football.c

    54	
  > 55	atomic_t players_ready;
  > 56	atomic_t ball_pos;
  > 57	unsigned long players_per_team;
  > 58	bool game_over;
    59	
    60	#define DEF_GAME_TIME		10
    61	#define CHECKIN_TIMEOUT		30
    62	
    63	#define REF_PRIO		20
    64	#define FAN_PRIO		15
    65	#define DEF_HI_PRIO		10
    66	#define OFF_PRIO		5
    67	#define DEF_MID_PRIO		3
    68	#define DEF_LOW_PRIO		2
    69	
    70	#ifdef CONFIG_SCHED_PROXY_EXEC
    71	struct mutex *mutex_low_list;
    72	struct mutex *mutex_mid_list;
    73	#define test_lock_init(x)	mutex_init(x)
    74	#define TEST_LOCK_SIZE		sizeof(struct mutex)
    75	#define test_lock(x)		mutex_lock(x)
    76	#define test_unlock(x)		mutex_unlock(x)
    77	#else
  > 78	struct rt_mutex *mutex_low_list;
  > 79	struct rt_mutex *mutex_mid_list;
    80	#define test_lock_init(x)	rt_mutex_init(x)
    81	#define TEST_LOCK_SIZE		sizeof(struct rt_mutex)
    82	#define test_lock(x)		rt_mutex_lock(x)
    83	#define test_unlock(x)		rt_mutex_unlock(x)
    84	#endif
    85	
    86	static struct task_struct *create_fifo_thread(int (*threadfn)(void *data),
    87						      void *data, char *name, int prio)
    88	{
    89		struct task_struct *kth;
    90		struct sched_attr attr = {
    91			.size		= sizeof(struct sched_attr),
    92			.sched_policy	= SCHED_FIFO,
    93			.sched_nice	= 0,
    94			.sched_priority	= prio,
    95		};
    96		int ret;
    97	
    98		kth = kthread_create(threadfn, data, name);
    99		if (IS_ERR(kth)) {
   100			pr_warn("%s: Error, kthread_create %s failed\n", __func__,
   101				name);
   102			return kth;
   103		}
   104		ret = sched_setattr_nocheck(kth, &attr);
   105		if (ret) {
   106			kthread_stop(kth);
   107			pr_warn("%s: Error, failed to set SCHED_FIFO for %s\n",
   108				__func__, name);
   109			return ERR_PTR(ret);
   110		}
   111	
   112		wake_up_process(kth);
   113		return kth;
   114	}
   115	
   116	static int spawn_players(int (*threadfn)(void *data), char *name, int prio)
   117	{
   118		unsigned long current_players, start, i;
   119		struct task_struct *kth;
   120	
   121		current_players = atomic_read(&players_ready);
   122		/* Create players_per_team threads */
   123		for (i = 0; i < players_per_team; i++) {
   124			kth = create_fifo_thread(threadfn, (void *)i, name, prio);
   125			if (IS_ERR(kth))
   126				return -1;
   127		}
   128	
   129		start = jiffies;
   130		/* Wait for players_per_team threads to check in */
   131		while (atomic_read(&players_ready) < current_players + players_per_team) {
   132			msleep(1);
   133			if (jiffies - start > CHECKIN_TIMEOUT * HZ) {
   134				pr_err("%s: Error, %s players took too long to checkin "
   135				       "(only %ld of %ld checked in)\n", __func__, name,
   136				       (long)atomic_read(&players_ready),
   137				       current_players + players_per_team);
   138				return -1;
   139			}
   140		}
   141		return 0;
   142	}
   143	
   144	static int defense_low_thread(void *arg)
   145	{
   146		long tnum = (long)arg;
   147	
   148		atomic_inc(&players_ready);
   149		test_lock(&mutex_low_list[tnum]);
   150		while (!READ_ONCE(game_over)) {
   151			if (kthread_should_stop())
   152				break;
   153			schedule();
   154		}
   155		test_unlock(&mutex_low_list[tnum]);
   156		return 0;
   157	}
   158	
   159	static int defense_mid_thread(void *arg)
   160	{
   161		long tnum = (long)arg;
   162	
   163		atomic_inc(&players_ready);
   164		test_lock(&mutex_mid_list[tnum]);
   165		test_lock(&mutex_low_list[tnum]);
   166		while (!READ_ONCE(game_over)) {
   167			if (kthread_should_stop())
   168				break;
   169			schedule();
   170		}
   171		test_unlock(&mutex_low_list[tnum]);
   172		test_unlock(&mutex_mid_list[tnum]);
   173		return 0;
   174	}
   175	
   176	static int offense_thread(void *arg)
   177	{
   178		atomic_inc(&players_ready);
   179		while (!READ_ONCE(game_over)) {
   180			if (kthread_should_stop())
   181				break;
   182			schedule();
   183			atomic_inc(&ball_pos);
   184		}
   185		return 0;
   186	}
   187	
   188	static int defense_hi_thread(void *arg)
   189	{
   190		long tnum = (long)arg;
   191	
   192		atomic_inc(&players_ready);
   193		test_lock(&mutex_mid_list[tnum]);
   194		while (!READ_ONCE(game_over)) {
   195			if (kthread_should_stop())
   196				break;
   197			schedule();
   198		}
   199		test_unlock(&mutex_mid_list[tnum]);
   200		return 0;
   201	}
   202	
   203	static int crazy_fan_thread(void *arg)
   204	{
   205		atomic_inc(&players_ready);
   206		while (!READ_ONCE(game_over)) {
   207			if (kthread_should_stop())
   208				break;
   209			schedule();
   210			udelay(1000);
   211			msleep(2);
   212		}
   213		return 0;
   214	}
   215	
 > 216	struct completion referee_done;
   217	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.