All of lore.kernel.org
 help / color / mirror / Atom feed
* [android-common:android16-6.12 12/12] fs/bcachefs/btree_key_cache.c:759:9: sparse: sparse: dereference of noderef expression
@ 2026-07-19  1:56 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-07-19  1:56 UTC (permalink / raw)
  To: cros-kernel-buildreports; +Cc: oe-kbuild-all

tree:   https://android.googlesource.com/kernel/common android16-6.12
head:   0fd55a309793adc6b8cddb5c29e80caa545ba4bb
commit: f2bfe7e83765f3bd84382cc75d8ac3ca619de39a [12/12] bcachefs: Rip out freelists from btree key cache
config: x86_64-randconfig-r111-20260716 (https://download.01.org/0day-ci/archive/20260719/202607190905.jry1tu6N-lkp@intel.com/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/20260719/202607190905.jry1tu6N-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
| Fixes: f2bfe7e83765 ("bcachefs: Rip out freelists from btree key cache")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202607190905.jry1tu6N-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   fs/bcachefs/btree_key_cache.c: note: in included file:
   fs/bcachefs/bcachefs.h:996:9: sparse: sparse: array of flexible structures
   fs/bcachefs/btree_key_cache.c:688:32: sparse: sparse: context imbalance in 'bch2_fs_btree_key_cache_exit' - different lock contexts for basic block
>> fs/bcachefs/btree_key_cache.c:759:9: sparse: sparse: dereference of noderef expression

vim +759 fs/bcachefs/btree_key_cache.c

   673	
   674	void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc)
   675	{
   676		struct bch_fs *c = container_of(bc, struct bch_fs, btree_key_cache);
   677		struct bucket_table *tbl;
   678		struct bkey_cached *ck;
   679		struct rhash_head *pos;
   680		LIST_HEAD(items);
   681		unsigned i;
   682	
   683		shrinker_free(bc->shrink);
   684	
   685		/*
   686		 * The loop is needed to guard against racing with rehash:
   687		 */
 > 688		while (atomic_long_read(&bc->nr_keys)) {
   689			rcu_read_lock();
   690			tbl = rht_dereference_rcu(bc->table.tbl, &bc->table);
   691			if (tbl) {
   692				if (tbl->nest) {
   693					/* wait for in progress rehash */
   694					rcu_read_unlock();
   695					mutex_lock(&bc->table.mutex);
   696					mutex_unlock(&bc->table.mutex);
   697					rcu_read_lock();
   698					continue;
   699				}
   700				for (i = 0; i < tbl->size; i++)
   701					while (pos = rht_ptr_rcu(&tbl->buckets[i]), !rht_is_a_nulls(pos)) {
   702						ck = container_of(pos, struct bkey_cached, hash);
   703						BUG_ON(!bkey_cached_evict(bc, ck));
   704						kfree(ck->k);
   705						kmem_cache_free(bch2_key_cache, ck);
   706					}
   707			}
   708			rcu_read_unlock();
   709		}
   710	
   711		if (atomic_long_read(&bc->nr_dirty) &&
   712		    !bch2_journal_error(&c->journal) &&
   713		    test_bit(BCH_FS_was_rw, &c->flags))
   714			panic("btree key cache shutdown error: nr_dirty nonzero (%li)\n",
   715			      atomic_long_read(&bc->nr_dirty));
   716	
   717		if (atomic_long_read(&bc->nr_keys))
   718			panic("btree key cache shutdown error: nr_keys nonzero (%li)\n",
   719			      atomic_long_read(&bc->nr_keys));
   720	
   721		if (bc->table_init_done)
   722			rhashtable_destroy(&bc->table);
   723	}
   724	
   725	void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c)
   726	{
   727	}
   728	
   729	int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc)
   730	{
   731		struct bch_fs *c = container_of(bc, struct bch_fs, btree_key_cache);
   732		struct shrinker *shrink;
   733	
   734		if (rhashtable_init(&bc->table, &bch2_btree_key_cache_params))
   735			return -BCH_ERR_ENOMEM_fs_btree_cache_init;
   736	
   737		bc->table_init_done = true;
   738	
   739		shrink = shrinker_alloc(0, "%s-btree_key_cache", c->name);
   740		if (!shrink)
   741			return -BCH_ERR_ENOMEM_fs_btree_cache_init;
   742		bc->shrink = shrink;
   743		shrink->count_objects	= bch2_btree_key_cache_count;
   744		shrink->scan_objects	= bch2_btree_key_cache_scan;
   745		shrink->batch		= 1 << 14;
   746		shrink->seeks		= 0;
   747		shrink->private_data	= c;
   748		shrinker_register(shrink);
   749		return 0;
   750	}
   751	
   752	void bch2_btree_key_cache_to_text(struct printbuf *out, struct btree_key_cache *bc)
   753	{
   754		printbuf_tabstop_push(out, 24);
   755		printbuf_tabstop_push(out, 12);
   756	
   757		prt_printf(out, "keys:\t%lu\r\n",		atomic_long_read(&bc->nr_keys));
   758		prt_printf(out, "dirty:\t%lu\r\n",		atomic_long_read(&bc->nr_dirty));
 > 759		prt_printf(out, "table size:\t%u\r\n",		bc->table.tbl->size);
   760	
   761		prt_printf(out, "\nshrinker:\n");
   762		prt_printf(out, "requested_to_free:\t%lu\r\n",	bc->requested_to_free);
   763		prt_printf(out, "freed:\t%lu\r\n",		bc->freed);
   764		prt_printf(out, "skipped_dirty:\t%lu\r\n",	bc->skipped_dirty);
   765		prt_printf(out, "skipped_accessed:\t%lu\r\n",	bc->skipped_accessed);
   766		prt_printf(out, "skipped_lock_fail:\t%lu\r\n",	bc->skipped_lock_fail);
   767	}
   768	

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [android-common:android16-6.12 12/12] fs/bcachefs/btree_key_cache.c:759:9: sparse: sparse: dereference of noderef expression
@ 2026-07-19 18:54 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-07-19 18:54 UTC (permalink / raw)
  To: cros-kernel-buildreports; +Cc: oe-kbuild-all

tree:   https://android.googlesource.com/kernel/common android16-6.12
head:   0fd55a309793adc6b8cddb5c29e80caa545ba4bb
commit: f2bfe7e83765f3bd84382cc75d8ac3ca619de39a [12/12] bcachefs: Rip out freelists from btree key cache
config: x86_64-randconfig-r111-20260716 (https://download.01.org/0day-ci/archive/20260720/202607200235.qLbdM3rk-lkp@intel.com/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/202607200235.qLbdM3rk-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
| Fixes: f2bfe7e83765 ("bcachefs: Rip out freelists from btree key cache")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202607200235.qLbdM3rk-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   fs/bcachefs/btree_key_cache.c: note: in included file:
   fs/bcachefs/bcachefs.h:996:9: sparse: sparse: array of flexible structures
   fs/bcachefs/btree_key_cache.c:688:32: sparse: sparse: context imbalance in 'bch2_fs_btree_key_cache_exit' - different lock contexts for basic block
>> fs/bcachefs/btree_key_cache.c:759:9: sparse: sparse: dereference of noderef expression

vim +759 fs/bcachefs/btree_key_cache.c

   673	
   674	void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc)
   675	{
   676		struct bch_fs *c = container_of(bc, struct bch_fs, btree_key_cache);
   677		struct bucket_table *tbl;
   678		struct bkey_cached *ck;
   679		struct rhash_head *pos;
   680		LIST_HEAD(items);
   681		unsigned i;
   682	
   683		shrinker_free(bc->shrink);
   684	
   685		/*
   686		 * The loop is needed to guard against racing with rehash:
   687		 */
 > 688		while (atomic_long_read(&bc->nr_keys)) {
   689			rcu_read_lock();
   690			tbl = rht_dereference_rcu(bc->table.tbl, &bc->table);
   691			if (tbl) {
   692				if (tbl->nest) {
   693					/* wait for in progress rehash */
   694					rcu_read_unlock();
   695					mutex_lock(&bc->table.mutex);
   696					mutex_unlock(&bc->table.mutex);
   697					rcu_read_lock();
   698					continue;
   699				}
   700				for (i = 0; i < tbl->size; i++)
   701					while (pos = rht_ptr_rcu(&tbl->buckets[i]), !rht_is_a_nulls(pos)) {
   702						ck = container_of(pos, struct bkey_cached, hash);
   703						BUG_ON(!bkey_cached_evict(bc, ck));
   704						kfree(ck->k);
   705						kmem_cache_free(bch2_key_cache, ck);
   706					}
   707			}
   708			rcu_read_unlock();
   709		}
   710	
   711		if (atomic_long_read(&bc->nr_dirty) &&
   712		    !bch2_journal_error(&c->journal) &&
   713		    test_bit(BCH_FS_was_rw, &c->flags))
   714			panic("btree key cache shutdown error: nr_dirty nonzero (%li)\n",
   715			      atomic_long_read(&bc->nr_dirty));
   716	
   717		if (atomic_long_read(&bc->nr_keys))
   718			panic("btree key cache shutdown error: nr_keys nonzero (%li)\n",
   719			      atomic_long_read(&bc->nr_keys));
   720	
   721		if (bc->table_init_done)
   722			rhashtable_destroy(&bc->table);
   723	}
   724	
   725	void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c)
   726	{
   727	}
   728	
   729	int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc)
   730	{
   731		struct bch_fs *c = container_of(bc, struct bch_fs, btree_key_cache);
   732		struct shrinker *shrink;
   733	
   734		if (rhashtable_init(&bc->table, &bch2_btree_key_cache_params))
   735			return -BCH_ERR_ENOMEM_fs_btree_cache_init;
   736	
   737		bc->table_init_done = true;
   738	
   739		shrink = shrinker_alloc(0, "%s-btree_key_cache", c->name);
   740		if (!shrink)
   741			return -BCH_ERR_ENOMEM_fs_btree_cache_init;
   742		bc->shrink = shrink;
   743		shrink->count_objects	= bch2_btree_key_cache_count;
   744		shrink->scan_objects	= bch2_btree_key_cache_scan;
   745		shrink->batch		= 1 << 14;
   746		shrink->seeks		= 0;
   747		shrink->private_data	= c;
   748		shrinker_register(shrink);
   749		return 0;
   750	}
   751	
   752	void bch2_btree_key_cache_to_text(struct printbuf *out, struct btree_key_cache *bc)
   753	{
   754		printbuf_tabstop_push(out, 24);
   755		printbuf_tabstop_push(out, 12);
   756	
   757		prt_printf(out, "keys:\t%lu\r\n",		atomic_long_read(&bc->nr_keys));
   758		prt_printf(out, "dirty:\t%lu\r\n",		atomic_long_read(&bc->nr_dirty));
 > 759		prt_printf(out, "table size:\t%u\r\n",		bc->table.tbl->size);
   760	
   761		prt_printf(out, "\nshrinker:\n");
   762		prt_printf(out, "requested_to_free:\t%lu\r\n",	bc->requested_to_free);
   763		prt_printf(out, "freed:\t%lu\r\n",		bc->freed);
   764		prt_printf(out, "skipped_dirty:\t%lu\r\n",	bc->skipped_dirty);
   765		prt_printf(out, "skipped_accessed:\t%lu\r\n",	bc->skipped_accessed);
   766		prt_printf(out, "skipped_lock_fail:\t%lu\r\n",	bc->skipped_lock_fail);
   767	}
   768	

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-19 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-19  1:56 [android-common:android16-6.12 12/12] fs/bcachefs/btree_key_cache.c:759:9: sparse: sparse: dereference of noderef expression kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2026-07-19 18:54 kernel test robot

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.