From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751178AbdAWMw1 (ORCPT ); Mon, 23 Jan 2017 07:52:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35524 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdAWMw0 (ORCPT ); Mon, 23 Jan 2017 07:52:26 -0500 Date: Mon, 23 Jan 2017 13:52:23 +0100 From: Oleg Nesterov To: Pavel Tikhomirov , Kees Cook 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: task_is_descendant() cleanup Message-ID: <20170123125222.GA28626@redhat.com> References: <20170119164346.4214-1-ptikhomirov@virtuozzo.com> <20170120181359.GA17205@redhat.com> <4908be49-d3c3-366d-0fd1-05249ef4ecef@virtuozzo.com> <20170123115534.GA11827@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170123115534.GA11827@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.30]); Mon, 23 Jan 2017 12:52:27 +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: > > Btw task_is_descendant() looks wrong at first glance. No, I missed the 2nd ->group_leader dereference. Still this function looks overcomplicated and the usage of thread_group_leader/group_leader just add the unnecessary confusion. It can be simplified a little bit: static int task_is_descendant(struct task_struct *parent, struct task_struct *child) { int rc = 0; struct task_struct *walker; if (!parent || !child) return 0; rcu_read_lock(); for (walker = child; walker->pid; walker = rcu_dereference(walker->real_parent)) if (same_thread_group(parent, walker)) { rc = 1; break; } rcu_read_unlock(); return rc; } Kees, I can send a patch if you think this very minor cleanup makes any sense. Oleg.