All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH V10 19/19] virtio_ring: add in order support
@ 2025-12-25  4:30 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-12-25  4:30 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251224003309.23432-20-jasowang@redhat.com>
References: <20251224003309.23432-20-jasowang@redhat.com>
TO: Jason Wang <jasowang@redhat.com>

Hi Jason,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on linus/master v6.19-rc2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Wang/virtio_ring-rename-virtqueue_reinit_xxx-to-virtqueue_reset_xxx/20251224-085755
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
patch link:    https://lore.kernel.org/r/20251224003309.23432-20-jasowang%40redhat.com
patch subject: [PATCH V10 19/19] virtio_ring: add in order support
:::::: branch date: 27 hours ago
:::::: commit date: 27 hours ago
config: arm-randconfig-r071-20251224 (https://download.01.org/0day-ci/archive/20251225/202512251237.1g0MyG32-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0

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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202512251237.1g0MyG32-lkp@intel.com/

New smatch warnings:
drivers/virtio/virtio_ring.c:1896 virtqueue_add_packed_in_order() error: uninitialized symbol 'head_flags'.

Old smatch warnings:
drivers/virtio/virtio_ring.c:1734 virtqueue_add_packed() error: uninitialized symbol 'prev'.
drivers/virtio/virtio_ring.c:1742 virtqueue_add_packed() error: uninitialized symbol 'head_flags'.

vim +/head_flags +1896 drivers/virtio/virtio_ring.c

1ce9e6055fa0a9 Tiwei Bie  2018-11-21  1770  
b8ff8e25553483 Jason Wang 2025-12-24  1771  static inline int virtqueue_add_packed_in_order(struct vring_virtqueue *vq,
b8ff8e25553483 Jason Wang 2025-12-24  1772  						struct scatterlist *sgs[],
b8ff8e25553483 Jason Wang 2025-12-24  1773  						unsigned int total_sg,
b8ff8e25553483 Jason Wang 2025-12-24  1774  						unsigned int out_sgs,
b8ff8e25553483 Jason Wang 2025-12-24  1775  						unsigned int in_sgs,
b8ff8e25553483 Jason Wang 2025-12-24  1776  						void *data,
b8ff8e25553483 Jason Wang 2025-12-24  1777  						void *ctx,
b8ff8e25553483 Jason Wang 2025-12-24  1778  						bool premapped,
b8ff8e25553483 Jason Wang 2025-12-24  1779  						gfp_t gfp)
b8ff8e25553483 Jason Wang 2025-12-24  1780  {
b8ff8e25553483 Jason Wang 2025-12-24  1781  	struct vring_packed_desc *desc;
b8ff8e25553483 Jason Wang 2025-12-24  1782  	struct scatterlist *sg;
b8ff8e25553483 Jason Wang 2025-12-24  1783  	unsigned int i, n, sg_count, err_idx, total_in_len = 0;
b8ff8e25553483 Jason Wang 2025-12-24  1784  	__le16 head_flags, flags;
b8ff8e25553483 Jason Wang 2025-12-24  1785  	u16 head, avail_used_flags;
b8ff8e25553483 Jason Wang 2025-12-24  1786  	int err;
b8ff8e25553483 Jason Wang 2025-12-24  1787  
b8ff8e25553483 Jason Wang 2025-12-24  1788  	START_USE(vq);
b8ff8e25553483 Jason Wang 2025-12-24  1789  
b8ff8e25553483 Jason Wang 2025-12-24  1790  	BUG_ON(data == NULL);
b8ff8e25553483 Jason Wang 2025-12-24  1791  	BUG_ON(ctx && vq->indirect);
b8ff8e25553483 Jason Wang 2025-12-24  1792  
b8ff8e25553483 Jason Wang 2025-12-24  1793  	if (unlikely(vq->broken)) {
b8ff8e25553483 Jason Wang 2025-12-24  1794  		END_USE(vq);
b8ff8e25553483 Jason Wang 2025-12-24  1795  		return -EIO;
b8ff8e25553483 Jason Wang 2025-12-24  1796  	}
b8ff8e25553483 Jason Wang 2025-12-24  1797  
b8ff8e25553483 Jason Wang 2025-12-24  1798  	LAST_ADD_TIME_UPDATE(vq);
b8ff8e25553483 Jason Wang 2025-12-24  1799  
b8ff8e25553483 Jason Wang 2025-12-24  1800  	BUG_ON(total_sg == 0);
b8ff8e25553483 Jason Wang 2025-12-24  1801  
b8ff8e25553483 Jason Wang 2025-12-24  1802  	if (virtqueue_use_indirect(vq, total_sg)) {
b8ff8e25553483 Jason Wang 2025-12-24  1803  		err = virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs,
b8ff8e25553483 Jason Wang 2025-12-24  1804  						    in_sgs, data, premapped, gfp,
b8ff8e25553483 Jason Wang 2025-12-24  1805  						    vq->packed.next_avail_idx);
b8ff8e25553483 Jason Wang 2025-12-24  1806  		if (err != -ENOMEM) {
b8ff8e25553483 Jason Wang 2025-12-24  1807  			END_USE(vq);
b8ff8e25553483 Jason Wang 2025-12-24  1808  			return err;
b8ff8e25553483 Jason Wang 2025-12-24  1809  		}
b8ff8e25553483 Jason Wang 2025-12-24  1810  
b8ff8e25553483 Jason Wang 2025-12-24  1811  		/* fall back on direct */
b8ff8e25553483 Jason Wang 2025-12-24  1812  	}
b8ff8e25553483 Jason Wang 2025-12-24  1813  
b8ff8e25553483 Jason Wang 2025-12-24  1814  	head = vq->packed.next_avail_idx;
b8ff8e25553483 Jason Wang 2025-12-24  1815  	avail_used_flags = vq->packed.avail_used_flags;
b8ff8e25553483 Jason Wang 2025-12-24  1816  
b8ff8e25553483 Jason Wang 2025-12-24  1817  	WARN_ON_ONCE(total_sg > vq->packed.vring.num && !vq->indirect);
b8ff8e25553483 Jason Wang 2025-12-24  1818  
b8ff8e25553483 Jason Wang 2025-12-24  1819  	desc = vq->packed.vring.desc;
b8ff8e25553483 Jason Wang 2025-12-24  1820  	i = head;
b8ff8e25553483 Jason Wang 2025-12-24  1821  
b8ff8e25553483 Jason Wang 2025-12-24  1822  	if (unlikely(vq->vq.num_free < total_sg)) {
b8ff8e25553483 Jason Wang 2025-12-24  1823  		pr_debug("Can't add buf len %i - avail = %i\n",
b8ff8e25553483 Jason Wang 2025-12-24  1824  			 total_sg, vq->vq.num_free);
b8ff8e25553483 Jason Wang 2025-12-24  1825  		END_USE(vq);
b8ff8e25553483 Jason Wang 2025-12-24  1826  		return -ENOSPC;
b8ff8e25553483 Jason Wang 2025-12-24  1827  	}
b8ff8e25553483 Jason Wang 2025-12-24  1828  
b8ff8e25553483 Jason Wang 2025-12-24  1829  	sg_count = 0;
b8ff8e25553483 Jason Wang 2025-12-24  1830  	for (n = 0; n < out_sgs + in_sgs; n++) {
b8ff8e25553483 Jason Wang 2025-12-24  1831  		for (sg = sgs[n]; sg; sg = sg_next(sg)) {
b8ff8e25553483 Jason Wang 2025-12-24  1832  			dma_addr_t addr;
b8ff8e25553483 Jason Wang 2025-12-24  1833  			u32 len;
b8ff8e25553483 Jason Wang 2025-12-24  1834  
b8ff8e25553483 Jason Wang 2025-12-24  1835  			flags = 0;
b8ff8e25553483 Jason Wang 2025-12-24  1836  			if (++sg_count != total_sg)
b8ff8e25553483 Jason Wang 2025-12-24  1837  				flags |= cpu_to_le16(VRING_DESC_F_NEXT);
b8ff8e25553483 Jason Wang 2025-12-24  1838  			if (n >= out_sgs)
b8ff8e25553483 Jason Wang 2025-12-24  1839  				flags |= cpu_to_le16(VRING_DESC_F_WRITE);
b8ff8e25553483 Jason Wang 2025-12-24  1840  
b8ff8e25553483 Jason Wang 2025-12-24  1841  			if (vring_map_one_sg(vq, sg, n < out_sgs ?
b8ff8e25553483 Jason Wang 2025-12-24  1842  					     DMA_TO_DEVICE : DMA_FROM_DEVICE,
b8ff8e25553483 Jason Wang 2025-12-24  1843  					     &addr, &len, premapped))
b8ff8e25553483 Jason Wang 2025-12-24  1844  				goto unmap_release;
b8ff8e25553483 Jason Wang 2025-12-24  1845  
b8ff8e25553483 Jason Wang 2025-12-24  1846  			flags |= cpu_to_le16(vq->packed.avail_used_flags);
b8ff8e25553483 Jason Wang 2025-12-24  1847  
b8ff8e25553483 Jason Wang 2025-12-24  1848  			if (i == head)
b8ff8e25553483 Jason Wang 2025-12-24  1849  				head_flags = flags;
b8ff8e25553483 Jason Wang 2025-12-24  1850  			else
b8ff8e25553483 Jason Wang 2025-12-24  1851  				desc[i].flags = flags;
b8ff8e25553483 Jason Wang 2025-12-24  1852  
b8ff8e25553483 Jason Wang 2025-12-24  1853  			desc[i].addr = cpu_to_le64(addr);
b8ff8e25553483 Jason Wang 2025-12-24  1854  			desc[i].len = cpu_to_le32(len);
b8ff8e25553483 Jason Wang 2025-12-24  1855  			desc[i].id = cpu_to_le16(head);
b8ff8e25553483 Jason Wang 2025-12-24  1856  
b8ff8e25553483 Jason Wang 2025-12-24  1857  			if (unlikely(vq->use_map_api)) {
b8ff8e25553483 Jason Wang 2025-12-24  1858  				vq->packed.desc_extra[i].addr = premapped ?
b8ff8e25553483 Jason Wang 2025-12-24  1859  				      DMA_MAPPING_ERROR: addr;
b8ff8e25553483 Jason Wang 2025-12-24  1860  				vq->packed.desc_extra[i].len = len;
b8ff8e25553483 Jason Wang 2025-12-24  1861  				vq->packed.desc_extra[i].flags =
b8ff8e25553483 Jason Wang 2025-12-24  1862  					le16_to_cpu(flags);
b8ff8e25553483 Jason Wang 2025-12-24  1863  			}
b8ff8e25553483 Jason Wang 2025-12-24  1864  
b8ff8e25553483 Jason Wang 2025-12-24  1865  			if ((unlikely(++i >= vq->packed.vring.num))) {
b8ff8e25553483 Jason Wang 2025-12-24  1866  				i = 0;
b8ff8e25553483 Jason Wang 2025-12-24  1867  				vq->packed.avail_used_flags ^=
b8ff8e25553483 Jason Wang 2025-12-24  1868  					1 << VRING_PACKED_DESC_F_AVAIL |
b8ff8e25553483 Jason Wang 2025-12-24  1869  					1 << VRING_PACKED_DESC_F_USED;
b8ff8e25553483 Jason Wang 2025-12-24  1870  				vq->packed.avail_wrap_counter ^= 1;
b8ff8e25553483 Jason Wang 2025-12-24  1871  			}
b8ff8e25553483 Jason Wang 2025-12-24  1872  
b8ff8e25553483 Jason Wang 2025-12-24  1873  			if (n >= out_sgs)
b8ff8e25553483 Jason Wang 2025-12-24  1874  				total_in_len += len;
b8ff8e25553483 Jason Wang 2025-12-24  1875  		}
b8ff8e25553483 Jason Wang 2025-12-24  1876  	}
b8ff8e25553483 Jason Wang 2025-12-24  1877  
b8ff8e25553483 Jason Wang 2025-12-24  1878  	/* We're using some buffers from the free list. */
b8ff8e25553483 Jason Wang 2025-12-24  1879  	vq->vq.num_free -= total_sg;
b8ff8e25553483 Jason Wang 2025-12-24  1880  
b8ff8e25553483 Jason Wang 2025-12-24  1881  	/* Update free pointer */
b8ff8e25553483 Jason Wang 2025-12-24  1882  	vq->packed.next_avail_idx = i;
b8ff8e25553483 Jason Wang 2025-12-24  1883  
b8ff8e25553483 Jason Wang 2025-12-24  1884  	/* Store token. */
b8ff8e25553483 Jason Wang 2025-12-24  1885  	vq->packed.desc_state[head].num = total_sg;
b8ff8e25553483 Jason Wang 2025-12-24  1886  	vq->packed.desc_state[head].data = data;
b8ff8e25553483 Jason Wang 2025-12-24  1887  	vq->packed.desc_state[head].indir_desc = ctx;
b8ff8e25553483 Jason Wang 2025-12-24  1888  	vq->packed.desc_state[head].total_in_len = total_in_len;
b8ff8e25553483 Jason Wang 2025-12-24  1889  
b8ff8e25553483 Jason Wang 2025-12-24  1890  	/*
b8ff8e25553483 Jason Wang 2025-12-24  1891  	 * A driver MUST NOT make the first descriptor in the list
b8ff8e25553483 Jason Wang 2025-12-24  1892  	 * available before all subsequent descriptors comprising
b8ff8e25553483 Jason Wang 2025-12-24  1893  	 * the list are made available.
b8ff8e25553483 Jason Wang 2025-12-24  1894  	 */
b8ff8e25553483 Jason Wang 2025-12-24  1895  	virtio_wmb(vq->weak_barriers);
b8ff8e25553483 Jason Wang 2025-12-24 @1896  	vq->packed.vring.desc[head].flags = head_flags;
b8ff8e25553483 Jason Wang 2025-12-24  1897  	vq->num_added += total_sg;
b8ff8e25553483 Jason Wang 2025-12-24  1898  
b8ff8e25553483 Jason Wang 2025-12-24  1899  	pr_debug("Added buffer head %i to %p\n", head, vq);
b8ff8e25553483 Jason Wang 2025-12-24  1900  	END_USE(vq);
b8ff8e25553483 Jason Wang 2025-12-24  1901  
b8ff8e25553483 Jason Wang 2025-12-24  1902  	return 0;
b8ff8e25553483 Jason Wang 2025-12-24  1903  
b8ff8e25553483 Jason Wang 2025-12-24  1904  unmap_release:
b8ff8e25553483 Jason Wang 2025-12-24  1905  	err_idx = i;
b8ff8e25553483 Jason Wang 2025-12-24  1906  	i = head;
b8ff8e25553483 Jason Wang 2025-12-24  1907  	vq->packed.avail_used_flags = avail_used_flags;
b8ff8e25553483 Jason Wang 2025-12-24  1908  
b8ff8e25553483 Jason Wang 2025-12-24  1909  	for (n = 0; n < total_sg; n++) {
b8ff8e25553483 Jason Wang 2025-12-24  1910  		if (i == err_idx)
b8ff8e25553483 Jason Wang 2025-12-24  1911  			break;
b8ff8e25553483 Jason Wang 2025-12-24  1912  		vring_unmap_extra_packed(vq, &vq->packed.desc_extra[i]);
b8ff8e25553483 Jason Wang 2025-12-24  1913  		i++;
b8ff8e25553483 Jason Wang 2025-12-24  1914  		if (i >= vq->packed.vring.num)
b8ff8e25553483 Jason Wang 2025-12-24  1915  			i = 0;
b8ff8e25553483 Jason Wang 2025-12-24  1916  	}
b8ff8e25553483 Jason Wang 2025-12-24  1917  
b8ff8e25553483 Jason Wang 2025-12-24  1918  	END_USE(vq);
b8ff8e25553483 Jason Wang 2025-12-24  1919  	return -EIO;
b8ff8e25553483 Jason Wang 2025-12-24  1920  }
b8ff8e25553483 Jason Wang 2025-12-24  1921  

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

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH V10 00/19] virtio_ring in order support
@ 2025-12-24  0:32 Jason Wang
  2025-12-24  0:33 ` [PATCH V10 19/19] virtio_ring: add " Jason Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Wang @ 2025-12-24  0:32 UTC (permalink / raw)
  To: mst, jasowang, xuanzhuo, eperezma, virtualization, linux-kernel

Hello all:

This sereis tries to implement the VIRTIO_F_IN_ORDER to
virtio_ring. This is done by introducing virtqueue ops so we can
implement separate helpers for different virtqueue layout/features
then the in-order were implemented on top.

Tests shows 2%-19% imporvment with packed virtqueue PPS with KVM guest
vhost-net/testpmd on the host.

Changes sinve v9:

- Fix the total_len calcuation and count only in buffer length
- Fix the comment for the condtiion when batching is not detected

Changes since v8:

- Rebase to vhost.git linux-next branch
- Fix issue when indirect descriptor is disabled
- use UINT_MAX instead of vq->num to indicate no batching is pending
- Tweak the comments for used_entry
- Various coding style tweaks and typo fixes
- Try to use in_order varianet in in_order ops

Changes since v7:

- Rebase on vhost.git linux-next branch
- Tweak the comment to explain the usage of free_head

Changes since v6:

- Rebase on vhost.git linux-next branch
- Fix poking packed virtqueue in more_used_split_in_order()
- Fix calling detach_buf_packed_in_order() unconditonally in
  virtqueue_detach_unused_buf_packed()
- Typo and indentation fixes
- Fix wrong changelog of patch 7

Changes since v5:

- rebase on vhost.git linux-next branch
- reorder the total_len to reduce memory comsuming

Changes since v4:

- Fix build error when DEBUG is enabled
- Fix function duplications
- Remove unnecessary new lines

Changes since v3:

- Re-benchmark with the recent vhost-net in order support
- Rename the batched used id and length
- Other minor tweaks

Changes since v2:

- Fix build warning when DEBUG is enabled

Changes since v1:

- use const global array of function pointers to avoid indirect
  branches to eliminate retpoline when mitigation is enabled
- fix used length calculation when processing used ids in a batch
- fix sparse warnings

Jason Wang (19):
  virtio_ring: rename virtqueue_reinit_xxx to virtqueue_reset_xxx()
  virtio_ring: switch to use vring_virtqueue in virtqueue_poll variants
  virtio_ring: unify logic of virtqueue_poll() and more_used()
  virtio_ring: switch to use vring_virtqueue for virtqueue resize
    variants
  virtio_ring: switch to use vring_virtqueue for virtqueue_kick_prepare
    variants
  virtio_ring: switch to use vring_virtqueue for virtqueue_add variants
  virtio: switch to use vring_virtqueue for virtqueue_get variants
  virtio_ring: switch to use vring_virtqueue for enable_cb_prepare
    variants
  virtio_ring: use vring_virtqueue for enable_cb_delayed variants
  virtio_ring: switch to use vring_virtqueue for disable_cb variants
  virtio_ring: switch to use vring_virtqueue for detach_unused_buf
    variants
  virtio_ring: switch to use unsigned int for virtqueue_poll_packed()
  virtio_ring: introduce virtqueue ops
  virtio_ring: determine descriptor flags at one time
  virtio_ring: factor out core logic of buffer detaching
  virtio_ring: factor out core logic for updating last_used_idx
  virtio_ring: factor out split indirect detaching logic
  virtio_ring: factor out split detaching logic
  virtio_ring: add in order support

 drivers/virtio/virtio_ring.c | 931 +++++++++++++++++++++++++++--------
 1 file changed, 717 insertions(+), 214 deletions(-)

-- 
2.31.1


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

end of thread, other threads:[~2025-12-25  4:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-25  4:30 [PATCH V10 19/19] virtio_ring: add in order support kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2025-12-24  0:32 [PATCH V10 00/19] virtio_ring " Jason Wang
2025-12-24  0:33 ` [PATCH V10 19/19] virtio_ring: add " Jason Wang
2025-12-24  8:05   ` Eugenio Perez Martin
2025-12-25  4:20     ` Jason Wang

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.