mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] neighbour: Don't let neigh_forced_gc() disable preemption for long
@ 2023-12-01  8:39 Judy Hsiao
  2023-12-01  9:10 ` Eric Dumazet
  0 siblings, 1 reply; 12+ messages in thread
From: Judy Hsiao @ 2023-12-01  8:39 UTC (permalink / raw)
  To: Eric Dumazet, David Ahern, Simon Horman
  Cc: Douglas Anderson, Judy Hsiao, Brian Haley, David S. Miller,
	Jakub Kicinski, Joel Granados, Julian Anastasov, Leon Romanovsky,
	Luis Chamberlain, Paolo Abeni, linux-kernel, netdev

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@chromium.org>
Signed-off-by: Judy Hsiao <judyhsiao@chromium.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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-12-05  8:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-01  8:39 [PATCH v1] neighbour: Don't let neigh_forced_gc() disable preemption for long Judy Hsiao
2023-12-01  9:10 ` Eric Dumazet
2023-12-01 15:16   ` Doug Anderson
2023-12-01 15:58     ` Eric Dumazet
2023-12-01 17:16       ` Doug Anderson
2023-12-01 17:35         ` Eric Dumazet
2023-12-01 18:40           ` Doug Anderson
2023-12-01 18:21         ` Julian Anastasov
2023-12-04 23:40   ` Doug Anderson
2023-12-05  1:08     ` David Ahern
2023-12-05  8:00     ` Eric Dumazet
2023-12-05  8:15       ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®