From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751228AbdAWMHz (ORCPT ); Mon, 23 Jan 2017 07:07:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56320 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbdAWMHo (ORCPT ); Mon, 23 Jan 2017 07:07:44 -0500 Date: Mon, 23 Jan 2017 13:07:35 +0100 From: Oleg Nesterov To: Pavel Tikhomirov Cc: Ingo Molnar , Peter Zijlstra , Andrew Morton , Cyrill Gorcunov , John Stultz , Thomas Gleixner , Nicolas Pitre , Michal Hocko , Stanislav Kinsburskiy , Mateusz Guzik , linux-kernel@vger.kernel.org, Pavel Emelyanov , Konstantin Khorenko Subject: Re: [PATCH] introduce the walk_process_tree() helper Message-ID: <20170123120735.GC11827@redhat.com> References: <20170119164346.4214-1-ptikhomirov@virtuozzo.com> <20170123115715.GB11827@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170123115715.GB11827@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 23 Jan 2017 12:07:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/23, Oleg Nesterov wrote: > > Add the new helper to walk the process tree, the next patch adds a user. > Note that it visits the group leaders only, proc_visitor can do > for_each_thread itself or we can trivially extend walk_process_tree() to > do this. Please consider this patch as a preparation for your change, or feel free to fold this code into your patch. Now you can simply do int xxx(struct task_struct *p, void *data) { if (p->signal->has_child_subreaper || is_child_reaper(task_pid(p)) return 0; p->signal->has_child_subreaper = 1; return 1; } walk_process_tree(xxx, NULL); walk_process_tree() handles the sub-threads correctly, but "p" is always the leader so is_child_reaper() is fine, but probably we need a new helper anyway. Oleg.