Welcome! Log In Create A New Profile

Advanced

Printing 'num_phypages' returns 0

Posted by rajeshr264 
Printing 'num_phypages' returns 0
July 17, 2013 10:01PM
Hi,

I downloaded and built the 3.9.6 kernel. I am learning about the memory management.

I created a module to print the value of 'num_phypages' in a new /proc file. However, the value of num_phypages is always 0.


int print_phy_pages_value(char *buf,char **start,off_t offset,
int count,int *eof,void *data ) {
int len=0;

len = sprintf(buf,"Number of pages = %ul\n", num_phypages);

return len;
}

int module_init() {
int result=0;

/* create a /proc file to store the size of 'num_phypages' */
if (create_proc_read_entry(DEVICE_NAME,0,NULL, print_phy_pages_value ,NULL) == NULL) {
printk("Failed to create new /proc/print_phy entry\n"winking smiley;
result = -1;
}

return result;
}

$ cat /proc/print_phy
Number of pages = 0l ---------> THE VALUE OF 'num_phypages' IS ALWAYS 0

Any suggestions?

Regards
Rajesh
Re: Printing 'num_phypages' returns 0
July 18, 2013 09:08AM
This may be a stupid question, but the name of the variable in the kernel is num_physpages.

You didn't declare a "num_phypages" variable in your module, and print out the value of that, did you?
Re: Printing 'num_phypages' returns 0
July 18, 2013 01:03PM
No I don't have any local variable. Its a typo. I typed the code for the question, so the error. Is there anything that I need to set in my 'make menuconfig' to make num_physpages to be set a valid value?

Regards
Rajesh

PS: I have tried replying many times but the forum mailer keeps saying that I am trying to post spam.
Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 11 plus 7?
Message: