[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231201083926.1817394-1-judyhsiao@chromium.org>
Date: Fri, 1 Dec 2023 08:39:03 +0000
From: Judy Hsiao <judyhsiao@...omium.org>
To: Eric Dumazet <edumazet@...gle.com>,
David Ahern <dsahern@...nel.org>,
Simon Horman <horms@...nel.org>
Cc: Douglas Anderson <dianders@...omium.org>,
Judy Hsiao <judyhsiao@...omium.org>,
Brian Haley <haleyb.dev@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Joel Granados <joel.granados@...il.com>,
Julian Anastasov <ja@....bg>,
Leon Romanovsky <leon@...nel.org>,
Luis Chamberlain <mcgrof@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: [PATCH v1] neighbour: Don't let neigh_forced_gc() disable preemption for long
We are seeing cases where neigh_cleanup_and_release() is called by
neigh_forced_gc() many times in a row with preemption turned off.
When running on a low powered CPU at a low CPU frequency, this has
been measured to keep preemption off for ~10 ms. That's not great on a
system with HZ=1000 which expects tasks to be able to schedule in
with ~1ms latency.
Suggested-by: Douglas Anderson <dianders@...omium.org>
Signed-off-by: Judy Hsiao <judyhsiao@...omium.org>
---
net/core/neighbour.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index df81c1f0a570..f7a89c7a7673 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -256,6 +256,8 @@ static int neigh_forced_gc(struct neigh_table *tbl)
unsigned long tref = jiffies - 5 * HZ;
struct neighbour *n, *tmp;
int shrunk = 0;
+ bool finish = true;
+ unsigned long timeout = jiffies + msecs_to_jiffies(1); /* timeout in 1ms */
NEIGH_CACHE_STAT_INC(tbl, forced_gc_runs);
@@ -278,10 +280,14 @@ static int neigh_forced_gc(struct neigh_table *tbl)
shrunk++;
if (shrunk >= max_clean)
break;
+ if (time_after(jiffies, timeout)) {
+ finish = false;
+ break;
+ }
}
}
-
- WRITE_ONCE(tbl->last_flush, jiffies);
+ if (finish)
+ WRITE_ONCE(tbl->last_flush, jiffies);
write_unlock_bh(&tbl->lock);
--
2.43.0.rc2.451.g8631bc7472-goog
Powered by blists - more mailing lists