some basic doubts / confusion regarding linux kernel / OS
Hi, I had some confusion/doubts regarding Linux kernel / OS and I want to be completely sure that my understanding is right for below, and need your inputs (would be really glad for your help): - There are functions defined in linux kernel. Some of these functions have a line EXPORT_SYMBOL(function_name); after them. These are the functions which are exported, so they can be directly called from a linux kernel module - right ? (we just need to include header files which define them in our kernel module) - There are some functions defined in linux kernel, which are not static and are not exported, like migrate_pages in migrate.c and it is mentioned in include/linux/migrate.h file. Is there a way to call these functions, directly from kernel module ?? (even if I include the header file) ?? If no, What is the technique used there, which prevents the module from calling this function (even though I have included the header file)?? - We have kernel header files defined in include/linux/ and there are user space header files (the C libraries). Can a user space program include kernel header file and call a kernel function directly?? No , right ?? Again, what is there which prevents a user space program from doing so?? How this technique is implemented ?? - I understand that, a struct page exists for each physical page in RAM. And this linked list of struct pages are stored together at the beginning of a zone. After this storage, does the real data (content) of pages is stored. Now each of these pages must be pointing to the data area/page which they define ? Which is this field in the struct page, which points to this data area, a physical address + length of the page ? Thanks, Ajay___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
working of migrate_page (exported) function in mm/migrate.c linux Kernel
Hi, Anybody knows the working of this function migrate_page (not migrate_pages) defined in mm/migrate.c file (linux 2.6) This function is exported so can be used in a Kernel module. Is it used somewhere ? Can it be used to migrate a page to a different NUMA node from kernel module and How to use it? Is there a function/way in kernel which can be used to migrate page to different NUMA node from Kernel module (not userspace)? Ajay___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: working of migrate_page (exported) function in mm/migrate.c linux Kernel
Hi, I have read some of these uses (of migrate_page) from linux kernel source code and tried to use this function in my kernel module. But it somehow hangs my module. Linux version : 2.6 and system has 4 NUMA nodes (0-3) and has 16 cores in total. I have done following: ( I already have a pointer to old page as pg ) [ this code is somewhat taken from usage of migrate_page in mm/migrate.c file ] struct page *new_page = alloc_pages_exact_node(2,GFP_HIGHUSER_MOVABLE | GFP_THISNODE, 0); if ( new_page != NULL ) { if ( trylock_page(new_page) ) { new_page-index = pg-index; new_page-mapping = pg-mapping; struct address_space *mapping = pg-mapping; migrate_page(mapping, new_page, pg); unlock_page(new_page); } } - I have checked without locking also, but it does not work - I check the existence of both pages and on what NUMA node they are assigned and it gives me correct information. It is only when I make a call to migrate_page does the code hangs. Any ideas? Ajay From: valdis.kletni...@vt.edu valdis.kletni...@vt.edu To: ajay saini ajay_saini1...@yahoo.co.in Cc: kernelnewbies@kernelnewbies.org kernelnewbies@kernelnewbies.org Sent: Sunday, 22 September 2013 9:53 PM Subject: Re: working of migrate_page (exported) function in mm/migrate.c linux Kernel On Mon, 23 Sep 2013 09:00:21 +0800, ajay saini said: Is it used somewhere ? [~] cd /usr/src/linux-next/ [/usr/src/linux-next] find [a-z]* -name '*.[ch]' | xargs grep migrate_page | grep -v migrate_pages And start searching from there. You'll probably have to iterate several times, because there's at least onea few lines of the form: mm/swap_state.c: .migratepage = migrate_page, mm/shmem.c: .migratepage = migrate_page, which means you need to figure out who calls that function pointer. ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Getting struct page pointer from virtual address
More information : - Linux kernel version : 2.6.32 (But I would like a method which is portable to other higher versions as well) - I tried using follow_page, but this function is not exported from the kernel so, can't use it. (Any reason why this function is not exported??) Thanks Ajay From: ajay saini ajay_saini1...@yahoo.co.in To: kernelnewbies@kernelnewbies.org kernelnewbies@kernelnewbies.org Sent: Tuesday, 3 September 2013 1:21 PM Subject: Getting struct page pointer from virtual address Hey, I am working on a linux kernel module and I have a virtual address and mm (struct mm_struct) for a process in this module. I can find the virtaul memory area to which this address belongs to by using find_vma. Is there a function in the linux kernel which I can use in this module (i.e. exported from the kernel) to get struct page pointer for this virtual address. Thanks Ajay___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Given a page, How to get the NUMA node id of this page
Hi all, I am working on a checkpoint/Restart Linux kernel module. Wherein, a process sends a request to this module to checkpoint itself. In this process information about the process is stored in a file, which is used later on to restart the process. Now when this module is storing the information related to pages (of the process) in a file, we also want to know on which NUMA node this page was assigned Can you suggest what will be the best way to get this data (page to NUMA node mapping) I tried using page_to_nid(page), but I am not really sure it gives me correct value. (Like, I am working on linux 2.6.32, 64 bit machine with 16 cores and there are 4 NUMA nodes (4 cores on each) on it, but this function returns 32 when called) Thanks, Ajay ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies