From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0853AEC4 for ; Wed, 11 Jun 2025 00:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749601540; cv=none; b=o1C8FOZZ2sBpP3ItQQMDPuv9g+NvMaIWbSAM+dq9OKPbZppQF6ACBb1m8buafVrWEHitHdv6XalrOOv62VX/QQfEN9Rd7KOdqpNG4atkRuz0HrmhQhHzIuOuR0ONPy9c45QKGqJ/NjSpr8wwjFcb5OyZwht6ZgSy70zcT1IoN8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749601540; c=relaxed/simple; bh=mFag4hz+lv7bx3Z8BEnZDowZA4eQdv8p3Ld0WnRSmX8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RMx+v8U/JeoMzyBeYVb9ymx+HdIpvQPfhwasK8SO5rL1ZLaK63MY6mM97la3VzveattaezolRt1cHS/yDis4+ERfOI7tIs5yAdCMd2mLAMDX0GxK1kXBeJcFkAL2jQfyEpmC24gpuCb8sog9IMY/A6S8UJDa4gRYCOW6tTpIOg0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=l5JDaIli; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="l5JDaIli" Message-ID: <68106010-f34b-45a8-aaf5-003f5c925c01@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1749601536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OH4ApGYmn/DMBgrAa1vHydYXZRuq4f/WNOze5miWktY=; b=l5JDaIliqGax9nCiNWoNNyi6hrwme+E9qfvM4NE+RsJJRlu5WXkURDmC6mSALN3pvWi2fT KB7lFOOEFR33expXmQ8uf9HaXAtdb/Y0IiimPuL7R+vl9UBPpYxqMFvhBfws5hyhjqd9eo n+AUEuKPTVtDEYA5GI3fj6j0xfp2boo= Date: Tue, 10 Jun 2025 17:25:26 -0700 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net-next V7 2/2] veth: apply qdisc backpressure on full ptr_ring to reduce TX drops To: Jesper Dangaard Brouer , netdev@vger.kernel.org, Jakub Kicinski , Bastien Curutchet Cc: bpf@vger.kernel.org, tom@herbertland.com, Eric Dumazet , "David S. Miller" , Paolo Abeni , =?UTF-8?Q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , dsahern@kernel.org, makita.toshiaki@lab.ntt.co.jp, kernel-team@cloudflare.com, phil@nwl.cc, Sebastian Andrzej Siewior References: <174559288731.827981.8748257839971869213.stgit@firesoul> <174559294022.827981.1282809941662942189.stgit@firesoul> <46a47776-dcd9-4c6f-8d71-f94b22b077e2@kernel.org> <6812c58a-4f33-46b5-8886-1198e36823ed@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Ihor Solodrai In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 6/10/25 2:40 PM, Jesper Dangaard Brouer wrote: > > > On 10/06/2025 20.26, Ihor Solodrai wrote: >> On 6/10/25 8:56 AM, Jesper Dangaard Brouer wrote: >>> >>> >>> On 10/06/2025 13.43, Jesper Dangaard Brouer wrote: >>>> >>>> On 10/06/2025 00.09, Ihor Solodrai wrote: >>> [...] >>>> >>>> Can you give me the output from below command (on your compiled >>>> kernel): >>>> >>>>   ./scripts/faddr2line drivers/net/veth.o veth_xdp_rcv.constprop.0+0x6b >>>> >>> >>> Still need above data/info please. >> >> root@devvm7589:/ci/workspace# ./scripts/faddr2line ./kout.gcc/drivers/ >> net/veth.o veth_xdp_rcv.constprop.0+0x6b >> veth_xdp_rcv.constprop.0+0x6b/0x390: >> netdev_get_tx_queue at /ci/workspace/kout.gcc/../include/linux/ >> netdevice.h:2637 >> (inlined by) veth_xdp_rcv at /ci/workspace/kout.gcc/../drivers/net/ >> veth.c:912 >> >> Which is: >> >> veth.c:912 >>      struct veth_priv *priv = netdev_priv(rq->dev); >>      int queue_idx = rq->xdp_rxq.queue_index; >>      struct netdev_queue *peer_txq; >>      struct net_device *peer_dev; >>      int i, done = 0, n_xdpf = 0; >>      void *xdpf[VETH_XDP_BATCH]; >> >>      /* NAPI functions as RCU section */ >>      peer_dev = rcu_dereference_check(priv->peer, >> rcu_read_lock_bh_held()); >>   --->    peer_txq = netdev_get_tx_queue(peer_dev, queue_idx); >> >> netdevice.h:2637 >>      static inline >>      struct netdev_queue *netdev_get_tx_queue(const struct net_device >> *dev, >>                       unsigned int index) >>      { >>          DEBUG_NET_WARN_ON_ONCE(index >= dev->num_tx_queues); >>   --->        return &dev->_tx[index]; >>      } >> >> So the suspect is peer_dev (priv->peer)? > > Yes, this is the problem! > > So, it seems that peer_dev (priv->peer) can become a NULL pointer. > > Managed to reproduce - via manually deleting the peer device: >  - ip link delete dev veth42 >  - while overloading veth41 via XDP redirecting packets into it. > > Managed to trigger concurrent crashes on two CPUs (C0 + C3) >  - so below output gets interlaced a bit: > > [...] > > A fix could look like this: > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index e58a0f1b5c5b..a3046142cb8e 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -909,7 +909,7 @@ static int veth_xdp_rcv(struct veth_rq *rq, int budget, > >         /* NAPI functions as RCU section */ >         peer_dev = rcu_dereference_check(priv->peer, > rcu_read_lock_bh_held()); > -       peer_txq = netdev_get_tx_queue(peer_dev, queue_idx); > +       peer_txq = peer_dev ? netdev_get_tx_queue(peer_dev, queue_idx) : > NULL; > >         for (i = 0; i < budget; i++) { >                 void *ptr = __ptr_ring_consume(&rq->xdp_ring); > @@ -959,7 +959,7 @@ static int veth_xdp_rcv(struct veth_rq *rq, int budget, >         rq->stats.vs.xdp_packets += done; >         u64_stats_update_end(&rq->stats.syncp); > > -       if (unlikely(netif_tx_queue_stopped(peer_txq))) > +       if (peer_txq && unlikely(netif_tx_queue_stopped(peer_txq))) >                 netif_tx_wake_queue(peer_txq); > Great! I presume you will send a patch separately? > > > > --Jesper > >