Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752486AbbGONcy (ORCPT ); Wed, 15 Jul 2015 09:32:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56863 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751762AbbGONcw (ORCPT ); Wed, 15 Jul 2015 09:32:52 -0400 Date: Wed, 15 Jul 2015 15:31:07 +0200 From: Oleg Nesterov To: David Ahern Cc: Andrey Vagin , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Andrew Morton , Cyrill Gorcunov , Pavel Emelyanov , Roger Luethi , Arnd Bergmann , Arnaldo Carvalho de Melo , Andy Lutomirski , Pavel Odintsov Subject: Re: [PATCH 20/24] task_diag: Only add VMAs for thread_group leader Message-ID: <20150715133107.GA20539@redhat.com> References: <1436172445-6979-1-git-send-email-avagin@openvz.org> <1436172445-6979-21-git-send-email-avagin@openvz.org> <20150714174703.GA8088@redhat.com> <55A5BF0F.7090808@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55A5BF0F.7090808@gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1266 Lines: 43 On 07/14, David Ahern wrote: > > On 7/14/15 1:47 PM, Oleg Nesterov wrote: >>> >>> if (show_flags & TASK_DIAG_SHOW_VMA) { >>> + /* if the request is to dump all threads of all processes >>> + * only show VMAs for group leader. >>> + */ >>> + if (req->dump_strategy == TASK_DIAG_DUMP_ALL_THREAD && >>> + !thread_group_leader(tsk)) >>> + goto done; >>> + >> >> This doesn't look right, group leader can be a zombie with ->mm == NULL, > > Seriously? Yes, the main thread can do sys_exit() / pthread_exit(), although this is not that common. > I'll find some way to track whether VMAs have been dumped for > a pid. In case I confused you, the thread_group_leader() check and "goto done" above are fine, just you can't trust tsk->mm, so >>> if (i >= n) >>> err = fill_vma(tsk, skb, cb, &progress, show_flags); >> >> so this probably needs something like find_lock_task_mm(). > > ok. Yes, you just need to (try) find a subthread with ->mm != NULL if !tsk->mm, find_lock_task_mm() can help. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/