public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [rcu:boqun-dev/hazptr 1/1] kernel/rcu/hazptr_test.c:18:8: warning: incompatible integer to pointer conversion assigning to 'struct callback_head *' from 'int'
@ 2024-05-20 23:20 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-05-20 23:20 UTC (permalink / raw)
  To: Boqun Feng; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git boqun-dev/hazptr
head:   ca2ab86d71c6d322c87127363aa4b665012a0ac2
commit: ca2ab86d71c6d322c87127363aa4b665012a0ac2 [1/1] WIP
config: arm-defconfig (https://download.01.org/0day-ci/archive/20240521/202405210704.NDdG0x1S-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240521/202405210704.NDdG0x1S-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/202405210704.NDdG0x1S-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/rcu/hazptr_test.c:8:2: error: implicit declaration of function 'kfree' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           kfree(head);
           ^
   kernel/rcu/hazptr_test.c:18:10: error: implicit declaration of function 'kzalloc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           dummy = kzalloc(sizeof(*dummy), GFP_KERNEL);
                   ^
>> kernel/rcu/hazptr_test.c:18:8: warning: incompatible integer to pointer conversion assigning to 'struct callback_head *' from 'int' [-Wint-conversion]
           dummy = kzalloc(sizeof(*dummy), GFP_KERNEL);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/rcu/hazptr_test.c:19:8: warning: incompatible integer to pointer conversion assigning to 'struct callback_head *' from 'int' [-Wint-conversion]
           other = kzalloc(sizeof(*dummy), GFP_KERNEL);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   2 warnings and 2 errors generated.


vim +18 kernel/rcu/hazptr_test.c

    10	
    11	static void simple(void)
    12	{
    13		struct hazptr_context ctx;
    14		struct callback_head *dummy, *tmp, *other;
    15		hazptr_t *hptr;
    16		hazptr_t *hptr2;
    17	
  > 18		dummy = kzalloc(sizeof(*dummy), GFP_KERNEL);
    19		other = kzalloc(sizeof(*dummy), GFP_KERNEL);
    20	
    21		if (!dummy || !other) {
    22			printk("allocation failed, skip test\n");
    23			return;
    24		}
    25	
    26		init_hazptr_context(&ctx);
    27		hptr = hazptr_alloc(&ctx);
    28		BUG_ON(!hptr);
    29	
    30		// Get a second hptr.
    31		hptr2 = hazptr_alloc(&ctx);
    32		BUG_ON(!hptr2);
    33	
    34		// No one is modifying 'dummy', protection must succeed.
    35		BUG_ON(!__hazptr_tryprotect(hptr, (void **)&dummy, 0));
    36	
    37		// Simulate changing a global pointer.
    38		tmp = dummy;
    39		WRITE_ONCE(dummy, other);
    40	
    41		// Callback will run after no active readers.
    42		printk("callback added, %px\n", tmp);
    43		call_hazptr(tmp, simple_func);
    44	
    45		// Simulate changing a global pointer.
    46		tmp = dummy;
    47		WRITE_ONCE(dummy, other);
    48	
    49		// No one is modifying 'dummy', protection must succeed.
    50		BUG_ON(!__hazptr_tryprotect(hptr2, (void **)&dummy, 0));
    51	
    52		// The above callback should run after this.
    53		hazptr_clear(hptr);
    54		printk("first reader is out\n");
    55	
    56		for (int i = 0; i < 10; i++)
    57			schedule(); // yield a few times.
    58	
    59		printk("callback added, %px\n", tmp);
    60		call_hazptr(tmp, simple_func);
    61	
    62		cleanup_hazptr_context(&ctx);
    63		printk("no reader here\n");
    64	
    65		for (int i = 0; i < 10; i++)
    66			schedule(); // yield a few times.
    67	}
    68	

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-20 23:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-20 23:20 [rcu:boqun-dev/hazptr 1/1] kernel/rcu/hazptr_test.c:18:8: warning: incompatible integer to pointer conversion assigning to 'struct callback_head *' from 'int' kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox