tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: would a mutex_wait be useful?



christos%astron.com@localhost (Christos Zoulas) wrote:
> >You probably was intended to set the D_MPSAFE flag for mem_cdevsw. Note
> >that this wont be atomic then:
> >
> >if (zeropage == NULL) {
> >     zeropage = (void *)
> >         malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
> >     memset(zeropage, 0, PAGE_SIZE);
> >}
> >
> 
> if (zeropage == NULL)
>       zeropage = malloc(PAGE_SIZE, M_TEMP, M_WAITOK|M_ZERO);
> 
> Not a good reason :-)
> 

Concern is a window between test and set. How about:

zeropage = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);

Somewhere in initialisation path, could be in the end of pmap_init(), or even
UVM as a "generic" zero-page.

-- 
Best regards,
Mindaugas


Home | Main Index | Thread Index | Old Index