Netdev List
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: shemminger@linux-foundation.org
Cc: netdev@vger.kernel.org
Subject: Re: new NAPI quota synchronization issue
Date: Wed, 19 Sep 2007 15:10:32 -0700 (PDT)	[thread overview]
Message-ID: <20070919.151032.118951762.davem@davemloft.net> (raw)
In-Reply-To: <20070919150129.7b0967f7@freepuppy.rosehill.hemminger.net>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Wed, 19 Sep 2007 15:01:29 -0700

> There might be a future problem if some driver decided to change
> weight often on the fly?  Perhaps you need to sample it once in
> start of napi_schedule.

Fair enough, I checked the following into net-2.6.24

commit 3b4eed9f46e4b0405a0d8921c2319f2b7c6a6b4a
Author: David S. Miller <davem@sunset.davemloft.net>
Date:   Wed Sep 19 15:09:55 2007 -0700

    [NAPI]: Sample weight into a local var in case it changes.
    
    Noted by Stephen Hemminger.
    
    Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/net/core/dev.c b/net/core/dev.c
index 0b9f82e..91c31e6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2136,7 +2136,7 @@ static void net_rx_action(struct softirq_action *h)
 
 	while (!list_empty(list)) {
 		struct napi_struct *n;
-		int work;
+		int work, weight;
 
 		/* If softirq window is exhuasted then punt.
 		 *
@@ -2159,9 +2159,11 @@ static void net_rx_action(struct softirq_action *h)
 
 		have = netpoll_poll_lock(n);
 
-		work = n->poll(n, n->weight);
+		weight = n->weight;
 
-		WARN_ON_ONCE(work > n->weight);
+		work = n->poll(n, weight);
+
+		WARN_ON_ONCE(work > weight);
 
 		budget -= work;
 
@@ -2172,7 +2174,7 @@ static void net_rx_action(struct softirq_action *h)
 		 * still "owns" the NAPI instance and therefore can
 		 * move the instance around on the list at-will.
 		 */
-		if (unlikely(work == n->weight))
+		if (unlikely(work == weight))
 			list_move_tail(&n->poll_list, list);
 
 		netpoll_poll_unlock(have);

      reply	other threads:[~2007-09-19 22:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-19 16:58 new NAPI quota synchronization issue David Miller
2007-09-19 17:35 ` David Miller
2007-09-19 22:01   ` Stephen Hemminger
2007-09-19 22:10     ` David Miller [this message]

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=20070919.151032.118951762.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@linux-foundation.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox