<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><span>Hi,</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>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.</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>But it somehow hangs my module.</span></div><div style="font-family:
'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>Linux version : 2.6 and system has 4 NUMA nodes (0-3) and has 16 cores in total.</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>I have done following: ( I already have a pointer to old page as pg ) [ this code is somewhat taken from usage of "</span>migrate_page" in mm/migrate.c file ]</div><div style="font-family: 'times
new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>--------------------------------------------------------</span></div><div style="background-color: transparent;">struct page *new_page = alloc_pages_exact_node(2,GFP_HIGHUSER_MOVABLE | GFP_THISNODE, 0);</div><div style="background-color: transparent;">if ( new_page != NULL )</div><div style="background-color: transparent;">{</div><div style="background-color: transparent;"> if ( trylock_page(new_page) )</div><div style="background-color: transparent;"> {</div><div style="background-color: transparent;"> new_page->index = pg->index;</div><div style="background-color: transparent;"> new_page->mapping = pg->mapping;</div><div style="background-color: transparent;"> struct
address_space *mapping = pg->mapping;</div><div style="background-color: transparent;"> migrate_page(mapping, new_page, pg);</div><div style="background-color: transparent;"> unlock_page(new_page);</div><div style="background-color: transparent;"> }</div><div style="background-color: transparent;"><span></span></div><div style="background-color: transparent;">}</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">--------------------------------------------------------</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><span style="font-size: 12pt;">- I have checked without locking also, but it does not work</span><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">- 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.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">Any ideas?</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">Ajay</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1"> <font
size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> "Valdis.Kletnieks@vt.edu" <Valdis.Kletnieks@vt.edu><br> <b><span style="font-weight: bold;">To:</span></b> ajay saini <ajay_saini1006@yahoo.co.in> <br><b><span style="font-weight: bold;">Cc:</span></b> "kernelnewbies@kernelnewbies.org" <kernelnewbies@kernelnewbies.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Sunday, 22 September 2013 9:53 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: working of migrate_page (exported) function in mm/migrate.c linux        Kernel<br> </font> </div> <div class="y_msg_container"><br>On Mon, 23 Sep 2013 09:00:21 +0800, ajay saini said:<br>> Is it used somewhere ?<br><br>[~] cd /usr/src/linux-next/<br>[/usr/src/linux-next] find [a-z]* -name '*.[ch]' | xargs grep migrate_page | grep -v migrate_pages<br><br>And start searching from there. You'll probably have to iterate several<br>times, because
there's at least onea few lines of the form:<br><br>mm/swap_state.c: .migratepage = migrate_page,<br>mm/shmem.c: .migratepage = migrate_page,<br><br>which means you need to figure out who calls that function pointer.<br><br>_______________________________________________<br>Kernelnewbies mailing list<br><a ymailto="mailto:Kernelnewbies@kernelnewbies.org" href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br><a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br><br><br></div> </div> </div> </div></body></html>