tkernel: netatop: add netatop module in kernel/tkernel/

Upstream: no

when netatop module insmod, user tools atop could display
network bandwidth per process

Signed-off-by: Zhiping Du <zhipingdu@tencent.com>
Signed-off-by: Wang Fuhai <fuhaiwang@tencent.com>
Signed-off-by: katrinzhou <katrinzhou@tencent.com>
Signed-off-by: Kairui Song <kasong@tencent.com>
This commit is contained in:
katrinzhou 2023-12-06 11:21:51 +08:00 committed by Kairui Song
parent c9c30816bb
commit 1c4e7e7a52
7 changed files with 1861 additions and 0 deletions

View File

@ -30,3 +30,6 @@ source "lib/Kconfig"
source "lib/Kconfig.debug"
source "Documentation/Kconfig"
# For TKernel features
source "kernel/tkernel/Kconfig"

View File

@ -1,4 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# TKernel configuration
#
menuconfig TKERNEL
bool "Tencent Kernel Features"
default n
@ -13,4 +16,11 @@ config TKERNEL_TTOOLS
tristate "Tencent Kernel TTools"
default n
config TKERNEL_NETATOP
tristate 'Netatop support'
default n
depends on NETFILTER
help
Netatop module from TKernel
endif

View File

@ -1,3 +1,4 @@
obj-$(CONFIG_TKERNEL) += base.o
obj-$(CONFIG_TKERNEL_NONPRIV_NETBIND) += netbind.o
obj-$(CONFIG_TKERNEL_TTOOLS) += ttools/
obj-$(CONFIG_TKERNEL_NETATOP) += netatop/

View File

@ -0,0 +1 @@
obj-m := netatop.o

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
#define COMLEN 16
struct taskcount {
unsigned long long tcpsndpacks;
unsigned long long tcpsndbytes;
unsigned long long tcprcvpacks;
unsigned long long tcprcvbytes;
unsigned long long udpsndpacks;
unsigned long long udpsndbytes;
unsigned long long udprcvpacks;
unsigned long long udprcvbytes;
/* space for future extensions */
};
struct netpertask {
pid_t id; // tgid or tid (depending on command)
unsigned long btime;
char command[COMLEN];
struct taskcount tc;
};
/*
** getsocktop commands
*/
#define NETATOP_BASE_CTL 15661
// just probe if the netatop module is active
#define NETATOP_PROBE (NETATOP_BASE_CTL)
// force garbage collection to make finished processes available
#define NETATOP_FORCE_GC (NETATOP_BASE_CTL+1)
// wait until all finished processes are read (blocks until done)
#define NETATOP_EMPTY_EXIT (NETATOP_BASE_CTL+2)
// get info for finished process (blocks until available)
#define NETATOP_GETCNT_EXIT (NETATOP_BASE_CTL+3)
// get counters for thread group (i.e. process): input is 'id' (pid)
#define NETATOP_GETCNT_TGID (NETATOP_BASE_CTL+4)
// get counters for thread: input is 'id' (tid)
#define NETATOP_GETCNT_PID (NETATOP_BASE_CTL+5)

View File

@ -0,0 +1,2 @@
#define NETATOPVERSION "0.7"
#define NETATOPDATE "2015/10/09 14:26:52"