From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH 12/24] task_diag: add a new group to get tasks memory mappings (v2) Date: Tue, 14 Jul 2015 22:02:19 -0400 Message-ID: <55A5BF2B.1040504@gmail.com> References: <1436172445-6979-1-git-send-email-avagin@openvz.org> <1436172445-6979-13-git-send-email-avagin@openvz.org> <20150714180857.GC8088@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150714180857.GC8088-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Oleg Nesterov , Andrey Vagin Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Morton , Cyrill Gorcunov , Pavel Emelyanov , Roger Luethi , Arnd Bergmann , Arnaldo Carvalho de Melo , Andy Lutomirski , Pavel Odintsov List-Id: linux-api@vger.kernel.org On 7/14/15 2:08 PM, Oleg Nesterov wrote: > On 07/06, Andrey Vagin wrote: >> >> +static int task_vma_num(struct mm_struct *mm) >> +{ >> + struct vm_area_struct *vma; >> + int n_vma = 0; >> + >> + if (!mm || !atomic_inc_not_zero(&mm->mm_users)) >> + return 0; >> + >> + down_read(&mm->mmap_sem); >> + for (vma = mm->mmap; vma; vma = vma->vm_next, n_vma++) >> + ; >> + >> + up_read(&mm->mmap_sem); >> + mmput(mm); >> + >> + return n_vma; >> +} > > Hmm. How about > > int task_vma_num(struct mm_struct *mm) > { > return mm->map_count; > } > > ? makes sense. Thanks for the pointer.