From patchwork Wed May 27 04:35:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 218461 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 ED134C433E1 for ; Wed, 27 May 2020 04:35:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB00220776 for ; Wed, 27 May 2020 04:35:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h7LXFZsl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbgE0Efw (ORCPT ); Wed, 27 May 2020 00:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725849AbgE0Efu (ORCPT ); Wed, 27 May 2020 00:35:50 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5126CC061A0F for ; Tue, 26 May 2020 21:35:50 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id x13so11264603pfn.11 for ; Tue, 26 May 2020 21:35:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EkzL/BGsNUdUyg3y8Xr2lfREoy2cCNVAC2wqTo+1JDs=; b=h7LXFZslmc+Bi5sNYTbziMMVzRI099vHfYyOMB8RAmbCCgfm1aFFIerago/QkJwUOj iTnm4b8xhaNewmBms44moVI1f2oQ0T8v3i1ar80nl8X2T3+f0/DuhEvWPVQXFTndsijA RBK2TKBolgmX+0o0k2FfSBIk+eZHQwz7TuKfN6Fbg4wspblkKEehO6HTjd7GFlZQ4QTo rtbX1abl9m+aBUoVgvCnx5r4Aur5FoSgqgOi2HDDGu8VCHsNIdfihKQF6xwrTT5wKgcp yIlzZ+3ohLzpoYWdBs0pKG538YJkLxuxr9BNe0w+16KN31g3LK+gZkaLlcZ2aAgId5gy grpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EkzL/BGsNUdUyg3y8Xr2lfREoy2cCNVAC2wqTo+1JDs=; b=KsUCfgzDNkqfLKy6He1wbFf0lbkA8+o7fwC6+5NVa3MTafbkfG+QX8OeShuyQyMRvA ODcFG8xXWoNbF0H/skHjaalp0UouLn9FTFW5zLdpsJ6iDGSfVZOApgq6D7syqwEZXR3O EG7fyE6IYgaPTXLwuFjbT2SvCGgcrhOSvIEQVxtgb5TfEWMAjR+5ySHKDwk0r8wvM7Z8 /nh7XP/bzxdoi7iD2J5SVfK3hs8Ph4nfG58PWqLeBgQMYlcLEFiCStbm4RilSALCdStZ CThR73pb6xgupfPa/mP1/AOrssgdCtDnyO8AqJ+Zexh6uHAFCGRkmSFAt7YPDXJ45qxT 4xPQ== X-Gm-Message-State: AOAM533ChlXllU+FE9bsBuj/BTuLP5YYjksUhfhMTbX1L1ZOih5OcDNp 6uNZjbXpcjCECREKsHcZSmFppqHk X-Google-Smtp-Source: ABdhPJwai22rzW/SVUzbC7Gf4nnYH2eJcULBtI6cU6o6IGBKGwROf7uMYGFTp0Qb6PrGuAT9WySLeQ== X-Received: by 2002:a63:1f0e:: with SMTP id f14mr1906154pgf.405.1590554149727; Tue, 26 May 2020 21:35:49 -0700 (PDT) Received: from MacBookAir.linux-6brj.site (99-174-169-255.lightspeed.sntcca.sbcglobal.net. [99.174.169.255]) by smtp.gmail.com with ESMTPSA id 62sm884990pfc.204.2020.05.26.21.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 21:35:49 -0700 (PDT) From: Cong Wang To: netdev@vger.kernel.org Cc: vaclav.zindulka@tlapnet.cz, Cong Wang , Jamal Hadi Salim , Jiri Pirko Subject: [Patch net-next 1/5] net_sched: use qdisc_reset() in qdisc_destroy() Date: Tue, 26 May 2020 21:35:23 -0700 Message-Id: <20200527043527.12287-2-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200527043527.12287-1-xiyou.wangcong@gmail.com> References: <20200527043527.12287-1-xiyou.wangcong@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org qdisc_destroy() calls ops->reset() and cleans up qdisc->gso_skb and qdisc->skb_bad_txq, these are nearly same with qdisc_reset(), so just call it directly, and cosolidate the code for the next patch. Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang --- net/sched/sch_generic.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index ebc55d884247..7a0b06001e48 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -949,7 +949,6 @@ static void qdisc_free_cb(struct rcu_head *head) static void qdisc_destroy(struct Qdisc *qdisc) { const struct Qdisc_ops *ops = qdisc->ops; - struct sk_buff *skb, *tmp; #ifdef CONFIG_NET_SCHED qdisc_hash_del(qdisc); @@ -957,24 +956,15 @@ static void qdisc_destroy(struct Qdisc *qdisc) qdisc_put_stab(rtnl_dereference(qdisc->stab)); #endif gen_kill_estimator(&qdisc->rate_est); - if (ops->reset) - ops->reset(qdisc); + + qdisc_reset(qdisc); + if (ops->destroy) ops->destroy(qdisc); module_put(ops->owner); dev_put(qdisc_dev(qdisc)); - skb_queue_walk_safe(&qdisc->gso_skb, skb, tmp) { - __skb_unlink(skb, &qdisc->gso_skb); - kfree_skb_list(skb); - } - - skb_queue_walk_safe(&qdisc->skb_bad_txq, skb, tmp) { - __skb_unlink(skb, &qdisc->skb_bad_txq); - kfree_skb_list(skb); - } - call_rcu(&qdisc->rcu, qdisc_free_cb); } From patchwork Wed May 27 04:35:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 218460 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 0FDDBC433E0 for ; Wed, 27 May 2020 04:36:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2A6320899 for ; Wed, 27 May 2020 04:35:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ta1CpHpM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727879AbgE0Ef7 (ORCPT ); Wed, 27 May 2020 00:35:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725849AbgE0Efy (ORCPT ); Wed, 27 May 2020 00:35:54 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66316C061A0F for ; Tue, 26 May 2020 21:35:53 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id cx22so996300pjb.1 for ; Tue, 26 May 2020 21:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F3APV1bDQLXitPHVMpvETixDyrO0aAHo7NHW9tfZ46o=; b=Ta1CpHpM9yrM5FimLbCB8GmKTOGqxncrFr7VbJH5S1WpyyYx4D4AhHngmXatCgksWm KhoM9z8FKbOOr7ZvYLcL+xJq33fp6mCztZ7rfeYTwkFFRqxfN6z5SsSoB9HZFH6tXfe9 6v3OZjM6CXpE7QP7Q4rAFViBklPbsB+7hFrPRFiBi6CgbLPpmNITrYRpQ5x64UwzTOb3 fhmppcU+Zh7rfmuSl8E4DfIX57UjXLoWWrfpminSqcZaiBc34auH/kUwNb2XGkGfl2Fw RBBnGQubFaD+FTOhpa4Y1JmloF9TR6+tFGxhd7yq42+u4YxI6uqUC2WyXfOkbEV49rBT ldiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F3APV1bDQLXitPHVMpvETixDyrO0aAHo7NHW9tfZ46o=; b=rDMEF6GTvkLlf8WqQ+oIkZkehc0dd9fKf1ZjFy/QP1Mbi1keSpVNz5V4zCwjF+31Zg EXEURfwgQOjItyAK3NpPZNozCKSR9uZMsEU2JX6ju2SWwZwtnTKJJaXqSCp4iRFYSCFi AiFc/23qyA6E14u6Ep1Kleo8+HizJzwM31TbUnVcNm4+gbSzeTTKHDEbJHhehTQFHKpg qsZp63zUHXWFxH+xsQjNckELo8UXltX5pmpOaB+gfMIdy5nyxMKWZkna9nsDBEYxm2AE UJXxHAHtP/QNhMrF2CPlzhCCW8Uu9uTYBLuXGAV45dLE+BlAmYIRwoo4HPcs2MhpecR7 CTdg== X-Gm-Message-State: AOAM531/cVBDPmH6/AEkld9xs+fexUJ2/sccsEYC7frdYdsJysrCNFh0 Uw9ZDL8+ASOxCMPhm1LvX9nQyp62 X-Google-Smtp-Source: ABdhPJyVgET4dWoWEiqxJyspUJtHVGXMedj4nMI8oP0vxuWSNZCGfoe2a591Ubq4dqa1n60ULXDpbw== X-Received: by 2002:a17:902:7045:: with SMTP id h5mr4261779plt.108.1590554151743; Tue, 26 May 2020 21:35:51 -0700 (PDT) Received: from MacBookAir.linux-6brj.site (99-174-169-255.lightspeed.sntcca.sbcglobal.net. [99.174.169.255]) by smtp.gmail.com with ESMTPSA id 62sm884990pfc.204.2020.05.26.21.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 21:35:51 -0700 (PDT) From: Cong Wang To: netdev@vger.kernel.org Cc: vaclav.zindulka@tlapnet.cz, Cong Wang , Jamal Hadi Salim , Jiri Pirko Subject: [Patch net-next 3/5] net_sched: add a tracepoint for qdisc creation Date: Tue, 26 May 2020 21:35:25 -0700 Message-Id: <20200527043527.12287-4-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200527043527.12287-1-xiyou.wangcong@gmail.com> References: <20200527043527.12287-1-xiyou.wangcong@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With this tracepoint, we could know when qdisc's are created, especially those default qdisc's. Sample output: tc-736 [001] ...1 56.230107: qdisc_create: dev=ens3 kind=pfifo parent=1:0 tc-736 [001] ...1 56.230113: qdisc_create: dev=ens3 kind=hfsc parent=ffff:ffff tc-738 [001] ...1 56.256816: qdisc_create: dev=ens3 kind=pfifo parent=1:100 tc-739 [001] ...1 56.267584: qdisc_create: dev=ens3 kind=pfifo parent=1:200 tc-740 [001] ...1 56.279649: qdisc_create: dev=ens3 kind=fq_codel parent=1:100 tc-741 [001] ...1 56.289996: qdisc_create: dev=ens3 kind=pfifo_fast parent=1:200 tc-745 [000] .N.1 111.687483: qdisc_create: dev=ens3 kind=ingress parent=ffff:fff1 Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang --- include/trace/events/qdisc.h | 23 +++++++++++++++++++++++ net/sched/sch_api.c | 3 +++ net/sched/sch_generic.c | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/trace/events/qdisc.h b/include/trace/events/qdisc.h index 2b948801afa3..330d32d84485 100644 --- a/include/trace/events/qdisc.h +++ b/include/trace/events/qdisc.h @@ -96,6 +96,29 @@ TRACE_EVENT(qdisc_destroy, TC_H_MAJ(__entry->handle) >> 16, TC_H_MIN(__entry->handle)) ); +TRACE_EVENT(qdisc_create, + + TP_PROTO(const struct Qdisc_ops *ops, struct net_device *dev, u32 parent), + + TP_ARGS(ops, dev, parent), + + TP_STRUCT__entry( + __string( dev, dev->name ) + __string( kind, ops->id ) + __field( u32, parent ) + ), + + TP_fast_assign( + __assign_str(dev, dev->name); + __assign_str(kind, ops->id); + __entry->parent = parent; + ), + + TP_printk("dev=%s kind=%s parent=%x:%x", + __get_str(dev), __get_str(kind), + TC_H_MAJ(__entry->parent) >> 16, TC_H_MIN(__entry->parent)) +); + #endif /* _TRACE_QDISC_H */ /* This part must be outside protection */ diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 0d99df1e764d..9a3449b56bd6 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -32,6 +32,8 @@ #include #include +#include + /* Short review. @@ -1283,6 +1285,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev, } qdisc_hash_add(sch, false); + trace_qdisc_create(ops, dev, parent); return sch; diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index abaa446ed01a..a4271e47f220 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -896,8 +896,10 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, } sch->parent = parentid; - if (!ops->init || ops->init(sch, NULL, extack) == 0) + if (!ops->init || ops->init(sch, NULL, extack) == 0) { + trace_qdisc_create(ops, dev_queue->dev, parentid); return sch; + } qdisc_put(sch); return NULL; From patchwork Wed May 27 04:35:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 218459 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 768F9C433E2 for ; Wed, 27 May 2020 04:36:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51FAB20776 for ; Wed, 27 May 2020 04:36:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Kctgp9Xc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727844AbgE0Ef5 (ORCPT ); Wed, 27 May 2020 00:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbgE0Efy (ORCPT ); Wed, 27 May 2020 00:35:54 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C187C03E97B for ; Tue, 26 May 2020 21:35:53 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id bg4so4368121plb.3 for ; Tue, 26 May 2020 21:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/AZAmQTqbydzaxgqXP5EEC8VbRpGCwfPz1YWJZenrqA=; b=Kctgp9Xcumlt2TrX8R2o/iVja5OYM34tMqCEUUh27g7JiRDCuhzoiP6UWLLFnekXuz od1IwPuZYQE3EKj2X3BKAQ6Ohgw/7Q/NM8h5fxTSmNj82Cg7df9iKPd93B0hXDZFYb3w 9VZdKplr0m/O+Lposfe0wk1aX8yXn047pM29JurvV0hcuVvOzOxkKDtjOK8NCZ3hOSTi APmSAG/Is/ym5RrQXbA0hpHJes5ZbqxlH+I56P8IRfjVAUmznTJUUg8C82lEkOfBoBCw i4xEV0Cn6QwrsBr7bWlUnjyeIUsx7OOYli3mV+xAFMuXq0zwEowGx41v+AVHoAPpXY1N oExg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/AZAmQTqbydzaxgqXP5EEC8VbRpGCwfPz1YWJZenrqA=; b=Weepo7ulB5DyjQ7oH5ne7Jm8vw7CtTavc5k4BAW3aYukgEs5GDg86lT6XVEdFAg6xZ 7JZF8EZNtUgbbAY93yUYijs5UYbUOGVO7iWeHuda1b3bfGAaUwXbrFc56WNa9Oj6I17s xWSgidW+2O00S/UXluqmAbkkmo2rULsGHf6HeYFR9VFan3tjqbdJciRskK5S4B6BJYQ8 zF31PAxElczUMWlvbkuwWoeULj/+rSqV/DxYx+9wh40RbiVntXC4FTnEP1S5vXzddZQ3 KJoLGkmQqQjyz3jl7z6n3awdU7hwRZ4dcWUcY0cnjgS34rZmdpXitxnxUKZZYNqyM1ki SPiA== X-Gm-Message-State: AOAM532ZQoBxw5vuiTgey3LzvFtSAA9kYnmVP0LcbfzVBNrDsKTvsn/s r0PI+906TGMarXtrqx7MBOWUoXok X-Google-Smtp-Source: ABdhPJzputeRZ/n6FwzCxtP1s52zCg8fV1TB+YcwBGReUr7Oba0GG2T+IDKtlXFwgqqzn5RkHS+5IQ== X-Received: by 2002:a17:902:bd42:: with SMTP id b2mr4024348plx.219.1590554152876; Tue, 26 May 2020 21:35:52 -0700 (PDT) Received: from MacBookAir.linux-6brj.site (99-174-169-255.lightspeed.sntcca.sbcglobal.net. [99.174.169.255]) by smtp.gmail.com with ESMTPSA id 62sm884990pfc.204.2020.05.26.21.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 21:35:52 -0700 (PDT) From: Cong Wang To: netdev@vger.kernel.org Cc: vaclav.zindulka@tlapnet.cz, Cong Wang , Jamal Hadi Salim , Jiri Pirko Subject: [Patch net-next 4/5] net_sched: avoid resetting active qdisc for multiple times Date: Tue, 26 May 2020 21:35:26 -0700 Message-Id: <20200527043527.12287-5-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200527043527.12287-1-xiyou.wangcong@gmail.com> References: <20200527043527.12287-1-xiyou.wangcong@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Except for sch_mq and sch_mqprio, each dev queue points to the same root qdisc, so when we reset the dev queues with netdev_for_each_tx_queue() we end up resetting the same instance of the root qdisc for multiple times. Avoid this by checking the __QDISC_STATE_DEACTIVATED bit in each iteration, so for sch_mq/sch_mqprio, we still reset all of them like before, for the rest, we only reset it once. Reported-by: Václav Zindulka Tested-by: Václav Zindulka Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang --- net/sched/sch_generic.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index a4271e47f220..d13e27467470 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -1128,6 +1128,28 @@ void dev_activate(struct net_device *dev) } EXPORT_SYMBOL(dev_activate); +static void qdisc_deactivate(struct Qdisc *qdisc) +{ + bool nolock = qdisc->flags & TCQ_F_NOLOCK; + + if (qdisc->flags & TCQ_F_BUILTIN) + return; + if (test_bit(__QDISC_STATE_DEACTIVATED, &qdisc->state)) + return; + + if (nolock) + spin_lock_bh(&qdisc->seqlock); + spin_lock_bh(qdisc_lock(qdisc)); + + set_bit(__QDISC_STATE_DEACTIVATED, &qdisc->state); + + qdisc_reset(qdisc); + + spin_unlock_bh(qdisc_lock(qdisc)); + if (nolock) + spin_unlock_bh(&qdisc->seqlock); +} + static void dev_deactivate_queue(struct net_device *dev, struct netdev_queue *dev_queue, void *_qdisc_default) @@ -1137,21 +1159,8 @@ static void dev_deactivate_queue(struct net_device *dev, qdisc = rtnl_dereference(dev_queue->qdisc); if (qdisc) { - bool nolock = qdisc->flags & TCQ_F_NOLOCK; - - if (nolock) - spin_lock_bh(&qdisc->seqlock); - spin_lock_bh(qdisc_lock(qdisc)); - - if (!(qdisc->flags & TCQ_F_BUILTIN)) - set_bit(__QDISC_STATE_DEACTIVATED, &qdisc->state); - + qdisc_deactivate(qdisc); rcu_assign_pointer(dev_queue->qdisc, qdisc_default); - qdisc_reset(qdisc); - - spin_unlock_bh(qdisc_lock(qdisc)); - if (nolock) - spin_unlock_bh(&qdisc->seqlock); } }