Robin Holt wrote: > This is going out without any testing. I got it to compile but never > even booted the kernel. > > I noticed that on ia64, the following simple program would take 24 > seconds to complete. Profiling revealed I was spending all that time > in unmap_vmas. Looking over the function, I noticed that I would only > attempt 8 pages at a time (CONFIG_PREMPT). I then thought through this > some more. My particular application had one large mapping which was > never touched after being mmaped. > > Without this patch, we would iterate numerous times (256) to get past > a region of memory that had an empty pmd, 524,288 times to get past an > empty pud, and 1,073,741,824 to get past an empty pgd. I had a 4-level > page table directory patch applied at the time. > Ouch. I wonder why nobody's noticed this before. It really is horribly inefficient on sparse mappings, as you've noticed :( I guess I prefer the following (compiled, untested) slight variant of your patch. Measuring work in terms of address range is fairly vague.... however, it may be the case that some architectures take a long time to flush a large range of TLBs? I don't see how the patch can be made too much cleaner... I guess the rescheduling could be pushed down, like the copy_ case, however that isn't particularly brilliant either. What's more, it would probably get uglier due to the mmu_gather tricks... Nick -- SUSE Labs, Novell Inc.