[ovs-dev] [PATCH net-next 2/2] net: openvswitch: make masks cache size configurable

kernel test robot lkp at intel.com
Wed Jul 22 17:40:55 UTC 2020


Hi Eelco,

Thank you for the patch! Perhaps something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Eelco-Chaudron/net-openvswitch-masks-cache-enhancements/20200722-163017
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git fa56a987449bcf4c1cb68369a187af3515b85c78
config: x86_64-randconfig-s022-20200719 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-49-g707c5017-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>


sparse warnings: (new ones prefixed by >>)

>> net/openvswitch/flow_table.c:376:23: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct mask_cache_entry *cache @@     got void [noderef] __percpu * @@
>> net/openvswitch/flow_table.c:376:23: sparse:     expected struct mask_cache_entry *cache
>> net/openvswitch/flow_table.c:376:23: sparse:     got void [noderef] __percpu *
>> net/openvswitch/flow_table.c:386:25: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct mask_cache_entry [noderef] __percpu *mask_cache @@     got struct mask_cache_entry *cache @@
>> net/openvswitch/flow_table.c:386:25: sparse:     expected struct mask_cache_entry [noderef] __percpu *mask_cache
>> net/openvswitch/flow_table.c:386:25: sparse:     got struct mask_cache_entry *cache
>> net/openvswitch/flow_table.c:411:27: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct mask_cache [noderef] __rcu *mask_cache @@     got struct mask_cache * @@
>> net/openvswitch/flow_table.c:411:27: sparse:     expected struct mask_cache [noderef] __rcu *mask_cache
>> net/openvswitch/flow_table.c:411:27: sparse:     got struct mask_cache *
>> net/openvswitch/flow_table.c:440:35: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct mask_cache *mc @@     got struct mask_cache [noderef] __rcu *mask_cache @@
>> net/openvswitch/flow_table.c:440:35: sparse:     expected struct mask_cache *mc
>> net/openvswitch/flow_table.c:440:35: sparse:     got struct mask_cache [noderef] __rcu *mask_cache
   net/openvswitch/flow_table.c:517:24: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct callback_head *head @@     got struct callback_head [noderef] __rcu * @@
   net/openvswitch/flow_table.c:517:24: sparse:     expected struct callback_head *head
   net/openvswitch/flow_table.c:517:24: sparse:     got struct callback_head [noderef] __rcu *
   net/openvswitch/flow_table.c:518:24: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct callback_head *head @@     got struct callback_head [noderef] __rcu * @@
   net/openvswitch/flow_table.c:518:24: sparse:     expected struct callback_head *head
   net/openvswitch/flow_table.c:518:24: sparse:     got struct callback_head [noderef] __rcu *
   net/openvswitch/flow_table.c:1166:42: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct sw_flow_mask [noderef] __rcu * @@     got struct sw_flow_mask * @@
   net/openvswitch/flow_table.c:1166:42: sparse:     expected struct sw_flow_mask [noderef] __rcu *
   net/openvswitch/flow_table.c:1166:42: sparse:     got struct sw_flow_mask *

vim +376 net/openvswitch/flow_table.c

   357	
   358	static struct mask_cache *tbl_mask_cache_alloc(u32 size)
   359	{
   360		struct mask_cache_entry *cache = NULL;
   361		struct mask_cache *new;
   362	
   363		/* Only allow size to be 0, or a power of 2, and does not exceed
   364		 * percpu allocation size.
   365		 */
   366		if ((size & (size - 1)) != 0 ||
   367		    (size * sizeof(struct mask_cache_entry)) > PCPU_MIN_UNIT_SIZE)
   368			return NULL;
   369	
   370		new = kzalloc(sizeof(*new), GFP_KERNEL);
   371		if (!new)
   372			return NULL;
   373	
   374		new->cache_size = size;
   375		if (new->cache_size > 0) {
 > 376			cache = __alloc_percpu(sizeof(struct mask_cache_entry) *
   377					       new->cache_size,
   378					       __alignof__(struct mask_cache_entry));
   379	
   380			if (!cache) {
   381				kfree(new);
   382				return NULL;
   383			}
   384		}
   385	
 > 386		new->mask_cache = cache;
   387		return new;
   388	}
   389	
   390	void ovs_flow_tbl_masks_cache_resize(struct flow_table *table, u32 size)
   391	{
   392		struct mask_cache *mc = rcu_dereference(table->mask_cache);
   393		struct mask_cache *new;
   394	
   395		if (size == mc->cache_size || (size & (size - 1)) != 0)
   396			return;
   397	
   398		new = tbl_mask_cache_alloc(size);
   399		if (!new)
   400			return;
   401	
   402		rcu_assign_pointer(table->mask_cache, new);
   403		call_rcu(&mc->rcu, mask_cache_rcu_cb);
   404	}
   405	
   406	int ovs_flow_tbl_init(struct flow_table *table)
   407	{
   408		struct table_instance *ti, *ufid_ti;
   409		struct mask_array *ma;
   410	
 > 411		table->mask_cache = tbl_mask_cache_alloc(MC_DEFAULT_HASH_ENTRIES);
   412		if (!table->mask_cache)
   413			return -ENOMEM;
   414	
   415		ma = tbl_mask_array_alloc(MASK_ARRAY_SIZE_MIN);
   416		if (!ma)
   417			goto free_mask_cache;
   418	
   419		ti = table_instance_alloc(TBL_MIN_BUCKETS);
   420		if (!ti)
   421			goto free_mask_array;
   422	
   423		ufid_ti = table_instance_alloc(TBL_MIN_BUCKETS);
   424		if (!ufid_ti)
   425			goto free_ti;
   426	
   427		rcu_assign_pointer(table->ti, ti);
   428		rcu_assign_pointer(table->ufid_ti, ufid_ti);
   429		rcu_assign_pointer(table->mask_array, ma);
   430		table->last_rehash = jiffies;
   431		table->count = 0;
   432		table->ufid_count = 0;
   433		return 0;
   434	
   435	free_ti:
   436		__table_instance_destroy(ti);
   437	free_mask_array:
   438		__mask_array_destroy(ma);
   439	free_mask_cache:
 > 440		__mask_cache_destroy(table->mask_cache);
   441		return -ENOMEM;
   442	}
   443	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


More information about the dev mailing list