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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 49845C433E1 for ; Tue, 23 Mar 2021 19:25:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 085A8619CB for ; Tue, 23 Mar 2021 19:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232978AbhCWTZM (ORCPT ); Tue, 23 Mar 2021 15:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232912AbhCWTY6 (ORCPT ); Tue, 23 Mar 2021 15:24:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7C1C061574 for ; Tue, 23 Mar 2021 12:24:58 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1616527496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XymQE3BZ9skWIXCgwTWfmoNnNNp3VHzyUS4ZrjkJeUg=; b=O775ff2bjRjYnLHoLeFWDQd+4wYMCWfGMvIp10xPJCkF2qk8KocULa20ydWwHQEtk1+hzP MbONTRPZACM9a6wD/b14nwcTE1zIeE/acKg3F8RA4MrCZ6eaRAGKMVc4x9Qy00xo4BZf32 fhL6ajmNedDpkbPTyBxJmy8wMrBMbuZAV7ul1tswgmyItd7tcufzNe0UTEQSlEC8v0bLu+ vrNchJa0Vxqx1pngaddk2FY6fjjoMCaLWoP0pVhR5evT+iFcnl/a7GrfWiStnJ9JlCj4xw H2sLUh2hHmOfULUF167pMdVRAVHjCGF4TM15VK1iDfuzdXwnrOuPlWvyBtcuSw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1616527496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XymQE3BZ9skWIXCgwTWfmoNnNNp3VHzyUS4ZrjkJeUg=; b=zoMwwjdoSxKI8PnoYGj3/b3ZPRZkKAALrAtKfj8ePvwlI+cptT8ioENIHWm2IWWnj6+HzB z3/JfVjcUhGLEMCw== To: Oleg Nesterov Cc: LKML , Sebastian Andrzej Siewior , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Matt Fleming , "Eric W. Biederman" Subject: Re: [patch V4 2/2] signal: Allow tasks to cache one sigqueue struct In-Reply-To: <20210323180442.GC29219@redhat.com> References: <20210322091941.909544288@linutronix.de> <20210322092259.067712342@linutronix.de> <20210323180442.GC29219@redhat.com> Date: Tue, 23 Mar 2021 20:24:55 +0100 Message-ID: <87o8f9r7ug.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 23 2021 at 19:04, Oleg Nesterov wrote: > On 03/22, Thomas Gleixner wrote: >> +static void sigqueue_cache_or_free(struct sigqueue *q, bool cache) >> + if (q) { >> + tsk->sigqueue_cache = NULL; >> + /* If task is self reaping, don't cache it back */ >> + sigqueue_cache_or_free(q, tsk != current); > ^^^^^^^^^^^^^^ > Still not right or I am totally confused. > > tsk != current can be true if an exiting (and autoreaping) sub-thread > releases its group leader. > > IOW. Suppose a process has 2 threads, its parent ignores SIGCHLD. > > The group leader L exits. Then its sub-thread T exits too and calls > release_task(T). In this case the tsk != current is false. > > But after that T calls release_task(L) and L != T is true. Bah. yes. > I'd suggest to free tsk->sigqueue_cache in __exit_signal() unconditionally and > remove the "bool cache" argument from sigqueue_cache_or_free(). That's what you get from trying to be clever, dammit. Thanks for walking me through the oddities of exit ! tglx