diff mbox series

[v2,net-next] tcp: add a scheduling point in established_get_first()

Message ID 20230711032405.3253025-1-wenjian1@xiaomi.com (mailing list archive)
State Accepted
Commit 9f4a7c930284bf2b5b84d3636a8e88857149328f
Delegated to: Netdev Maintainers
Headers show
Series [v2,net-next] tcp: add a scheduling point in established_get_first() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1360 this patch: 1360
netdev/cc_maintainers warning 3 maintainers not CCed: kuba@kernel.org dsahern@kernel.org pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 1364 this patch: 1364
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1383 this patch: 1383
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Jian Wen <wenjianhn@gmail.com>' != 'Signed-off-by: Jian Wen <wenjian1@xiaomi.com>'
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jian Wen July 11, 2023, 3:24 a.m. UTC
Kubernetes[1] is going to stick with /proc/net/tcp for a while.

This commit reduces the scheduling latency introduced by
established_get_first(), similar to commit acffb584cda7 ("net: diag:
add a scheduling point in inet_diag_dump_icsk()").

In our environment, the scheduling latency affects the performance of
latency-sensitive services like Redis.

Changes in V2 :
 - call cond_resched() before checking if a bucket is empty as
   suggested by Eric Dumazet
 - removed the delay of synchronize_net() from the commit message

[1] https://github.com/google/cadvisor/blob/v0.47.2/container/libcontainer/handler.go#L130

Signed-off-by: Jian Wen <wenjian1@xiaomi.com>
---
 net/ipv4/tcp_ipv4.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Simon Horman July 12, 2023, 1:22 p.m. UTC | #1
On Tue, Jul 11, 2023 at 11:24:05AM +0800, Jian Wen wrote:
> Kubernetes[1] is going to stick with /proc/net/tcp for a while.
> 
> This commit reduces the scheduling latency introduced by
> established_get_first(), similar to commit acffb584cda7 ("net: diag:
> add a scheduling point in inet_diag_dump_icsk()").
> 
> In our environment, the scheduling latency affects the performance of
> latency-sensitive services like Redis.
> 
> Changes in V2 :
>  - call cond_resched() before checking if a bucket is empty as
>    suggested by Eric Dumazet
>  - removed the delay of synchronize_net() from the commit message
> 
> [1] https://github.com/google/cadvisor/blob/v0.47.2/container/libcontainer/handler.go#L130
> 
> Signed-off-by: Jian Wen <wenjian1@xiaomi.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
patchwork-bot+netdevbpf@kernel.org July 12, 2023, 9:50 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 11 Jul 2023 11:24:05 +0800 you wrote:
> Kubernetes[1] is going to stick with /proc/net/tcp for a while.
> 
> This commit reduces the scheduling latency introduced by
> established_get_first(), similar to commit acffb584cda7 ("net: diag:
> add a scheduling point in inet_diag_dump_icsk()").
> 
> In our environment, the scheduling latency affects the performance of
> latency-sensitive services like Redis.
> 
> [...]

Here is the summary with links:
  - [v2,net-next] tcp: add a scheduling point in established_get_first()
    https://git.kernel.org/netdev/net-next/c/9f4a7c930284

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index fd365de4d5ff..cecd5a135e64 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -57,6 +57,7 @@ 
 #include <linux/init.h>
 #include <linux/times.h>
 #include <linux/slab.h>
+#include <linux/sched.h>
 
 #include <net/net_namespace.h>
 #include <net/icmp.h>
@@ -2446,6 +2447,8 @@  static void *established_get_first(struct seq_file *seq)
 		struct hlist_nulls_node *node;
 		spinlock_t *lock = inet_ehash_lockp(hinfo, st->bucket);
 
+		cond_resched();
+
 		/* Lockless fast path for the common case of empty buckets */
 		if (empty_bucket(hinfo, st))
 			continue;