From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCD6A2FD1D3 for ; Mon, 10 Nov 2025 21:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762811382; cv=none; b=Ha0SBYABHbyBcF5OgeMrmwwfvIr37/kkPo47h6VO3jvpWe4jxhvaJYzXqmwBBn6JI2m9UI+0kRXKSgZPubOVRToOlGViQ9oDZSCqW+8RaDyQ+LZozNHYVLZXRSF45k7Rt5KDVVWz9gxKTUb4NTtRmAqXKeWSivulktcI1EcDyyI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762811382; c=relaxed/simple; bh=yVjviV3zopbG1PAfCWMvFshBkzHtOiy9INXF/AyrOjo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EuOC9sdbddQ4ElksEfm+84uUXBz5Z1UNc81us7Mgv6ak29VvCMB/01Iui0Hq5roJzf+1URvNeHdRJ656Gov6TOyLhP8pk1Xl9dVZw+4p3o5wLWObHCEKChiIZ07SfR80KC3fJ4f1rnSi2wczV8+9m9EutwPt8KZns5irzcTeEnk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ELZ14Cfj; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ELZ14Cfj" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-59445ee9738so2765305e87.3 for ; Mon, 10 Nov 2025 13:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762811379; x=1763416179; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=RFirqqcYt6xjzQLvnHeiyd54+NIBXchkEuHWoh2vuEE=; b=ELZ14Cfj9MG5Ek0/l9eeH/fIFQMGqh8G3P0o3tQcIOR2AY++gN9NOsFux0xdVdkO0v MU2OKQdYIen9yRt5rLjN6bvyQOaJQ8UYJaZWXxsmd6LkU3JEWUAbF9ulY+Zwn++dGE9t ThLPbe0s+JrPqiiKcJrsag1c3Uw0jRG8pHydamyIP3g58KmXkCqczTED6EJUFDfOE78H +RaawlpsDr25t6K4jglBizAPhm0jL9Z8kxp+O9aP6T+vVY4U6J5InZS8V4pqXniQPZBQ 2xEcJg8SRJPckCf4vj3My5MAmjC2Gk8IYc4bFJiYyWie7GmF22LJuqJAaezdigqj25vH uW5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762811379; x=1763416179; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RFirqqcYt6xjzQLvnHeiyd54+NIBXchkEuHWoh2vuEE=; b=o52rkYmOwsk9ZPgEOq4RNZQ7Q62YCppOw9/gPcvZXoW7xcVeCY4jZ5FYgAoAl/tCXx JM1m2cwCyfVwqKm2T2nOeEnm9iq3z4I5EDDCSLCF1Y1L1malTwq2bTPuxqDVQdmHYUb6 fhE562JskAelmQyja39fVK6Fulm4AMR83Zx85qPx/FLhpWBfmApDvF+K/0a2TxV4mqW+ dJfAyCd3pXPelSo8QKqLWsKPHfchPjxaWHmjYI8P5wTQkb7bfD7eoQ18QCVlsLn+UOXh hHuV9yENCnMNEwK8nMoFx3DPDMapOOIowj+n+3e5BVFTWGMOx1E509gB6IC9TTsryyvs F3cQ== X-Forwarded-Encrypted: i=1; AJvYcCVfHI2S7KHtdIndEX3kYBQJ00esgPtaTL4KpqHV9WCsFnZSCEXvcZeUr9Lv6ZzbEiF7/Myx/pMPhM/7SYbR6sI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3IhvLO6p2ZIobiUv44rshgExwsMiN6669PjeUP5j4HqCQhXDU M7zZLye9zj9NFiAhZdMoouIVQm93XSGtqQOIpnIFbKOIUEkYLPndQDAU X-Gm-Gg: ASbGncsTJGLyCCoL3S6VF7LmJIadNYALO/creZkEerQFNEnnF2nR/7DWmipnVwsnoS6 z9m+MqlaSYW56R1d2j8CJbbr+luJElhVb5zPNzHisZ1GK3n0E2WDakxqNvze4XzfkGZ0A+gkpDW 2Soaz9FLdQAeCjcjyjvCmreG+tMn94yb6aR2fvVJgjTQKqWDr9Lau0CEqZ4QfKrikGz4gxDjT83 KGTKe8AyGCzlSfD2BWqI/oc8TmRbaUGGxEOdpMHa6fQ8FumKrDqdrtYetHmYDxDyPmr15/5oKKZ KjvmDCA7+Le6dW/BdjTOdz/9C03/W8QvIszGgiVMl1r2KsYQTp2Xk+DMgytmoU03BFp986CHnib CWP1CfKdyzIDAQ0C14lESvkK4vdqwKmqFkdnuGcML8vr3d1CVzzcs3Gnll4pf/7vxjAgaYWILLH 8Zog== X-Google-Smtp-Source: AGHT+IGjkYEZuiIm45qpRwthPMBOYrneNAO2t8mNMUlpQZhecV1r6b86jhyyoGDLr3xqW66ODHKdcw== X-Received: by 2002:a05:6512:3a86:b0:57c:2474:371f with SMTP id 2adb3069b0e04-5945f1e5562mr3111337e87.45.1762811378727; Mon, 10 Nov 2025 13:49:38 -0800 (PST) Received: from grain.localdomain ([5.18.255.97]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5944ff427d0sm4115144e87.68.2025.11.10.13.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 13:49:38 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 93D625A0033; Tue, 11 Nov 2025 00:49:37 +0300 (MSK) Date: Tue, 11 Nov 2025 00:49:37 +0300 From: Cyrill Gorcunov To: Oleg Nesterov Cc: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org Subject: Re: [RFC PATCH 2/3] exec: don't wait for zombie threads with cred_guard_mutex held Message-ID: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.14 (2025-02-20) On Mon, Nov 10, 2025 at 04:09:05PM +0100, Oleg Nesterov wrote: ... > > > if (!((sig->flags & SIGNAL_GROUP_EXIT) || sig->group_exec_task)) { > > > sig->group_exec_task = tsk; > > > sig->notify_count = -zap_other_threads(tsk); > > > > Hi Oleg! I somehow manage to miss a moment -- why negative result here? > > You know, initially I wrote > > sig->notify_count = 0 - zap_other_threads(tsk); > > to make it clear that this is not a typo ;) Aha! Thanks a huge for explanation :) > > This is for exit_notify() which does > > /* mt-exec, de_thread() -> wait_for_notify_count() */ > if (tsk->signal->notify_count < 0 && !++tsk->signal->notify_count) > wake_up_process(tsk->signal->group_exec_task); > > Then setup_new_exec() sets notify_count > 0 for __exit_signal() which does > > /* mt-exec, setup_new_exec() -> wait_for_notify_count() */ > if (sig->notify_count > 0 && !--sig->notify_count) > wake_up_process(sig->group_exec_task); > > Yes this needs more comments and (with or without this patch) cleanups. > Note that exit_notify() and __exit_signal() already (before this patch) > use ->notify_count almost the same way, just exit_notify() assumes that > notify_count < 0 means the !thread_group_leader() case in de_thread(). Yeah, just realized. It's been a long time since I looked into this signals and tasks related code so to be honest don't think I would be helpful here) Anyway while looking into patch I got wonder why +static int wait_for_notify_count(struct task_struct *tsk) +{ + for (;;) { + return -EINTR; + set_current_state(TASK_KILLABLE); + if (!tsk->signal->notify_count) + break; We have no any barrier here in fetching @notify_count? I mean updating this value is done under locks (spin or read/write) in turn condition test is a raw one. Not a big deal since set_current_state() and schedule() are buffer flushers by themselves and after all not immediate update of notify_count simply force us to yield one more schedule() call but I've been a bit confused that we don't use some read_once here or something. Another (more likely) that I've just said something stupid) + schedule(); } + __set_current_state(TASK_RUNNING); + return 0; +} Cyrill