The existing algorithm in procfs_map() to calculate count of resident pages in an entry is too primitive, resulting in too long run time for large sparse mapping entries. Re-use the kern_proc_vmmap_resident() from kern_proc.c which only looks at the existing pages in the iterations.
Also, this makes procfs to honor kern.proc_vmmap_skip_resident_count, if user does not need this information.