All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next,v2] cgroup, netclassid: on modifying netclassid in cgroup, only consider the main process.
@ 2023-10-12  9:03 Liansen Zhai
  2023-10-16  9:28 ` Simon Horman
  2023-10-16 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Liansen Zhai @ 2023-10-12  9:03 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, zhailiansen, yuwang, wushukun, Liansen Zhai

When modifying netclassid, the command("echo 0x100001 > net_cls.classid")
will take more time on many threads of one process, because the process
create many fds.
for example, one process exists 28000 fds and 60000 threads, echo command
will task 45 seconds.
Now, we only consider the main process when exec "iterate_fd", and the
time is about 52 milliseconds.

Signed-off-by: Liansen Zhai <zhailiansen@kuaishou.com>
---
 net/core/netclassid_cgroup.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
index d6a70ae..d22f091 100644
--- a/net/core/netclassid_cgroup.c
+++ b/net/core/netclassid_cgroup.c
@@ -88,6 +88,12 @@ static void update_classid_task(struct task_struct *p, u32 classid)
 	};
 	unsigned int fd = 0;
 
+	/* Only update the leader task, when many threads in this task,
+	 * so it can avoid the useless traversal.
+	 */
+	if (p != p->group_leader)
+		return;
+
 	do {
 		task_lock(p);
 		fd = iterate_fd(p->files, fd, update_classid_sock, &ctx);
-- 
1.8.3.1


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

* Re: [PATCH net-next,v2] cgroup, netclassid: on modifying netclassid in cgroup, only consider the main process.
  2023-10-12  9:03 [PATCH net-next,v2] cgroup, netclassid: on modifying netclassid in cgroup, only consider the main process Liansen Zhai
@ 2023-10-16  9:28 ` Simon Horman
  2023-10-16 23:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-10-16  9:28 UTC (permalink / raw)
  To: Liansen Zhai
  Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel, yuwang,
	wushukun, Liansen Zhai

On Thu, Oct 12, 2023 at 05:03:30PM +0800, Liansen Zhai wrote:
> When modifying netclassid, the command("echo 0x100001 > net_cls.classid")
> will take more time on many threads of one process, because the process
> create many fds.
> for example, one process exists 28000 fds and 60000 threads, echo command
> will task 45 seconds.
> Now, we only consider the main process when exec "iterate_fd", and the
> time is about 52 milliseconds.
> 
> Signed-off-by: Liansen Zhai <zhailiansen@kuaishou.com>

Thanks for addressing my review of v1.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH net-next,v2] cgroup, netclassid: on modifying netclassid in cgroup, only consider the main process.
  2023-10-12  9:03 [PATCH net-next,v2] cgroup, netclassid: on modifying netclassid in cgroup, only consider the main process Liansen Zhai
  2023-10-16  9:28 ` Simon Horman
@ 2023-10-16 23:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-16 23:40 UTC (permalink / raw)
  To: Liansen Zhai
  Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel, yuwang,
	wushukun, zhailiansen

Hello:

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

On Thu, 12 Oct 2023 17:03:30 +0800 you wrote:
> When modifying netclassid, the command("echo 0x100001 > net_cls.classid")
> will take more time on many threads of one process, because the process
> create many fds.
> for example, one process exists 28000 fds and 60000 threads, echo command
> will task 45 seconds.
> Now, we only consider the main process when exec "iterate_fd", and the
> time is about 52 milliseconds.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] cgroup, netclassid: on modifying netclassid in cgroup, only consider the main process.
    https://git.kernel.org/netdev/net-next/c/c60991f8e187

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-10-16 23:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12  9:03 [PATCH net-next,v2] cgroup, netclassid: on modifying netclassid in cgroup, only consider the main process Liansen Zhai
2023-10-16  9:28 ` Simon Horman
2023-10-16 23:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.