netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netclassid: on modifying netclassid, only consider the main process.
@ 2023-10-08  3:04 zhailiansen
  2023-10-09 15:14 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: zhailiansen @ 2023-10-08  3:04 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, zhailiansen, yuwang, wushukun, zhailiansen

When modifying netclassid, the command("echo 0x100001 > net_cls.classid") will
take more time on muti 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
52 milliseconds.

Signed-off-by: zhailiansen <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..78c903c 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 multi threads in this task,
+	 * so it can avoid the useless traversal.
+	 */
+	if (p && 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] 2+ messages in thread

end of thread, other threads:[~2023-10-09 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-08  3:04 [PATCH] netclassid: on modifying netclassid, only consider the main process zhailiansen
2023-10-09 15:14 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).