Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yunsheng Lin <linyunsheng@huawei.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	"Linux Kernel Network Developers" <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>
Subject: Re: [PATCH net-next] net: sch_generic: aviod concurrent reset and enqueue op for lockless qdisc
Date: Fri, 4 Sep 2020 16:10:51 +0800	[thread overview]
Message-ID: <5223daf1-a7a2-5d20-7dde-b5b6284f8e02@huawei.com> (raw)
In-Reply-To: <1c01f9e0-fde4-a8ee-caa3-598738a9a98d@gmail.com>

On 2020/9/3 15:24, Eric Dumazet wrote:
> 
> 
> On 9/2/20 6:14 PM, Yunsheng Lin wrote:
> 
>>
>> It seems semantics for some_qdisc_is_busy() is changed, which does not only do
>> the checking, but also do the reseting?
> 
> Yes, obviously, we would have to rename to a better name.
> 
>>
>> Also, qdisc_reset() could be called multi times for the same qdisc if some_qdisc_is_busy()
>> return true multi times?
> 
> This should not matter, qdisc_reset() can be called multiple times,
> as we also call it from qdisc_destroy() anyway.

How about the below patch, which does not need to change the semantics
for some_qdisc_is_busy() and avoid calling qdisc_reset() multi times?


diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 265a61d..ce9031c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -1131,24 +1131,7 @@ 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,
@@ -1165,6 +1148,33 @@ static void dev_deactivate_queue(struct net_device *dev,
 	}
 }

+static void dev_reset_qdisc(struct net_device *dev)
+{
+	unsigned int i;
+
+	for (i = 0; i < dev->num_tx_queues; i++) {
+		struct netdev_queue *dev_queue;
+		struct Qdisc *q;
+		bool nolock;
+
+		dev_queue = netdev_get_tx_queue(dev, i);
+		q = dev_queue->qdisc_sleeping;
+		nolock = q->flags & TCQ_F_NOLOCK;
+
+		if (nolock)
+			spin_lock_bh(&q->seqlock);
+
+		spin_lock_bh(qdisc_lock(q));
+
+		qdisc_reset(q);
+
+		spin_unlock_bh(qdisc_lock(q));
+
+		if (nolock)
+			spin_unlock_bh(&q->seqlock);
+	}
+}
+
 static bool some_qdisc_is_busy(struct net_device *dev)
 {
 	unsigned int i;
@@ -1219,6 +1229,9 @@ void dev_deactivate_many(struct list_head *head)
 	 */
 	synchronize_net();

+	list_for_each_entry(dev, head, close_list)
+		dev_reset_qdisc(dev);
+
 	/* Wait for outstanding qdisc_run calls. */
 	list_for_each_entry(dev, head, close_list) {
 		while (some_qdisc_is_busy(dev)) {



> 
> 

  reply	other threads:[~2020-09-04  8:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01  0:55 Yunsheng Lin
2020-09-01  6:48 ` Eric Dumazet
2020-09-01  7:27   ` Yunsheng Lin
2020-09-01 18:34     ` David Miller
2020-09-02  1:43       ` Yunsheng Lin
2020-09-01 18:24 ` Cong Wang
2020-09-02  1:42   ` Yunsheng Lin
2020-09-02  4:41     ` Cong Wang
2020-09-02  6:34       ` Yunsheng Lin
2020-09-02  7:32         ` Eric Dumazet
2020-09-02  8:14           ` Yunsheng Lin
2020-09-02  9:20             ` Eric Dumazet
2020-09-03  1:14               ` Yunsheng Lin
2020-09-03  7:24                 ` Eric Dumazet
2020-09-04  8:10                   ` Yunsheng Lin [this message]
2020-09-03  0:35         ` Cong Wang
2020-09-03  1:21           ` Yunsheng Lin
2020-09-03  1:48             ` Cong Wang
2020-09-03  2:22               ` Yunsheng Lin
2020-09-03  2:53                 ` Cong Wang
2020-09-04  1:30                   ` John Fastabend
2020-09-04  8:08                     ` Yunsheng Lin
2020-09-06  8:52 ` [net] 6fd0d0dede: hwsim.ap_ht40_5ghz_switch.fail kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5223daf1-a7a2-5d20-7dde-b5b6284f8e02@huawei.com \
    --to=linyunsheng@huawei.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    --subject='Re: [PATCH net-next] net: sch_generic: aviod concurrent reset and enqueue op for lockless qdisc' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).