Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to solve for this 'extract_processinfo_fdinfo.c linux/kcmp.h: No such file or directory’ #195

Closed
gukejun1 opened this issue Feb 28, 2023 · 3 comments

Comments

@gukejun1
Copy link

gukejun1 commented Feb 28, 2023

@Syllo

[root@p4gpu-129 build]# make 
[  5%] Building C object src/CMakeFiles/nvtop.dir/nvtop.c.o
[ 11%] Building C object src/CMakeFiles/nvtop.dir/interface.c.o
[ 17%] Building C object src/CMakeFiles/nvtop.dir/interface_layout_selection.c.o
[ 23%] Building C object src/CMakeFiles/nvtop.dir/interface_options.c.o
[ 29%] Building C object src/CMakeFiles/nvtop.dir/interface_setup_win.c.o
[ 35%] Building C object src/CMakeFiles/nvtop.dir/interface_ring_buffer.c.o
[ 41%] Building C object src/CMakeFiles/nvtop.dir/get_process_info_linux.c.o
[ 47%] Building C object src/CMakeFiles/nvtop.dir/extract_gpuinfo.c.o
[ 52%] Building C object src/CMakeFiles/nvtop.dir/extract_processinfo_fdinfo.c.o
/home/nvtop/src/extract_processinfo_fdinfo.c:28:10: fatal error: linux/kcmp.h: No such file or directory
   28 | #include <linux/kcmp.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/CMakeFiles/nvtop.dir/extract_processinfo_fdinfo.c.o] Error 1
make[1]: *** [src/CMakeFiles/nvtop.dir/all] Error 2
make: *** [all] Error 2

The same error is reported,in accordance with this practice #152 . How to solve this problem

@gukejun1 gukejun1 changed the title how to solve for this 'linux/kcmp.h: No such file or directory’ how to solve for this 'extract_processinfo_fdinfo.c linux/kcmp.h: No such file or directory’ Mar 1, 2023
@Syllo
Copy link
Owner

Syllo commented Apr 12, 2023

Depending on your distribution, you may need to install the kernel headers (e.g., linux-headers on debian/ubuntu).
That's the only explanation I can come up with for the missing header really.
What distribution are you using?

@Lacedaemon
Copy link

Installing kernel-devel on CentOS 7.9 (kernel 3.10.0-1160.90.1.el7.x86_64) didn't work, but this patch did:

diff -Naur a/src/extract_processinfo_fdinfo.c b/src/extract_processinfo_fdinfo.c
--- a/src/extract_processinfo_fdinfo.c  2022-11-06 07:33:24.000000000 -0800
+++ b/src/extract_processinfo_fdinfo.c  2023-06-13 17:38:40.550066552 -0700
@@ -25,7 +25,6 @@
 #include <ctype.h>
 #include <dirent.h>
 #include <fcntl.h>
-#include <linux/kcmp.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/syscall.h>
@@ -140,10 +139,14 @@

       fd_num = atoi(fdinfo_dent->d_name);

+      #ifndef KCMP_FILE
+      #define KCMP_FILE 0
+      #endif
+
       // check if this fd refers to the same open file as any seen ones.
       // we only care about unique opens
       for (unsigned i = 0; i < seen_fds_len; i++) {
-        if (syscall(SYS_kcmp, client_pid, client_pid, KCMP_FILE, fd_num, seen_fds[i]) <= 0)
+        if (syscall(SYS_kcmp, client_pid, client_pid, 0, fd_num, seen_fds[i]) <= 0)
           goto next_fd;
       }

Inspired by this.

@Syllo
Copy link
Owner

Syllo commented Jun 15, 2023

Thank you @Lacedaemon, I applied a similar patch in 9a8458b

@Syllo Syllo closed this as completed Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants