From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97A32C04EBF for ; Mon, 23 Sep 2019 14:17:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 751AE207FD for ; Mon, 23 Sep 2019 14:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732642AbfIWORQ (ORCPT ); Mon, 23 Sep 2019 10:17:16 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:58672 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730669AbfIWORQ (ORCPT ); Mon, 23 Sep 2019 10:17:16 -0400 Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iCP9O-0006iw-Hk; Mon, 23 Sep 2019 16:17:14 +0200 Date: Mon, 23 Sep 2019 16:17:14 +0200 (CEST) From: Thomas Gleixner To: Frederic Weisbecker cc: LKML , Peter Zijlstra , Frederic Weisbecker , Oleg Nesterov , Ingo Molnar , Kees Cook Subject: Re: [patch 6/6] posix-cpu-timers: Make PID=0 and PID=self handling consistent In-Reply-To: <20190923141324.GB10778@lenoir> Message-ID: References: <20190905120339.561100423@linutronix.de> <20190905120540.162032542@linutronix.de> <20190923141324.GB10778@lenoir> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 23 Sep 2019, Frederic Weisbecker wrote: > On Thu, Sep 05, 2019 at 02:03:45PM +0200, Thomas Gleixner wrote: > > If the PID encoded into the clock id is 0 then the target is either the > > calling thread itself or the process to which it belongs. > > > > If the current thread encodes its own PID on a process wide clock then > > there is no reason not to treat it in the same way as the PID=0 case. > > > > Signed-off-by: Thomas Gleixner > > --- > > kernel/time/posix-cpu-timers.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > --- a/kernel/time/posix-cpu-timers.c > > +++ b/kernel/time/posix-cpu-timers.c > > @@ -90,7 +90,14 @@ static struct task_struct *lookup_task(c > > > > } else { > > /* > > - * For processes require that p is group leader. > > + * Timer is going to be attached to a process. If p is > > + * current then treat it like the PID=0 case above. > > + */ > > + if (p == current) > > + return current->group_leader; > > + > > + /* > > + * For foreign processes require that p is group leader. > > */ > > if (!has_group_leader_pid(p)) > > return NULL; > > So, right after you should have that: > > if (same_thread_group(p, current)) > return p; > > Which I suggested to convert as: > > if (p == current) > return p; Indeed :)