Serialize scrubbing pages
RFC PATCH 1/1 Serialize scrubbing pages
Hi,
I noticed that parallel scrubbing pages is not efficient due to spinlock contention. (also memory bandwidth?) Actually heap_lock becomes a bottleneck.
In my investigation, it often takes 1 millisec just to acquire the lock on ia64 with 8cpus. It's very wasteful.
For example, creating a domain is too slow while scrubbing pages.
# xm create vm memory=4000 # xm destroy vm; time xm create vm memory=4000 real 0m6.083s user 0m0.024s sys 0m0.008s
After the attached patch is applied,
# xm destroy vm; time xm create vm memory=4000 real 0m1.463s user 0m0.132s sys 0m0.028s
This workaround is an easy solution but ugly.
There must be another good way.
Thanks,
Kouya
xen/common/page_alloc.c +9 -0
@@ -70,6 +70,7 @@ integer_param("dma_bits", dma_bitsize);#define scrub_page (p) clear_page(p)#endif +static DEFINE_SPINLOCK (page_scrub_mutex);static DEFINE_SPINLOCK (page_scrub_lock);LIST_HEAD (page_scrub_list);static unsigned long scrub_pages;
@@ -951,6 +952,11 @@ static void page_scrub_softirq(void)int i;s_time_t start =NOW (); +if (!spin_trylock (&page_scrub_mutex)) { +set_timer (&this_cpu (page_scrub_timer),NOW () +MILLISECS (1 )); +return ; + } +/* Aim to do 1ms of work every 10ms. */ do { spin_lock(&page_scrub_lock);
@@ -958,6 +964,7 @@ static void page_scrub_softirq(void)if (unlikely ((ent = page_scrub_list.next) == &page_scrub_list) ) {spin_unlock (&page_scrub_lock); +spin_unlock (&page_scrub_mutex);return ; }
@@ -987,6 +994,8 @@ static void page_scrub_softirq(void)free_heap_pages (pfn_dom_zone_type (page_to_mfn (pg)), pg,0 ); } }while ( (NOW () - start) <MILLISECS (1 ) ); + +spin_unlock (&page_scrub_mutex);set_timer (&this_cpu (page_scrub_timer),NOW () +MILLISECS (10 )); }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 3 lines · Kouya Shimura
I noticed that parallel scrubbing pages is not efficient due to spinlock contention. (also memory bandwidth?) Actually
heap_lockbecomes a bottleneck.
I've considered the possibility of moving this kind of thing into a service domain. Then it would be visible to the scheduler and be less of a hack.
Anyhow, I hadn't considered the contention for the heap_lock. I think your patch is good and I will apply it for 3.3.
-- Keir
Quoted 5 lines · Keir Fraser
I've considered the possibility of moving this kind of thing into a service domain. Then it would be visible to the scheduler and be less of a hack.
Anyhow, I hadn't considered the contention for the
heap_lock. I think your patch is good and I will apply it for 3.3.
I've simplified the patch and then checked it in. There was no need for a new spinlock as it strictly dominated the old one.
-- Keir
Hi Keir,
I'm afraid that cset18305:f10d436d9a9e makes free_domheap_page freeze. Inner loop of page_scrub_softirq which keeps page_scrub_lock takes at least 1 millisec. Is it OK?
That's why I prepare a new spinlock.
Thanks,
Kouya
Quoted 10 lines · Keir Fraser
Quoted 5 lines · Keir Fraser
I've considered the possibility of moving this kind of thing into a service domain. Then it would be visible to the scheduler and be less of a hack.
Anyhow, I hadn't considered the contention for the
heap_lock. I think your patch is good and I will apply it for 3.3.I've simplified the patch and then checked it in. There was no need for a new spinlock as it strictly dominated the old one.
Quoted 4 lines · Kouya Shimura
I'm afraid that cset18305:f10d436d9a9e makes
free_domheap_pagefreeze. Inner loop ofpage_scrub_softirqwhich keepspage_scrub_locktakes at least 1 millisec. Is it OK?
That's why I prepare a new spinlock.
Oh, hmmm, that's a fair point. I'll put you extra lock back in, but private to the softirq scrub function.
Thanks,
Keir