From 67af9aba6b144789734289443a5f90a3ca716dbe Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 23 Dec 2020 16:17:44 +0200 Subject: [PATCH] Decode and report native eventfd descriptors from libprocstat and procstat. Submitted by: greg@unrelenting.technology Reviewed by: markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26668 --- lib/libprocstat/libprocstat.c | 5 +++++ lib/libprocstat/libprocstat.h | 1 + usr.bin/procstat/procstat.1 | 2 ++ usr.bin/procstat/procstat_files.c | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 8d10c2900459..a2de61855815 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -628,6 +628,10 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap type = PS_FST_TYPE_DEV; data = file.f_data; break; + case DTYPE_EVENTFD: + type = PS_FST_TYPE_EVENTFD; + data = file.f_data; + break; default: continue; } @@ -719,6 +723,7 @@ kinfo_type2fst(int kftype) { KF_TYPE_SHM, PS_FST_TYPE_SHM }, { KF_TYPE_SOCKET, PS_FST_TYPE_SOCKET }, { KF_TYPE_VNODE, PS_FST_TYPE_VNODE }, + { KF_TYPE_EVENTFD, PS_FST_TYPE_EVENTFD }, { KF_TYPE_UNKNOWN, PS_FST_TYPE_UNKNOWN } }; #define NKFTYPES (sizeof(kftypes2fst) / sizeof(*kftypes2fst)) diff --git a/lib/libprocstat/libprocstat.h b/lib/libprocstat/libprocstat.h index 4ef34da75ec2..0624ec5289d4 100644 --- a/lib/libprocstat/libprocstat.h +++ b/lib/libprocstat/libprocstat.h @@ -72,6 +72,7 @@ #define PS_FST_TYPE_NONE 12 #define PS_FST_TYPE_PROCDESC 13 #define PS_FST_TYPE_DEV 14 +#define PS_FST_TYPE_EVENTFD 15 /* * Special descriptor numbers. diff --git a/usr.bin/procstat/procstat.1 b/usr.bin/procstat/procstat.1 index 174f932a9dde..1ce0b796beb4 100644 --- a/usr.bin/procstat/procstat.1 +++ b/usr.bin/procstat/procstat.1 @@ -313,6 +313,8 @@ The following file descriptor types may be displayed: .Bl -tag -width X -compact .It e POSIX semaphore +.It E +eventfd .It f fifo .It h diff --git a/usr.bin/procstat/procstat_files.c b/usr.bin/procstat/procstat_files.c index 74c6e48eab01..1d7b419b3f4a 100644 --- a/usr.bin/procstat/procstat_files.c +++ b/usr.bin/procstat/procstat_files.c @@ -414,6 +414,11 @@ procstat_files(struct procstat *procstat, struct kinfo_proc *kipp) xo_emit("{eq:fd_type/dev}"); break; + case PS_FST_TYPE_EVENTFD: + str = "E"; + xo_emit("{eq:fd_type/eventfd}"); + break; + case PS_FST_TYPE_NONE: str = "?"; xo_emit("{eq:fd_type/none}");