All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/2] Net patches
@ 2022-07-06  3:47 Jason Wang
  2022-07-06  3:47 ` [PULL 1/2] e1000: set RX descriptor status in a separate operation Jason Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jason Wang @ 2022-07-06  3:47 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Jason Wang

The following changes since commit 39e19f5f67d925c60278a6156fd1776d04495a93:

  Merge tag 'pull-xen-20220705' of https://xenbits.xen.org/git-http/people/aperard/qemu-dm into staging (2022-07-05 22:13:51 +0530)

are available in the git repository at:

  https://github.com/jasowang/qemu.git tags/net-pull-request

for you to fetch changes up to a495eba03c31c96d6a0817b13598ce2219326691:

  ebpf: replace deprecated bpf_program__set_socket_filter (2022-07-06 11:39:09 +0800)

----------------------------------------------------------------

----------------------------------------------------------------
Ding Hui (1):
      e1000: set RX descriptor status in a separate operation

Haochen Tong (1):
      ebpf: replace deprecated bpf_program__set_socket_filter

 ebpf/ebpf_rss.c | 2 +-
 hw/net/e1000.c  | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)




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

* [PULL 1/2] e1000: set RX descriptor status in a separate operation
  2022-07-06  3:47 [PULL 0/2] Net patches Jason Wang
@ 2022-07-06  3:47 ` Jason Wang
  2022-07-06  3:47 ` [PULL 2/2] ebpf: replace deprecated bpf_program__set_socket_filter Jason Wang
  2022-07-06  6:50 ` [PULL 0/2] Net patches Richard Henderson
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2022-07-06  3:47 UTC (permalink / raw)
  To: qemu-devel, peter.maydell
  Cc: Ding Hui, Leonid Myravjev, Stefan Hajnoczi, Paolo Bonzini,
	Michael S . Tsirkin, qemu-stable, Jing Zhang, Frank Lee,
	Jason Wang

From: Ding Hui <dinghui@sangfor.com.cn>

The code of setting RX descriptor status field maybe work fine in
previously, however with the update of glibc version, it shows two
issues when guest using dpdk receive packets:

  1. The dpdk has a certain probability getting wrong buffer_addr

     this impact may be not obvious, such as lost a packet once in
     a while

  2. The dpdk may consume a packet twice when scan the RX desc queue
     over again

     this impact will lead a infinite wait in Qemu, since the RDT
     (tail pointer) be inscreased to equal to RDH by unexpected,
     which regard as the RX desc queue is full

Write a whole of RX desc with DD flag on is not quite correct, because
when the underlying implementation of memcpy using XMM registers to
copy e1000_rx_desc (when AVX or something else CPU feature is usable),
the bytes order of desc writing to memory is indeterminacy

We can use full-scale test case to reproduce the issue-2 by
https://github.com/BASM/qemu_dpdk_e1000_test (thanks to Leonid Myravjev)

I also write a POC test case at https://github.com/cdkey/e1000_poc
which can reproduce both of them, and easy to verify the patch effect.

The hw watchpoint also shows that, when Qemu using XMM related instructions
writing 16 bytes e1000_rx_desc, concurrent with DPDK using movb
writing 1 byte status, the final result of writing to memory will be one
of them, if it made by Qemu which DD flag is on, DPDK will consume it
again.

Setting DD status in a separate operation, can prevent the impact of
disorder memory writing by memcpy, also avoid unexpected data when
concurrent writing status by qemu and guest dpdk.

Links: https://lore.kernel.org/qemu-devel/20200102110504.GG121208@stefanha-x1.localdomain/T/

Reported-by: Leonid Myravjev <asm@asm.pp.ru>
Cc: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: qemu-stable@nongnu.org
Tested-by: Jing Zhang <zhangjing@sangfor.com.cn>
Reviewed-by: Frank Lee <lifan38153@sangfor.com.cn>
Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/e1000.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index f5bc812..e26e0a6 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -979,7 +979,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
         base = rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH];
         pci_dma_read(d, base, &desc, sizeof(desc));
         desc.special = vlan_special;
-        desc.status |= (vlan_status | E1000_RXD_STAT_DD);
+        desc.status &= ~E1000_RXD_STAT_DD;
         if (desc.buffer_addr) {
             if (desc_offset < size) {
                 size_t iov_copy;
@@ -1013,6 +1013,9 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
             DBGOUT(RX, "Null RX descriptor!!\n");
         }
         pci_dma_write(d, base, &desc, sizeof(desc));
+        desc.status |= (vlan_status | E1000_RXD_STAT_DD);
+        pci_dma_write(d, base + offsetof(struct e1000_rx_desc, status),
+                      &desc.status, sizeof(desc.status));
 
         if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
             s->mac_reg[RDH] = 0;
-- 
2.7.4



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

* [PULL 2/2] ebpf: replace deprecated bpf_program__set_socket_filter
  2022-07-06  3:47 [PULL 0/2] Net patches Jason Wang
  2022-07-06  3:47 ` [PULL 1/2] e1000: set RX descriptor status in a separate operation Jason Wang
@ 2022-07-06  3:47 ` Jason Wang
  2022-07-06  6:50 ` [PULL 0/2] Net patches Richard Henderson
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2022-07-06  3:47 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: Haochen Tong, Zhang Chen, Jason Wang

From: Haochen Tong <i@hexchain.org>

bpf_program__set_<TYPE> functions have been deprecated since libbpf 0.8.
Replace with the equivalent bpf_program__set_type call to avoid a
deprecation warning.

Signed-off-by: Haochen Tong <i@hexchain.org>
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 ebpf/ebpf_rss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
index 118c68d..cee658c 100644
--- a/ebpf/ebpf_rss.c
+++ b/ebpf/ebpf_rss.c
@@ -49,7 +49,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx)
         goto error;
     }
 
-    bpf_program__set_socket_filter(rss_bpf_ctx->progs.tun_rss_steering_prog);
+    bpf_program__set_type(rss_bpf_ctx->progs.tun_rss_steering_prog, BPF_PROG_TYPE_SOCKET_FILTER);
 
     if (rss_bpf__load(rss_bpf_ctx)) {
         trace_ebpf_error("eBPF RSS", "can not load RSS program");
-- 
2.7.4



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

* Re: [PULL 0/2] Net patches
  2022-07-06  3:47 [PULL 0/2] Net patches Jason Wang
  2022-07-06  3:47 ` [PULL 1/2] e1000: set RX descriptor status in a separate operation Jason Wang
  2022-07-06  3:47 ` [PULL 2/2] ebpf: replace deprecated bpf_program__set_socket_filter Jason Wang
@ 2022-07-06  6:50 ` Richard Henderson
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2022-07-06  6:50 UTC (permalink / raw)
  To: Jason Wang, qemu-devel, peter.maydell

On 7/6/22 09:17, Jason Wang wrote:
> The following changes since commit 39e19f5f67d925c60278a6156fd1776d04495a93:
> 
>    Merge tag 'pull-xen-20220705' of https://xenbits.xen.org/git-http/people/aperard/qemu-dm into staging (2022-07-05 22:13:51 +0530)
> 
> are available in the git repository at:
> 
>    https://github.com/jasowang/qemu.git tags/net-pull-request
> 
> for you to fetch changes up to a495eba03c31c96d6a0817b13598ce2219326691:
> 
>    ebpf: replace deprecated bpf_program__set_socket_filter (2022-07-06 11:39:09 +0800)
> 
> ----------------------------------------------------------------
> 
> ----------------------------------------------------------------
> Ding Hui (1):
>        e1000: set RX descriptor status in a separate operation
> 
> Haochen Tong (1):
>        ebpf: replace deprecated bpf_program__set_socket_filter

Applied, thanks.  Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.


r~


> 
>   ebpf/ebpf_rss.c | 2 +-
>   hw/net/e1000.c  | 5 ++++-
>   2 files changed, 5 insertions(+), 2 deletions(-)
> 
> 
> 



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

end of thread, other threads:[~2022-07-06  6:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06  3:47 [PULL 0/2] Net patches Jason Wang
2022-07-06  3:47 ` [PULL 1/2] e1000: set RX descriptor status in a separate operation Jason Wang
2022-07-06  3:47 ` [PULL 2/2] ebpf: replace deprecated bpf_program__set_socket_filter Jason Wang
2022-07-06  6:50 ` [PULL 0/2] Net patches Richard Henderson

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.