Re: [PATCH v5 3/6] mm, proc: reduce cost of /proc/pid/smaps for shmem mappings

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

 



On Wed 18-11-15 10:29:33, Vlastimil Babka wrote:
> The previous patch has improved swap accounting for shmem mapping, which
> however made /proc/pid/smaps more expensive for shmem mappings, as we consult
> the radix tree for each pte_none entry, so the overal complexity is
> O(n*log(n)).
> 
> We can reduce this significantly for mappings that cannot contain COWed pages,
> because then we can either use the statistics tha shmem object itself tracks
> (if the mapping contains the whole object, or the swap usage of the whole
> object is zero), or use the radix tree iterator, which is much more effective
> than repeated find_get_entry() calls.
> 
> This patch therefore introduces a function shmem_swap_usage(vma) and makes
> /proc/pid/smaps use it when possible. Only for writable private mappings of
> shmem objects (i.e. tmpfs files) with the shmem object itself (partially)
> swapped outwe have to resort to the find_get_entry() approach. Hopefully
> such mappings are relatively uncommon.
> 
> To demonstrate the diference, I have measured this on a process that creates
> a 2GB mapping and dirties single pages with a stride of 2MB, and time how long
> does it take to cat /proc/pid/smaps of this process 100 times.
> 
> Private writable mapping of a /dev/shm/file (the most complex case):
> 
> real    0m3.831s
> user    0m0.180s
> sys     0m3.212s
> 
> Shared mapping of an almost full mapping of a partially swapped /dev/shm/file
> (which needs to employ the radix tree iterator).
> 
> real    0m1.351s
> user    0m0.096s
> sys     0m0.768s
> 
> Same, but with /dev/shm/file not swapped (so no radix tree walk needed)
> 
> real    0m0.935s
> user    0m0.128s
> sys     0m0.344s
> 
> Private anonymous mapping:
> 
> real    0m0.949s
> user    0m0.116s
> sys     0m0.348s
> 
> The cost is now much closer to the private anonymous mapping case, unless the
> shmem mapping is private and writable.
> 
> Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>

Looks good to me
Acked-by: Michal Hocko <mhocko@xxxxxxxx>
[...]
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]