Question about synchronization in socow_setup()

Andrey Simonenko simon at comsys.ntu-kpi.kiev.ua
Thu Jun 23 09:41:50 GMT 2005


Hello,

Can somebody explain how socow_setup() synchronizes access to the page
it wants to COW:

    99		s = splvm();
      	
   100	       /* 
   101		* verify page is mapped & not already wired for i/o
   102		*/
   103		socow_stats.attempted++;
   104		pa=pmap_extract(map->pmap, uva);
   105		if(!pa) {
   106			socow_stats.fail_not_mapped++;
   107			splx(s);
   108			return(0);
   109		}
   110		pp = PHYS_TO_VM_PAGE(pa);
      	
   111		/* 
   112		 * set up COW
   113		 */
   114		vm_page_lock_queues();
   115		vm_page_cowsetup(pp);

How socow_setup() is sure, that pp is valid after pmap_extract()
(line 104) and before vm_page_lock_queues() (line 114) ?

Another question, why socow_setup() uses vm_page_wire() instead
of pmap_extract_and_hold() ?  When a page should be held and when
it should be wired?  According the comment for vm_page_hold(), a
page should be held only for "*very* temporary holding", so when
one decides what to use (vm_page_hold() or vm_page_wire()), he should
decide what will be more effective: simply increment m->hold_count or
increment m->wire_count and remove m from the page queue (so this
page will be invisible for vm_pageout_scan()).  Am I right?


More information about the freebsd-hackers mailing list