From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8749AC433E1 for ; Tue, 7 Jul 2020 14:18:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67581206E2 for ; Tue, 7 Jul 2020 14:18:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XgFRUT4H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728362AbgGGOSr (ORCPT ); Tue, 7 Jul 2020 10:18:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48107 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727962AbgGGOSq (ORCPT ); Tue, 7 Jul 2020 10:18:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594131525; 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=h8kfVniZWiVVu/oKiOpIxaI4NJX/9MflF7cI1fe2hxw=; b=XgFRUT4HcXOShdQk2Ui+OFWXFZ2mjdTygs046cplvwerW7V0jSuLQ84ynvnhzXuRFX345a 4Alx57dHcB2lIdFnS0RDI2MMUnW6qrKudY1s9LwRvG7bSHvBFMxpg25jPDnYYiBEZ6HxjX eb7yIvc6ewTgX9eRsvhVIOWdlvTbG/4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-06ZZwhG3MNuqPzddtPf18Q-1; Tue, 07 Jul 2020 10:18:41 -0400 X-MC-Unique: 06ZZwhG3MNuqPzddtPf18Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB4F8461; Tue, 7 Jul 2020 14:18:39 +0000 (UTC) Received: from ovpn-114-17.ams2.redhat.com (ovpn-114-17.ams2.redhat.com [10.36.114.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97F035BAC3; Tue, 7 Jul 2020 14:18:37 +0000 (UTC) Message-ID: Subject: Re: Packet gets stuck in NOLOCK pfifo_fast qdisc From: Paolo Abeni To: Josh Hunt , Jonas Bonn , Cong Wang Cc: Michael Zhivich , David Miller , John Fastabend , LKML , Linux Kernel Network Developers Date: Tue, 07 Jul 2020 16:18:36 +0200 In-Reply-To: <25ca46e4-a8c1-1c88-d6a9-603289ff44c3@akamai.com> References: <465a540e-5296-32e7-f6a6-79942dfe2618@netrounds.com> <20200623134259.8197-1-mzhivich@akamai.com> <1849b74f-163c-8cfa-baa5-f653159fefd4@akamai.com> <7fd86d97-6785-0b5f-1e95-92bc1da9df35@netrounds.com> <500b4843cb7c425ea5449fe199095edd5f7feb0c.camel@redhat.com> <25ca46e4-a8c1-1c88-d6a9-603289ff44c3@akamai.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-07-02 at 11:08 -0700, Josh Hunt wrote: > On 7/2/20 2:45 AM, Paolo Abeni wrote: > > Hi all, > > > > On Thu, 2020-07-02 at 08:14 +0200, Jonas Bonn wrote: > > > Hi Cong, > > > > > > On 01/07/2020 21:58, Cong Wang wrote: > > > > On Wed, Jul 1, 2020 at 9:05 AM Cong Wang wrote: > > > > > On Tue, Jun 30, 2020 at 2:08 PM Josh Hunt wrote: > > > > > > Do either of you know if there's been any development on a fix for this > > > > > > issue? If not we can propose something. > > > > > > > > > > If you have a reproducer, I can look into this. > > > > > > > > Does the attached patch fix this bug completely? > > > > > > It's easier to comment if you inline the patch, but after taking a quick > > > look it seems too simplistic. > > > > > > i) Are you sure you haven't got the return values on qdisc_run reversed? > > > > qdisc_run() returns true if it was able to acquire the seq lock. We > > need to take special action in the opposite case, so Cong's patch LGTM > > from a functional PoV. > > > > > ii) There's a "bypass" path that skips the enqueue/dequeue operation if > > > the queue is empty; that needs a similar treatment: after releasing > > > seqlock it needs to ensure that another packet hasn't been enqueued > > > since it last checked. > > > > That has been reverted with > > commit 379349e9bc3b42b8b2f8f7a03f64a97623fff323 > > > > --- > > > diff --git a/net/core/dev.c b/net/core/dev.c > > > index 90b59fc50dc9..c7e48356132a 100644 > > > --- a/net/core/dev.c > > > +++ b/net/core/dev.c > > > @@ -3744,7 +3744,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, > > > > > > if (q->flags & TCQ_F_NOLOCK) { > > > rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK; > > > - qdisc_run(q); > > > + if (!qdisc_run(q) && rc == NET_XMIT_SUCCESS) > > > + __netif_schedule(q); > > > > I fear the __netif_schedule() call may cause performance regression to > > the point of making a revert of TCQ_F_NOLOCK preferable. I'll try to > > collect some data. > > Initial results with Cong's patch look promising, so far no stalls. We > will let it run over the long weekend and report back on Tuesday. > > Paolo - I have concerns about possible performance regression with the > change as well. If you can gather some data that would be great. I finally had the time to run some performance tests vs the above with mixed results. Using several netperf threadsover a single pfifo_fast queue with small UDP packets, perf differences vs vanilla are just above noise range (1- 1,5%) Using pktgen in 'queue_xmit' mode on a dummy device (this should maximise the pkt-rate and thus the contention) I see: pktgen threads vanilla patched delta nr kpps kpps % 1 3240 3240 0 2 3910 2710 -30.5 4 5140 4920 -4 A relevant source of the measured overhead is due to the contention on q->state in __netif_schedule, so the following helps a bit: --- diff --git a/net/core/dev.c b/net/core/dev.c index b8e8286a0a34..3cad6e086fac 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3750,7 +3750,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, if (q->flags & TCQ_F_NOLOCK) { rc = q->enqueue(skb, q, NULL, &to_free) & NET_XMIT_MASK; - if (!qdisc_run(q) && rc == NET_XMIT_SUCCESS) + if (!qdisc_run(q) && rc == NET_XMIT_SUCCESS && + !test_bit(__QDISC_STATE_SCHED, &q->state)) __netif_schedule(q); if (unlikely(to_free)) --- With the above incremental patch applied I see: pktgen threads vanilla patched[II] delta nr kpps kpps % 1 3240 3240 0 2 3910 2830 -27% 4 5140 5140 0 So the regression with 2 pktgen threads is still relevant. 'perf' shows relevant time spent into net_tx_action() and __netif_schedule(). Cheers, Paolo.