1

I am new to linux, C and stack overflow. I was trying to view page tables of all processes running. For this I am using dump_pagetable.c.

I tried to run first by normal compiling gcc dump_pagetables.c -o dump_pagetables.out. But it gave me error:

dump_pagetable.c:15:27: fatal error: linux/debugfs.h: No such file or directory #include linux/debugfs.h></code><br/><br/>Then I tried to use a make command <code>make -C /lib/modules/$(uname -r)/build M=$PWD modules</code>. So it gave me this error<code>CC [M]  /home/varma/Desktop/TLB/dump_pagetable.o
/home/varma/Desktop/TLB/dump_pagetable.c:420:1: warning: data definition has no type or storage class
 __initcall(pt_dump_init);
 ^
/home/varma/Desktop/TLB/dump_pagetable.c:420:1: error: type defaults to ‘int’ in declaration of ‘__initcall’ [-Werror=implicit-int]
/home/varma/Desktop/TLB/dump_pagetable.c:420:1: warning: parameter names (without types) in function declaration
/home/varma/Desktop/TLB/dump_pagetable.c:398:12: warning: ‘pt_dump_init’ defined but not used [-Wunused-function]
 static int pt_dump_init(void)
            ^
cc1: some warnings being treated as errors
scripts/Makefile.build:263: recipe for target '/home/varma/Desktop/TLB/dump_pagetable.o' failed
make[1]: *** [/home/varma/Desktop/TLB/dump_pagetable.o] Error 1
Makefile:1394: recipe for target '_module_/home/varma/Desktop/TLB' failed
make: *** [_module_/home/varma/Desktop/TLB] Error 2
make: Leaving directory '/usr/src/linux-headers-3.19.0-23-generic'</code>
  1. How do I get this code running?
  2. How do modify the dump_pagetables.c So that I can see huge pages also.
Piotr Olaszewski
  • 6,017
  • 5
  • 38
  • 65
Varmakochin
  • 31
  • 1
  • 9
  • You can't dive into the middle of a gigantic kernel source tree and expect to selectively compile a single file. There's huge amounts of configuration that happen at every level in the build tree. You need to build the kernel as a whole. Start at the root of the source tree and set up a build environment. Read: https://github.com/mmind/rkchrome-kernel/blob/master/README This will be the beginning of a very long journey. – BaseZen Aug 01 '15 at 03:33
  • Possible duplicate of [Print kernel's page table entries](https://stackoverflow.com/questions/20069620/print-kernels-page-table-entries) – Ciro Santilli OurBigBook.com Jul 12 '17 at 08:43

1 Answers1

1

The file you are trying to compile is a utility function for use within the Linux kernel for a somewhat obscure CPU used in IBM mainframes (the IBM System/390). It cannot be used outside of the kernel, and even there, it's only applicable to systems of that particular architecture, not to any desktop computers.

Needless to say, this won't work.

There is an equivalent feature (CONF_X86_PTDUMP) available in the kernel for x86 systems, but it is not enabled. If you want to use it, you will probably need to recompile your kernel. For more details, see the answer to the question "Print kernel's page tables".

Community
  • 1
  • 1
  • **1/2**So I understand I need to configure my kernel. My kernel is 3.19.0 -25 generic, 64bit and I am running it virtually. Now, I did not understand "[Print kernel's page tables](http://stackoverflow.com/questions/20069620/print-kernels-page-table-entries)". But I saw link to ubuntu page for "[Build Your Own Kernel](https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel)" Which I found generic. Also from above comment is got a link to github for kernel 3.x"[rkchrome-kernel/README](https://github.com/mmind/rkchrome-kernel/blob/master/README)" – Varmakochin Aug 02 '15 at 23:40
  • **2/2** **A**. How do I configure the kernel with CONF_X86_PTDUMP flag set. **B** .Do I have to edit a particular file? if so where can I find it? **C**. What should I add to the .config file? **D**. Should I clone entire repository? – Varmakochin Aug 02 '15 at 23:48
  • The rkchrome-kernel repository that you're looking at is intended for use with certain ChromeOS devices using Rockchip SoCs. It is not appropriate for your computer; the only reason it was linked in comments is because the file you linked in your question came from that repository. –  Aug 02 '15 at 23:51
  • 1
    **1/2**I turned on the `CONFIG_X86_PTDUMP` by configuring the kernel with make command. Then checked the kernel version by `(uname -r)` it returned `4.1.4`. Later verified the config file under /boot/config-4.1.4 the file contained `CONFIG_X86_PTDUMP =y`. But, when I echo ` > /proc/sys/debug/pgt_dump_process_id` returned `No such file or Directory exists`. Also `/proc/kernel_page_tables` the file called kernel_page_tables does not exist. – Varmakochin Aug 05 '15 at 22:28
  • **2/2**Now I understand I have to apply the patch [dump_pagetable.c](https://github.com/rjmccabe3701/LinuxViewPageTables/commit/e2cb0f6810b11a25ff2d5f8aa50ff32dcbb8805e). I used command `wget https://github.com/rjmccabe3701/LinuxViewPageTables/commit/e2cb0f6810b11a25ff2d5f8aa50ff32dcbb8805e.patch` then tried to execute the file and it gave me error.

    **1**. How to patch it.?
    **2**. How to solve possible dependency for `dump_pagetable.c`so that patch will be properly functional.
    – Varmakochin Aug 05 '15 at 22:36