All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: warning: Value stored to 'cleaned_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
@ 2022-01-08 17:42 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-01-08 17:42 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 26765 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
CC: Tony Nguyen <anthony.l.nguyen@intel.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d1587f7bfe9a0f97a75d42ac1489aeda551106bc
commit: f12738b6ec063b1b63ff2232fd203d13a6ec2468 i40e: remove unnecessary cleaned_count updates
date:   11 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 11 months ago
config: x86_64-randconfig-c007-20220101 (https://download.01.org/0day-ci/archive/20220109/202201090152.YwLraiRy-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c054402170cd8466683a20385befc0523aba3359)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f12738b6ec063b1b63ff2232fd203d13a6ec2468
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout f12738b6ec063b1b63ff2232fd203d13a6ec2468
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
                           ^         ~~~~
   drivers/video/fbdev/core/fbcvt.c:262:4: note: Value stored to 'offset' is never read
                           offset += read;
                           ^         ~~~~
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   drivers/i2c/busses/i2c-sis96x.c:88:8: warning: Although the value stored to 'temp' is used in the enclosing expression, the value is never actually read from 'temp' [clang-analyzer-deadcode.DeadStores]
           if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
                 ^      ~~~~~~~~~~~~~~~~~~~~
   drivers/i2c/busses/i2c-sis96x.c:88:8: note: Although the value stored to 'temp' is used in the enclosing expression, the value is never actually read from 'temp'
           if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
                 ^      ~~~~~~~~~~~~~~~~~~~~
   drivers/i2c/busses/i2c-sis96x.c:97:9: warning: Although the value stored to 'temp' is used in the enclosing expression, the value is never actually read from 'temp' [clang-analyzer-deadcode.DeadStores]
                   if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
                         ^      ~~~~~~~~~~~~~~~~~~~~
   drivers/i2c/busses/i2c-sis96x.c:97:9: note: Although the value stored to 'temp' is used in the enclosing expression, the value is never actually read from 'temp'
                   if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
                         ^      ~~~~~~~~~~~~~~~~~~~~
   drivers/i2c/busses/i2c-sis96x.c:141:7: warning: Although the value stored to 'temp' is used in the enclosing expression, the value is never actually read from 'temp' [clang-analyzer-deadcode.DeadStores]
           if ((temp = sis96x_read(SMB_STS))) {
                ^      ~~~~~~~~~~~~~~~~~~~~
   drivers/i2c/busses/i2c-sis96x.c:141:7: note: Although the value stored to 'temp' is used in the enclosing expression, the value is never actually read from 'temp'
           if ((temp = sis96x_read(SMB_STS))) {
                ^      ~~~~~~~~~~~~~~~~~~~~
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   drivers/acpi/battery.c:1192:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
           ^~~~~~
   drivers/acpi/battery.c:1192:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
           strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
           ^~~~~~
   drivers/acpi/battery.c:1193:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
           ^~~~~~
   drivers/acpi/battery.c:1193:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
           strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
           ^~~~~~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
>> drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: warning: Value stored to 'cleaned_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
               ^~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: note: Value stored to 'cleaned_count' during its initialization is never read
           u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
               ^~~~~~~~~~~~~
   Suppressed 15 warnings (15 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   drivers/media/dvb-frontends/cxd2820r_t.c:14:21: warning: Value stored to 'client' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:14:21: note: Value stored to 'client' during its initialization is never read
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:130:21: warning: Value stored to 'client' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:130:21: note: Value stored to 'client' during its initialization is never read
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:250:21: warning: Value stored to 'client' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:250:21: note: Value stored to 'client' during its initialization is never read
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:375:21: warning: Value stored to 'client' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:375:21: note: Value stored to 'client' during its initialization is never read
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:393:21: warning: Value stored to 'client' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   drivers/media/dvb-frontends/cxd2820r_t.c:393:21: note: Value stored to 'client' during its initialization is never read
           struct i2c_client *client = priv->client[0];
                              ^~~~~~   ~~~~~~~~~~~~~~~
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   drivers/input/misc/ad714x.c:206:20: warning: Division by zero [clang-analyzer-core.DivideZero]
           return (max_coord / (end_stage - start_stage)) * a_param / b_param;
                             ^
   drivers/input/misc/ad714x.c:948:14: note: Assuming 'i' is >= field 'button_num'
           for (i = 0; i < ad714x->hw->button_num; i++)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:948:2: note: Loop condition is false. Execution continues on line 950
           for (i = 0; i < ad714x->hw->button_num; i++)
           ^
   drivers/input/misc/ad714x.c:950:14: note: Assuming 'i' is < field 'slider_num'
           for (i = 0; i < ad714x->hw->slider_num; i++)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:950:2: note: Loop condition is true.  Entering loop body
           for (i = 0; i < ad714x->hw->slider_num; i++)
           ^
   drivers/input/misc/ad714x.c:951:3: note: Calling 'ad714x_slider_state_machine'
                   ad714x_slider_state_machine(ad714x, i);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:350:2: note: Control jumps to 'case JITTER:'  at line 362
           switch (sw->state) {
           ^
   drivers/input/misc/ad714x.c:363:7: note: Assuming 'c_state' is equal to 'mask'
                   if (c_state == mask) {
                       ^~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:363:3: note: Taking true branch
                   if (c_state == mask) {
                   ^
   drivers/input/misc/ad714x.c:366:4: note: Calling 'ad714x_slider_cal_abs_pos'
                           ad714x_slider_cal_abs_pos(ad714x, idx);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:296:16: note: Calling 'ad714x_cal_abs_pos'
           sw->abs_pos = ad714x_cal_abs_pos(ad714x, hw->start_stage, hw->end_stage,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:183:6: note: Assuming 'highest_stage' is equal to 'start_stage'
           if (highest_stage == start_stage) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:183:2: note: Taking true branch
           if (highest_stage == start_stage) {
           ^
   drivers/input/misc/ad714x.c:206:20: note: Division by zero
           return (max_coord / (end_stage - start_stage)) * a_param / b_param;
                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:1014:2: warning: Value stored to 'drv_mem' is never read [clang-analyzer-deadcode.DeadStores]
           drv_mem += sizeof(*bt_drv) * ad714x->hw->button_num;
           ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/input/misc/ad714x.c:1014:2: note: Value stored to 'drv_mem' is never read
           drv_mem += sizeof(*bt_drv) * ad714x->hw->button_num;
           ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

vim +/cleaned_count +274 drivers/net/ethernet/intel/i40e/i40e_xsk.c

0a714186d3c0f7 Björn Töpel         2018-08-28  263  
0a714186d3c0f7 Björn Töpel         2018-08-28  264  /**
0a714186d3c0f7 Björn Töpel         2018-08-28  265   * i40e_clean_rx_irq_zc - Consumes Rx packets from the hardware ring
0a714186d3c0f7 Björn Töpel         2018-08-28  266   * @rx_ring: Rx ring
0a714186d3c0f7 Björn Töpel         2018-08-28  267   * @budget: NAPI budget
0a714186d3c0f7 Björn Töpel         2018-08-28  268   *
0a714186d3c0f7 Björn Töpel         2018-08-28  269   * Returns amount of work completed
0a714186d3c0f7 Björn Töpel         2018-08-28  270   **/
0a714186d3c0f7 Björn Töpel         2018-08-28  271  int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
0a714186d3c0f7 Björn Töpel         2018-08-28  272  {
0a714186d3c0f7 Björn Töpel         2018-08-28  273  	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
0a714186d3c0f7 Björn Töpel         2018-08-28 @274  	u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  275  	u16 next_to_clean = rx_ring->next_to_clean;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  276  	u16 count_mask = rx_ring->count - 1;
0a714186d3c0f7 Björn Töpel         2018-08-28  277  	unsigned int xdp_res, xdp_xmit = 0;
1773482fd8cecd Dan Carpenter       2020-09-16  278  	bool failure = false;
0a714186d3c0f7 Björn Töpel         2018-08-28  279  	struct sk_buff *skb;
0a714186d3c0f7 Björn Töpel         2018-08-28  280  
0a714186d3c0f7 Björn Töpel         2018-08-28  281  	while (likely(total_rx_packets < (unsigned int)budget)) {
0a714186d3c0f7 Björn Töpel         2018-08-28  282  		union i40e_rx_desc *rx_desc;
3b4f0b66c2b3dc Björn Töpel         2020-05-20  283  		struct xdp_buff **bi;
0a714186d3c0f7 Björn Töpel         2018-08-28  284  		unsigned int size;
0a714186d3c0f7 Björn Töpel         2018-08-28  285  		u64 qword;
0a714186d3c0f7 Björn Töpel         2018-08-28  286  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  287  		rx_desc = I40E_RX_DESC(rx_ring, next_to_clean);
0a714186d3c0f7 Björn Töpel         2018-08-28  288  		qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
0a714186d3c0f7 Björn Töpel         2018-08-28  289  
0a714186d3c0f7 Björn Töpel         2018-08-28  290  		/* This memory barrier is needed to keep us from reading
0a714186d3c0f7 Björn Töpel         2018-08-28  291  		 * any other fields out of the rx_desc until we have
0a714186d3c0f7 Björn Töpel         2018-08-28  292  		 * verified the descriptor has been written back.
0a714186d3c0f7 Björn Töpel         2018-08-28  293  		 */
0a714186d3c0f7 Björn Töpel         2018-08-28  294  		dma_rmb();
0a714186d3c0f7 Björn Töpel         2018-08-28  295  
be1222b585fdc4 Björn Töpel         2020-05-20  296  		if (i40e_rx_is_programming_status(qword)) {
be1222b585fdc4 Björn Töpel         2020-05-20  297  			i40e_clean_programming_status(rx_ring,
be1222b585fdc4 Björn Töpel         2020-05-20  298  						      rx_desc->raw.qword[0],
0a714186d3c0f7 Björn Töpel         2018-08-28  299  						      qword);
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  300  			bi = i40e_rx_bi(rx_ring, next_to_clean);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  301  			xsk_buff_free(*bi);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  302  			*bi = NULL;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  303  			next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  304  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  305  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  306  
0a714186d3c0f7 Björn Töpel         2018-08-28  307  		size = (qword & I40E_RXD_QW1_LENGTH_PBUF_MASK) >>
0a714186d3c0f7 Björn Töpel         2018-08-28  308  		       I40E_RXD_QW1_LENGTH_PBUF_SHIFT;
0a714186d3c0f7 Björn Töpel         2018-08-28  309  		if (!size)
0a714186d3c0f7 Björn Töpel         2018-08-28  310  			break;
0a714186d3c0f7 Björn Töpel         2018-08-28  311  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  312  		bi = i40e_rx_bi(rx_ring, next_to_clean);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  313  		(*bi)->data_end = (*bi)->data + size;
9647c57b11e563 Magnus Karlsson     2020-08-28  314  		xsk_buff_dma_sync_for_cpu(*bi, rx_ring->xsk_pool);
0a714186d3c0f7 Björn Töpel         2018-08-28  315  
3b4f0b66c2b3dc Björn Töpel         2020-05-20  316  		xdp_res = i40e_run_xdp_zc(rx_ring, *bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  317  		if (xdp_res) {
3b4f0b66c2b3dc Björn Töpel         2020-05-20  318  			if (xdp_res & (I40E_XDP_TX | I40E_XDP_REDIR))
0a714186d3c0f7 Björn Töpel         2018-08-28  319  				xdp_xmit |= xdp_res;
3b4f0b66c2b3dc Björn Töpel         2020-05-20  320  			else
3b4f0b66c2b3dc Björn Töpel         2020-05-20  321  				xsk_buff_free(*bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  322  
3b4f0b66c2b3dc Björn Töpel         2020-05-20  323  			*bi = NULL;
0a714186d3c0f7 Björn Töpel         2018-08-28  324  			total_rx_bytes += size;
0a714186d3c0f7 Björn Töpel         2018-08-28  325  			total_rx_packets++;
0a714186d3c0f7 Björn Töpel         2018-08-28  326  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  327  			next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  328  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  329  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  330  
0a714186d3c0f7 Björn Töpel         2018-08-28  331  		/* XDP_PASS path */
0a714186d3c0f7 Björn Töpel         2018-08-28  332  
0a714186d3c0f7 Björn Töpel         2018-08-28  333  		/* NB! We are not checking for errors using
0a714186d3c0f7 Björn Töpel         2018-08-28  334  		 * i40e_test_staterr with
0a714186d3c0f7 Björn Töpel         2018-08-28  335  		 * BIT(I40E_RXD_QW1_ERROR_SHIFT). This is due to that
0a714186d3c0f7 Björn Töpel         2018-08-28  336  		 * SBP is *not* set in PRT_SBPVSI (default not set).
0a714186d3c0f7 Björn Töpel         2018-08-28  337  		 */
3b4f0b66c2b3dc Björn Töpel         2020-05-20  338  		skb = i40e_construct_skb_zc(rx_ring, *bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  339  		if (!skb) {
0a714186d3c0f7 Björn Töpel         2018-08-28  340  			rx_ring->rx_stats.alloc_buff_failed++;
0a714186d3c0f7 Björn Töpel         2018-08-28  341  			break;
0a714186d3c0f7 Björn Töpel         2018-08-28  342  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  343  
7128c834d30e6b Cristian Dumitrescu 2021-01-11  344  		*bi = NULL;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  345  		next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  346  
0a714186d3c0f7 Björn Töpel         2018-08-28  347  		if (eth_skb_pad(skb))
0a714186d3c0f7 Björn Töpel         2018-08-28  348  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  349  
0a714186d3c0f7 Björn Töpel         2018-08-28  350  		total_rx_bytes += skb->len;
0a714186d3c0f7 Björn Töpel         2018-08-28  351  		total_rx_packets++;
0a714186d3c0f7 Björn Töpel         2018-08-28  352  
800b8f637d07cc Michał Mirosław     2018-12-04  353  		i40e_process_skb_fields(rx_ring, rx_desc, skb);
2a508c64ad278d Michał Mirosław     2018-12-04  354  		napi_gro_receive(&rx_ring->q_vector->napi, skb);
0a714186d3c0f7 Björn Töpel         2018-08-28  355  	}
0a714186d3c0f7 Björn Töpel         2018-08-28  356  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  357  	rx_ring->next_to_clean = next_to_clean;
f12738b6ec063b Cristian Dumitrescu 2021-01-14  358  	cleaned_count = (next_to_clean - rx_ring->next_to_use - 1) & count_mask;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  359  
8cbf7414990338 Björn Töpel         2020-08-25  360  	if (cleaned_count >= I40E_RX_BUFFER_WRITE)
8cbf7414990338 Björn Töpel         2020-08-25  361  		failure = !i40e_alloc_rx_buffers_zc(rx_ring, cleaned_count);
8cbf7414990338 Björn Töpel         2020-08-25  362  
0a714186d3c0f7 Björn Töpel         2018-08-28  363  	i40e_finalize_xdp_rx(rx_ring, xdp_xmit);
0a714186d3c0f7 Björn Töpel         2018-08-28  364  	i40e_update_rx_stats(rx_ring, total_rx_bytes, total_rx_packets);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  365  
c4655761d3cf62 Magnus Karlsson     2020-08-28  366  	if (xsk_uses_need_wakeup(rx_ring->xsk_pool)) {
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  367  		if (failure || next_to_clean == rx_ring->next_to_use)
c4655761d3cf62 Magnus Karlsson     2020-08-28  368  			xsk_set_rx_need_wakeup(rx_ring->xsk_pool);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  369  		else
c4655761d3cf62 Magnus Karlsson     2020-08-28  370  			xsk_clear_rx_need_wakeup(rx_ring->xsk_pool);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  371  
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  372  		return (int)total_rx_packets;
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  373  	}
0a714186d3c0f7 Björn Töpel         2018-08-28  374  	return failure ? budget : (int)total_rx_packets;
0a714186d3c0f7 Björn Töpel         2018-08-28  375  }
0a714186d3c0f7 Björn Töpel         2018-08-28  376  

:::::: The code at line 274 was first introduced by commit
:::::: 0a714186d3c0f7c563a03537f98716457c1f5ae0 i40e: add AF_XDP zero-copy Rx support

:::::: TO: Björn Töpel <bjorn.topel@intel.com>
:::::: CC: Alexei Starovoitov <ast@kernel.org>

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

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

* drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: warning: Value stored to 'cleaned_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
@ 2022-01-02  7:45 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-01-02  7:45 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 23413 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
CC: Tony Nguyen <anthony.l.nguyen@intel.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   278218f6778bc7d6f8b67199446c56cec7ebb841
commit: f12738b6ec063b1b63ff2232fd203d13a6ec2468 i40e: remove unnecessary cleaned_count updates
date:   11 months ago
:::::: branch date: 13 hours ago
:::::: commit date: 11 months ago
config: x86_64-randconfig-c007-20220101 (https://download.01.org/0day-ci/archive/20220102/202201021531.WqxLNEDn-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c054402170cd8466683a20385befc0523aba3359)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f12738b6ec063b1b63ff2232fd203d13a6ec2468
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout f12738b6ec063b1b63ff2232fd203d13a6ec2468
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:320:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:308:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:298:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   fs/btrfs/tree-log.c:4204:8: note: 'ret' is 0
                   if (!ret)
                        ^~~
   fs/btrfs/tree-log.c:4204:3: note: Taking true branch
                   if (!ret)
                   ^
   fs/btrfs/tree-log.c:4207:3: note: Memory is released
                   kfree(sums);
                   ^~~~~~~~~~~
   fs/btrfs/tree-log.c:4200:2: note: Loop condition is true.  Entering loop body
           while (!list_empty(&ordered_sums)) {
           ^
   fs/btrfs/tree-log.c:4201:36: note: Left side of '&&' is false
                   struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next,
                                                    ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:694:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   fs/btrfs/tree-log.c:4201:36: note: Taking false branch
                   struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next,
                                                    ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:694:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:320:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:308:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   fs/btrfs/tree-log.c:4201:36: note: Loop condition is false.  Exiting loop
                   struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next,
                                                    ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:694:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:320:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:308:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:298:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   fs/btrfs/tree-log.c:4204:7: note: Assuming 'ret' is not equal to 0
                   if (!ret)
                       ^~~~
   fs/btrfs/tree-log.c:4204:3: note: Taking false branch
                   if (!ret)
                   ^
   fs/btrfs/tree-log.c:4206:3: note: Calling 'list_del'
                   list_del(&sums->list);
                   ^~~~~~~~~~~~~~~~~~~~~
   include/linux/list.h:147:14: note: Use of memory after it is freed
           entry->next = LIST_POISON1;
           ~~~~~~~~~~~ ^
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3781:3: warning: Value stored to 'aq_ret' is never read [clang-analyzer-deadcode.DeadStores]
                   aq_ret = I40E_ERR_PARAM;
                   ^        ~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3781:3: note: Value stored to 'aq_ret' is never read
                   aq_ret = I40E_ERR_PARAM;
                   ^        ~~~~~~~~~~~~~~
   Suppressed 15 warnings (15 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
>> drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: warning: Value stored to 'cleaned_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
               ^~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: note: Value stored to 'cleaned_count' during its initialization is never read
           u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
               ^~~~~~~~~~~~~
   Suppressed 15 warnings (15 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   14 warnings generated.
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:10755:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
                   err = 0;
                   ^     ~
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:10755:3: note: Value stored to 'err' is never read
                   err = 0;
                   ^     ~
   include/linux/page-flags.h:184:23: warning: Dereference of null pointer [clang-analyzer-core.NullDereference]
           unsigned long head = READ_ONCE(page->compound_head);
                                ^
   include/asm-generic/rwonce.h:50:2: note: expanded from macro 'READ_ONCE'
           __READ_ONCE(x);                                                 \
           ^
   include/asm-generic/rwonce.h:44:24: note: expanded from macro '__READ_ONCE'
   #define __READ_ONCE(x)  (*(const volatile __unqual_scalar_typeof(x) *)&(x))
                           ^
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3146:5: note: Left side of '&&' is false
                                   container_of(napi, struct ixgbe_q_vector, napi);
                                   ^
   include/linux/kernel.h:694:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3146:5: note: Taking false branch
                                   container_of(napi, struct ixgbe_q_vector, napi);
                                   ^
   include/linux/kernel.h:694:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:320:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:308:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3146:5: note: Loop condition is false.  Exiting loop
                                   container_of(napi, struct ixgbe_q_vector, napi);
                                   ^
   include/linux/kernel.h:694:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:320:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:308:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:298:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3157:22: note: Assuming 'ring' is equal to null
           ixgbe_for_each_ring(ring, q_vector->tx) {
                               ^
   drivers/net/ethernet/intel/ixgbe/ixgbe.h:437:26: note: expanded from macro 'ixgbe_for_each_ring'
           for (pos = (head).ring; pos != NULL; pos = pos->next)
                                   ^~~~~~~~~~~
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3157:2: note: Loop condition is false. Execution continues on line 3167
           ixgbe_for_each_ring(ring, q_vector->tx) {
           ^
   drivers/net/ethernet/intel/ixgbe/ixgbe.h:437:2: note: expanded from macro 'ixgbe_for_each_ring'
           for (pos = (head).ring; pos != NULL; pos = pos->next)
           ^
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3167:6: note: Assuming 'budget' is > 0
           if (budget <= 0)
               ^~~~~~~~~~~
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3167:2: note: Taking false branch
           if (budget <= 0)
           ^
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3172:6: note: Assuming field 'count' is <= 1
           if (q_vector->rx.count > 1)
               ^~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3172:2: note: Taking false branch
           if (q_vector->rx.count > 1)
           ^
   drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3177:22: note: Assuming 'ring' is not equal to null
           ixgbe_for_each_ring(ring, q_vector->rx) {

vim +/cleaned_count +274 drivers/net/ethernet/intel/i40e/i40e_xsk.c

0a714186d3c0f7 Björn Töpel         2018-08-28  263  
0a714186d3c0f7 Björn Töpel         2018-08-28  264  /**
0a714186d3c0f7 Björn Töpel         2018-08-28  265   * i40e_clean_rx_irq_zc - Consumes Rx packets from the hardware ring
0a714186d3c0f7 Björn Töpel         2018-08-28  266   * @rx_ring: Rx ring
0a714186d3c0f7 Björn Töpel         2018-08-28  267   * @budget: NAPI budget
0a714186d3c0f7 Björn Töpel         2018-08-28  268   *
0a714186d3c0f7 Björn Töpel         2018-08-28  269   * Returns amount of work completed
0a714186d3c0f7 Björn Töpel         2018-08-28  270   **/
0a714186d3c0f7 Björn Töpel         2018-08-28  271  int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
0a714186d3c0f7 Björn Töpel         2018-08-28  272  {
0a714186d3c0f7 Björn Töpel         2018-08-28  273  	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
0a714186d3c0f7 Björn Töpel         2018-08-28 @274  	u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  275  	u16 next_to_clean = rx_ring->next_to_clean;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  276  	u16 count_mask = rx_ring->count - 1;
0a714186d3c0f7 Björn Töpel         2018-08-28  277  	unsigned int xdp_res, xdp_xmit = 0;
1773482fd8cecd Dan Carpenter       2020-09-16  278  	bool failure = false;
0a714186d3c0f7 Björn Töpel         2018-08-28  279  	struct sk_buff *skb;
0a714186d3c0f7 Björn Töpel         2018-08-28  280  
0a714186d3c0f7 Björn Töpel         2018-08-28  281  	while (likely(total_rx_packets < (unsigned int)budget)) {
0a714186d3c0f7 Björn Töpel         2018-08-28  282  		union i40e_rx_desc *rx_desc;
3b4f0b66c2b3dc Björn Töpel         2020-05-20  283  		struct xdp_buff **bi;
0a714186d3c0f7 Björn Töpel         2018-08-28  284  		unsigned int size;
0a714186d3c0f7 Björn Töpel         2018-08-28  285  		u64 qword;
0a714186d3c0f7 Björn Töpel         2018-08-28  286  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  287  		rx_desc = I40E_RX_DESC(rx_ring, next_to_clean);
0a714186d3c0f7 Björn Töpel         2018-08-28  288  		qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
0a714186d3c0f7 Björn Töpel         2018-08-28  289  
0a714186d3c0f7 Björn Töpel         2018-08-28  290  		/* This memory barrier is needed to keep us from reading
0a714186d3c0f7 Björn Töpel         2018-08-28  291  		 * any other fields out of the rx_desc until we have
0a714186d3c0f7 Björn Töpel         2018-08-28  292  		 * verified the descriptor has been written back.
0a714186d3c0f7 Björn Töpel         2018-08-28  293  		 */
0a714186d3c0f7 Björn Töpel         2018-08-28  294  		dma_rmb();
0a714186d3c0f7 Björn Töpel         2018-08-28  295  
be1222b585fdc4 Björn Töpel         2020-05-20  296  		if (i40e_rx_is_programming_status(qword)) {
be1222b585fdc4 Björn Töpel         2020-05-20  297  			i40e_clean_programming_status(rx_ring,
be1222b585fdc4 Björn Töpel         2020-05-20  298  						      rx_desc->raw.qword[0],
0a714186d3c0f7 Björn Töpel         2018-08-28  299  						      qword);
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  300  			bi = i40e_rx_bi(rx_ring, next_to_clean);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  301  			xsk_buff_free(*bi);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  302  			*bi = NULL;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  303  			next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  304  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  305  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  306  
0a714186d3c0f7 Björn Töpel         2018-08-28  307  		size = (qword & I40E_RXD_QW1_LENGTH_PBUF_MASK) >>
0a714186d3c0f7 Björn Töpel         2018-08-28  308  		       I40E_RXD_QW1_LENGTH_PBUF_SHIFT;
0a714186d3c0f7 Björn Töpel         2018-08-28  309  		if (!size)
0a714186d3c0f7 Björn Töpel         2018-08-28  310  			break;
0a714186d3c0f7 Björn Töpel         2018-08-28  311  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  312  		bi = i40e_rx_bi(rx_ring, next_to_clean);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  313  		(*bi)->data_end = (*bi)->data + size;
9647c57b11e563 Magnus Karlsson     2020-08-28  314  		xsk_buff_dma_sync_for_cpu(*bi, rx_ring->xsk_pool);
0a714186d3c0f7 Björn Töpel         2018-08-28  315  
3b4f0b66c2b3dc Björn Töpel         2020-05-20  316  		xdp_res = i40e_run_xdp_zc(rx_ring, *bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  317  		if (xdp_res) {
3b4f0b66c2b3dc Björn Töpel         2020-05-20  318  			if (xdp_res & (I40E_XDP_TX | I40E_XDP_REDIR))
0a714186d3c0f7 Björn Töpel         2018-08-28  319  				xdp_xmit |= xdp_res;
3b4f0b66c2b3dc Björn Töpel         2020-05-20  320  			else
3b4f0b66c2b3dc Björn Töpel         2020-05-20  321  				xsk_buff_free(*bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  322  
3b4f0b66c2b3dc Björn Töpel         2020-05-20  323  			*bi = NULL;
0a714186d3c0f7 Björn Töpel         2018-08-28  324  			total_rx_bytes += size;
0a714186d3c0f7 Björn Töpel         2018-08-28  325  			total_rx_packets++;
0a714186d3c0f7 Björn Töpel         2018-08-28  326  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  327  			next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  328  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  329  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  330  
0a714186d3c0f7 Björn Töpel         2018-08-28  331  		/* XDP_PASS path */
0a714186d3c0f7 Björn Töpel         2018-08-28  332  
0a714186d3c0f7 Björn Töpel         2018-08-28  333  		/* NB! We are not checking for errors using
0a714186d3c0f7 Björn Töpel         2018-08-28  334  		 * i40e_test_staterr with
0a714186d3c0f7 Björn Töpel         2018-08-28  335  		 * BIT(I40E_RXD_QW1_ERROR_SHIFT). This is due to that
0a714186d3c0f7 Björn Töpel         2018-08-28  336  		 * SBP is *not* set in PRT_SBPVSI (default not set).
0a714186d3c0f7 Björn Töpel         2018-08-28  337  		 */
3b4f0b66c2b3dc Björn Töpel         2020-05-20  338  		skb = i40e_construct_skb_zc(rx_ring, *bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  339  		if (!skb) {
0a714186d3c0f7 Björn Töpel         2018-08-28  340  			rx_ring->rx_stats.alloc_buff_failed++;
0a714186d3c0f7 Björn Töpel         2018-08-28  341  			break;
0a714186d3c0f7 Björn Töpel         2018-08-28  342  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  343  
7128c834d30e6b Cristian Dumitrescu 2021-01-11  344  		*bi = NULL;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  345  		next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  346  
0a714186d3c0f7 Björn Töpel         2018-08-28  347  		if (eth_skb_pad(skb))
0a714186d3c0f7 Björn Töpel         2018-08-28  348  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  349  
0a714186d3c0f7 Björn Töpel         2018-08-28  350  		total_rx_bytes += skb->len;
0a714186d3c0f7 Björn Töpel         2018-08-28  351  		total_rx_packets++;
0a714186d3c0f7 Björn Töpel         2018-08-28  352  
800b8f637d07cc Michał Mirosław     2018-12-04  353  		i40e_process_skb_fields(rx_ring, rx_desc, skb);
2a508c64ad278d Michał Mirosław     2018-12-04  354  		napi_gro_receive(&rx_ring->q_vector->napi, skb);
0a714186d3c0f7 Björn Töpel         2018-08-28  355  	}
0a714186d3c0f7 Björn Töpel         2018-08-28  356  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  357  	rx_ring->next_to_clean = next_to_clean;
f12738b6ec063b Cristian Dumitrescu 2021-01-14  358  	cleaned_count = (next_to_clean - rx_ring->next_to_use - 1) & count_mask;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  359  
8cbf7414990338 Björn Töpel         2020-08-25  360  	if (cleaned_count >= I40E_RX_BUFFER_WRITE)
8cbf7414990338 Björn Töpel         2020-08-25  361  		failure = !i40e_alloc_rx_buffers_zc(rx_ring, cleaned_count);
8cbf7414990338 Björn Töpel         2020-08-25  362  
0a714186d3c0f7 Björn Töpel         2018-08-28  363  	i40e_finalize_xdp_rx(rx_ring, xdp_xmit);
0a714186d3c0f7 Björn Töpel         2018-08-28  364  	i40e_update_rx_stats(rx_ring, total_rx_bytes, total_rx_packets);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  365  
c4655761d3cf62 Magnus Karlsson     2020-08-28  366  	if (xsk_uses_need_wakeup(rx_ring->xsk_pool)) {
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  367  		if (failure || next_to_clean == rx_ring->next_to_use)
c4655761d3cf62 Magnus Karlsson     2020-08-28  368  			xsk_set_rx_need_wakeup(rx_ring->xsk_pool);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  369  		else
c4655761d3cf62 Magnus Karlsson     2020-08-28  370  			xsk_clear_rx_need_wakeup(rx_ring->xsk_pool);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  371  
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  372  		return (int)total_rx_packets;
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  373  	}
0a714186d3c0f7 Björn Töpel         2018-08-28  374  	return failure ? budget : (int)total_rx_packets;
0a714186d3c0f7 Björn Töpel         2018-08-28  375  }
0a714186d3c0f7 Björn Töpel         2018-08-28  376  

:::::: The code at line 274 was first introduced by commit
:::::: 0a714186d3c0f7c563a03537f98716457c1f5ae0 i40e: add AF_XDP zero-copy Rx support

:::::: TO: Björn Töpel <bjorn.topel@intel.com>
:::::: CC: Alexei Starovoitov <ast@kernel.org>

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

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

* drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: warning: Value stored to 'cleaned_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
@ 2022-01-02  2:11 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-01-02  2:11 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 23624 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
CC: Tony Nguyen <anthony.l.nguyen@intel.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   278218f6778bc7d6f8b67199446c56cec7ebb841
commit: f12738b6ec063b1b63ff2232fd203d13a6ec2468 i40e: remove unnecessary cleaned_count updates
date:   11 months ago
:::::: branch date: 8 hours ago
:::::: commit date: 11 months ago
config: i386-randconfig-c001-20211215 (https://download.01.org/0day-ci/archive/20220102/202201021017.Lq16vkl4-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dd245bab9fbb364faa1581e4f92ba3119a872fba)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f12738b6ec063b1b63ff2232fd203d13a6ec2468
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout f12738b6ec063b1b63ff2232fd203d13a6ec2468
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   net/sched/sch_fq.c:314:7: note: Assuming 'sk' is equal to field 'sk'
                   if (f->sk == sk) {
                       ^~~~~~~~~~~
   net/sched/sch_fq.c:314:3: note: Taking true branch
                   if (f->sk == sk) {
                   ^
   net/sched/sch_fq.c:320:17: note: Assuming 'sk' is equal to field 'sk'
                           if (unlikely(skb->sk == sk &&
                                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   net/sched/sch_fq.c:320:17: note: Left side of '&&' is true
                           if (unlikely(skb->sk == sk &&
                                        ^
   net/sched/sch_fq.c:321:28: note: Dereference of null pointer
                                        f->socket_hash != sk->sk_hash)) {
                                                          ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   net/sched/sch_fq.c:349:20: warning: Dereference of null pointer [clang-analyzer-core.NullDereference]
                   f->socket_hash = sk->sk_hash;
                                    ^
   net/sched/sch_fq.c:448:15: note: Assuming field 'qlen' is < field 'limit'
           if (unlikely(sch->q.qlen >= sch->limit))
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   net/sched/sch_fq.c:448:2: note: Taking false branch
           if (unlikely(sch->q.qlen >= sch->limit))
           ^
   net/sched/sch_fq.c:451:6: note: Assuming field 'tstamp' is 0
           if (!skb->tstamp) {
               ^~~~~~~~~~~~
   net/sched/sch_fq.c:451:2: note: Taking true branch
           if (!skb->tstamp) {
           ^
   net/sched/sch_fq.c:473:6: note: Calling 'fq_classify'
           f = fq_classify(skb, q);
               ^~~~~~~~~~~~~~~~~~~
   net/sched/sch_fq.c:269:15: note: Assuming the condition is false
           if (unlikely((skb->priority & TC_PRIO_MAX) == TC_PRIO_CONTROL))
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   net/sched/sch_fq.c:269:2: note: Taking false branch
           if (unlikely((skb->priority & TC_PRIO_MAX) == TC_PRIO_CONTROL))
           ^
   net/sched/sch_fq.c:281:6: note: Assuming 'sk' is null
           if (!sk || sk_listener(sk)) {
               ^~~
   net/sched/sch_fq.c:281:10: note: Left side of '||' is true
           if (!sk || sk_listener(sk)) {
                   ^
   net/sched/sch_fq.c:287:3: note: Value assigned to 'sk'
                   sk = (struct sock *)((hash << 1) | 1UL);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_fq.c:304:6: note: Assuming the condition is false
           if (q->flows >= (2U << q->fq_trees_log) &&
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_fq.c:304:42: note: Left side of '&&' is false
           if (q->flows >= (2U << q->fq_trees_log) &&
                                                   ^
   net/sched/sch_fq.c:310:2: note: Loop condition is false. Execution continues on line 339
           while (*p) {
           ^
   net/sched/sch_fq.c:340:15: note: Assuming 'f' is non-null
           if (unlikely(!f)) {
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   net/sched/sch_fq.c:340:2: note: Taking false branch
           if (unlikely(!f)) {
           ^
   net/sched/sch_fq.c:348:6: note: Assuming 'sk' is equal to field 'sk'
           if (skb->sk == sk) {
               ^~~~~~~~~~~~~
   net/sched/sch_fq.c:348:2: note: Taking true branch
           if (skb->sk == sk) {
           ^
   net/sched/sch_fq.c:349:20: note: Dereference of null pointer
                   f->socket_hash = sk->sk_hash;
                                    ^~~~~~~~~~~
   Suppressed 14 warnings (14 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   17 warnings generated.
   drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3781:3: warning: Value stored to 'aq_ret' is never read [clang-analyzer-deadcode.DeadStores]
                   aq_ret = I40E_ERR_PARAM;
                   ^        ~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3781:3: note: Value stored to 'aq_ret' is never read
                   aq_ret = I40E_ERR_PARAM;
                   ^        ~~~~~~~~~~~~~~
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   17 warnings generated.
>> drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: warning: Value stored to 'cleaned_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
               ^~~~~~~~~~~~~
   drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: note: Value stored to 'cleaned_count' during its initialization is never read
           u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
               ^~~~~~~~~~~~~
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   27 warnings generated.
   drivers/net/ethernet/neterion/vxge/vxge-config.c:41:2: warning: Value stored to 'val64' is never read [clang-analyzer-deadcode.DeadStores]
           val64 = readq(&vp_reg->rxmac_vcfg0);
           ^
   drivers/net/ethernet/neterion/vxge/vxge-config.c:41:2: note: Value stored to 'val64' is never read
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2158:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = vxge_hw_ring_rxd_reserve(ring, &rxd);
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2158:3: note: Value stored to 'status' is never read
                   status = vxge_hw_ring_rxd_reserve(ring, &rxd);
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2620:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = VXGE_HW_FAIL;
                   ^        ~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2620:3: note: Value stored to 'status' is never read
                   status = VXGE_HW_FAIL;
                   ^        ~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2626:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2626:3: note: Value stored to 'status' is never read
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2651:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2651:3: note: Value stored to 'status' is never read
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2661:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2661:3: note: Value stored to 'status' is never read
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2672:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2672:3: note: Value stored to 'status' is never read
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2682:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2682:3: note: Value stored to 'status' is never read
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2697:3: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/neterion/vxge/vxge-config.c:2697:3: note: Value stored to 'status' is never read
                   status = VXGE_HW_ERR_OUT_OF_MEMORY;
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 18 warnings (18 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   11 warnings generated.
   drivers/hid/hid-core.c:1332:24: warning: The result of the left shift is undefined due to shifting by '4294967295', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
                                        ^
   drivers/hid/hid-core.c:1714:6: note: Assuming 'buf' is non-null
           if (!buf)
               ^~~~
   drivers/hid/hid-core.c:1714:2: note: Taking false branch
           if (!buf)
           ^
   drivers/hid/hid-core.c:1719:6: note: Assuming 'reqtype' is equal to HID_REQ_SET_REPORT
           if (reqtype == HID_REQ_SET_REPORT)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1719:2: note: Taking true branch
           if (reqtype == HID_REQ_SET_REPORT)
           ^
   drivers/hid/hid-core.c:1720:3: note: Calling 'hid_output_report'
                   hid_output_report(report, buf);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1627:14: note: Field 'id' is <= 0
           if (report->id > 0)
                       ^
   drivers/hid/hid-core.c:1627:2: note: Taking false branch
           if (report->id > 0)
           ^
   drivers/hid/hid-core.c:1631:14: note: Assuming 'n' is < field 'maxfield'
           for (n = 0; n < report->maxfield; n++)
                       ^~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1631:2: note: Loop condition is true.  Entering loop body
           for (n = 0; n < report->maxfield; n++)
           ^
   drivers/hid/hid-core.c:1632:3: note: Calling 'hid_output_field'
                   hid_output_field(report->device, report->field[n], data);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1597:14: note: Assuming 'n' is < 'count'

vim +/cleaned_count +274 drivers/net/ethernet/intel/i40e/i40e_xsk.c

0a714186d3c0f7 Björn Töpel         2018-08-28  263  
0a714186d3c0f7 Björn Töpel         2018-08-28  264  /**
0a714186d3c0f7 Björn Töpel         2018-08-28  265   * i40e_clean_rx_irq_zc - Consumes Rx packets from the hardware ring
0a714186d3c0f7 Björn Töpel         2018-08-28  266   * @rx_ring: Rx ring
0a714186d3c0f7 Björn Töpel         2018-08-28  267   * @budget: NAPI budget
0a714186d3c0f7 Björn Töpel         2018-08-28  268   *
0a714186d3c0f7 Björn Töpel         2018-08-28  269   * Returns amount of work completed
0a714186d3c0f7 Björn Töpel         2018-08-28  270   **/
0a714186d3c0f7 Björn Töpel         2018-08-28  271  int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
0a714186d3c0f7 Björn Töpel         2018-08-28  272  {
0a714186d3c0f7 Björn Töpel         2018-08-28  273  	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
0a714186d3c0f7 Björn Töpel         2018-08-28 @274  	u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  275  	u16 next_to_clean = rx_ring->next_to_clean;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  276  	u16 count_mask = rx_ring->count - 1;
0a714186d3c0f7 Björn Töpel         2018-08-28  277  	unsigned int xdp_res, xdp_xmit = 0;
1773482fd8cecd Dan Carpenter       2020-09-16  278  	bool failure = false;
0a714186d3c0f7 Björn Töpel         2018-08-28  279  	struct sk_buff *skb;
0a714186d3c0f7 Björn Töpel         2018-08-28  280  
0a714186d3c0f7 Björn Töpel         2018-08-28  281  	while (likely(total_rx_packets < (unsigned int)budget)) {
0a714186d3c0f7 Björn Töpel         2018-08-28  282  		union i40e_rx_desc *rx_desc;
3b4f0b66c2b3dc Björn Töpel         2020-05-20  283  		struct xdp_buff **bi;
0a714186d3c0f7 Björn Töpel         2018-08-28  284  		unsigned int size;
0a714186d3c0f7 Björn Töpel         2018-08-28  285  		u64 qword;
0a714186d3c0f7 Björn Töpel         2018-08-28  286  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  287  		rx_desc = I40E_RX_DESC(rx_ring, next_to_clean);
0a714186d3c0f7 Björn Töpel         2018-08-28  288  		qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
0a714186d3c0f7 Björn Töpel         2018-08-28  289  
0a714186d3c0f7 Björn Töpel         2018-08-28  290  		/* This memory barrier is needed to keep us from reading
0a714186d3c0f7 Björn Töpel         2018-08-28  291  		 * any other fields out of the rx_desc until we have
0a714186d3c0f7 Björn Töpel         2018-08-28  292  		 * verified the descriptor has been written back.
0a714186d3c0f7 Björn Töpel         2018-08-28  293  		 */
0a714186d3c0f7 Björn Töpel         2018-08-28  294  		dma_rmb();
0a714186d3c0f7 Björn Töpel         2018-08-28  295  
be1222b585fdc4 Björn Töpel         2020-05-20  296  		if (i40e_rx_is_programming_status(qword)) {
be1222b585fdc4 Björn Töpel         2020-05-20  297  			i40e_clean_programming_status(rx_ring,
be1222b585fdc4 Björn Töpel         2020-05-20  298  						      rx_desc->raw.qword[0],
0a714186d3c0f7 Björn Töpel         2018-08-28  299  						      qword);
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  300  			bi = i40e_rx_bi(rx_ring, next_to_clean);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  301  			xsk_buff_free(*bi);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  302  			*bi = NULL;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  303  			next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  304  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  305  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  306  
0a714186d3c0f7 Björn Töpel         2018-08-28  307  		size = (qword & I40E_RXD_QW1_LENGTH_PBUF_MASK) >>
0a714186d3c0f7 Björn Töpel         2018-08-28  308  		       I40E_RXD_QW1_LENGTH_PBUF_SHIFT;
0a714186d3c0f7 Björn Töpel         2018-08-28  309  		if (!size)
0a714186d3c0f7 Björn Töpel         2018-08-28  310  			break;
0a714186d3c0f7 Björn Töpel         2018-08-28  311  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  312  		bi = i40e_rx_bi(rx_ring, next_to_clean);
3b4f0b66c2b3dc Björn Töpel         2020-05-20  313  		(*bi)->data_end = (*bi)->data + size;
9647c57b11e563 Magnus Karlsson     2020-08-28  314  		xsk_buff_dma_sync_for_cpu(*bi, rx_ring->xsk_pool);
0a714186d3c0f7 Björn Töpel         2018-08-28  315  
3b4f0b66c2b3dc Björn Töpel         2020-05-20  316  		xdp_res = i40e_run_xdp_zc(rx_ring, *bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  317  		if (xdp_res) {
3b4f0b66c2b3dc Björn Töpel         2020-05-20  318  			if (xdp_res & (I40E_XDP_TX | I40E_XDP_REDIR))
0a714186d3c0f7 Björn Töpel         2018-08-28  319  				xdp_xmit |= xdp_res;
3b4f0b66c2b3dc Björn Töpel         2020-05-20  320  			else
3b4f0b66c2b3dc Björn Töpel         2020-05-20  321  				xsk_buff_free(*bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  322  
3b4f0b66c2b3dc Björn Töpel         2020-05-20  323  			*bi = NULL;
0a714186d3c0f7 Björn Töpel         2018-08-28  324  			total_rx_bytes += size;
0a714186d3c0f7 Björn Töpel         2018-08-28  325  			total_rx_packets++;
0a714186d3c0f7 Björn Töpel         2018-08-28  326  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  327  			next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  328  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  329  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  330  
0a714186d3c0f7 Björn Töpel         2018-08-28  331  		/* XDP_PASS path */
0a714186d3c0f7 Björn Töpel         2018-08-28  332  
0a714186d3c0f7 Björn Töpel         2018-08-28  333  		/* NB! We are not checking for errors using
0a714186d3c0f7 Björn Töpel         2018-08-28  334  		 * i40e_test_staterr with
0a714186d3c0f7 Björn Töpel         2018-08-28  335  		 * BIT(I40E_RXD_QW1_ERROR_SHIFT). This is due to that
0a714186d3c0f7 Björn Töpel         2018-08-28  336  		 * SBP is *not* set in PRT_SBPVSI (default not set).
0a714186d3c0f7 Björn Töpel         2018-08-28  337  		 */
3b4f0b66c2b3dc Björn Töpel         2020-05-20  338  		skb = i40e_construct_skb_zc(rx_ring, *bi);
0a714186d3c0f7 Björn Töpel         2018-08-28  339  		if (!skb) {
0a714186d3c0f7 Björn Töpel         2018-08-28  340  			rx_ring->rx_stats.alloc_buff_failed++;
0a714186d3c0f7 Björn Töpel         2018-08-28  341  			break;
0a714186d3c0f7 Björn Töpel         2018-08-28  342  		}
0a714186d3c0f7 Björn Töpel         2018-08-28  343  
7128c834d30e6b Cristian Dumitrescu 2021-01-11  344  		*bi = NULL;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  345  		next_to_clean = (next_to_clean + 1) & count_mask;
0a714186d3c0f7 Björn Töpel         2018-08-28  346  
0a714186d3c0f7 Björn Töpel         2018-08-28  347  		if (eth_skb_pad(skb))
0a714186d3c0f7 Björn Töpel         2018-08-28  348  			continue;
0a714186d3c0f7 Björn Töpel         2018-08-28  349  
0a714186d3c0f7 Björn Töpel         2018-08-28  350  		total_rx_bytes += skb->len;
0a714186d3c0f7 Björn Töpel         2018-08-28  351  		total_rx_packets++;
0a714186d3c0f7 Björn Töpel         2018-08-28  352  
800b8f637d07cc Michał Mirosław     2018-12-04  353  		i40e_process_skb_fields(rx_ring, rx_desc, skb);
2a508c64ad278d Michał Mirosław     2018-12-04  354  		napi_gro_receive(&rx_ring->q_vector->napi, skb);
0a714186d3c0f7 Björn Töpel         2018-08-28  355  	}
0a714186d3c0f7 Björn Töpel         2018-08-28  356  
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  357  	rx_ring->next_to_clean = next_to_clean;
f12738b6ec063b Cristian Dumitrescu 2021-01-14  358  	cleaned_count = (next_to_clean - rx_ring->next_to_use - 1) & count_mask;
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  359  
8cbf7414990338 Björn Töpel         2020-08-25  360  	if (cleaned_count >= I40E_RX_BUFFER_WRITE)
8cbf7414990338 Björn Töpel         2020-08-25  361  		failure = !i40e_alloc_rx_buffers_zc(rx_ring, cleaned_count);
8cbf7414990338 Björn Töpel         2020-08-25  362  
0a714186d3c0f7 Björn Töpel         2018-08-28  363  	i40e_finalize_xdp_rx(rx_ring, xdp_xmit);
0a714186d3c0f7 Björn Töpel         2018-08-28  364  	i40e_update_rx_stats(rx_ring, total_rx_bytes, total_rx_packets);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  365  
c4655761d3cf62 Magnus Karlsson     2020-08-28  366  	if (xsk_uses_need_wakeup(rx_ring->xsk_pool)) {
c8a8ca3408dcd2 Cristian Dumitrescu 2021-01-14  367  		if (failure || next_to_clean == rx_ring->next_to_use)
c4655761d3cf62 Magnus Karlsson     2020-08-28  368  			xsk_set_rx_need_wakeup(rx_ring->xsk_pool);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  369  		else
c4655761d3cf62 Magnus Karlsson     2020-08-28  370  			xsk_clear_rx_need_wakeup(rx_ring->xsk_pool);
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  371  
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  372  		return (int)total_rx_packets;
3d0c5f1cd268fd Magnus Karlsson     2019-08-14  373  	}
0a714186d3c0f7 Björn Töpel         2018-08-28  374  	return failure ? budget : (int)total_rx_packets;
0a714186d3c0f7 Björn Töpel         2018-08-28  375  }
0a714186d3c0f7 Björn Töpel         2018-08-28  376  

:::::: The code at line 274 was first introduced by commit
:::::: 0a714186d3c0f7c563a03537f98716457c1f5ae0 i40e: add AF_XDP zero-copy Rx support

:::::: TO: Björn Töpel <bjorn.topel@intel.com>
:::::: CC: Alexei Starovoitov <ast@kernel.org>

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

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

end of thread, other threads:[~2022-01-08 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 17:42 drivers/net/ethernet/intel/i40e/i40e_xsk.c:274:6: warning: Value stored to 'cleaned_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores] kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-01-02  7:45 kernel test robot
2022-01-02  2:11 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.