Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp160794ybg; Mon, 8 Jun 2020 19:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXmqR620dtIBgwvdIKtW9Izp6dWOY483CM39n1raW3I0kOQxu6Auptu3G4JUEeCuzuhjMo X-Received: by 2002:aa7:cb53:: with SMTP id w19mr23745657edt.328.1591670053496; Mon, 08 Jun 2020 19:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591670053; cv=none; d=google.com; s=arc-20160816; b=Uh7nfb1bK6p+V0+RzyYqYPEnQ8zUQoIFqwuL5vKx8j//ulCEHIVBqAQmS2JbSJXihe LS4MqzGEDnE+9m/Uk/SzDVNXbReVCZ4LWL0Ly56VfBwhcxCwECJzC8T0anaOHzgh1VIP qUtHUGzWLnPF60xC6wOOgksPOFwU89ISY0g03HOVt/QVXLaMV8guqTPT96XPifxMhs/e EsS8T7q31zIbcSqMPawytprWnW7Zl9SOkCCtPldH8kaLDvEe2ZPhvU7PiK2YgVFUrr2m A3TEXqDS+ZbZq1k7K3PR+OpLJLzSzAG8epqwVY/CJEoOJLo3jaWdffXcNhVEUFhCUXTK YU4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=VqSemQAEmTNIhewbIRWhFRKEajSoN3MPN2sI0jg+LZI=; b=nNepQrC6m4dBPzbT0Ahw1zMuSZZiIK6+CoNEPewRk4OQD5+DKaAuI+4HgjMqZHk717 nyv/K9XPhdajtTddh7iqVP+A1wI0U6MRj8hi+xbj3jctWn+wzT7DwgB+IM2lMTyzGvb+ PBKTDAOZbeeijWKrd1cPbnc7aVOv4FFHU2EzbiAODQP/2Yov2o71QRMIcH4XgMRO9dNX A8aNAIUzyMMO+zBxS8uhNvLFhRpgz9g/Qfvlr2gDc/m05TiS7RsMibIkeNB1xdJFwnDk B7CK5RbaSLWB5P1lT/qQIqbqPGDqCsIWwer2YU9sxKNvMx+obTPvbJ2auBSC4XRu5wA/ tizQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn14si12388198ejc.414.2020.06.08.19.33.50; Mon, 08 Jun 2020 19:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726937AbgFICaG convert rfc822-to-8bit (ORCPT + 99 others); Mon, 8 Jun 2020 22:30:06 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:54882 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726749AbgFICaF (ORCPT ); Mon, 8 Jun 2020 22:30:05 -0400 Received: from DGGEMM404-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 391D862EB35D663B2CE9; Tue, 9 Jun 2020 10:30:04 +0800 (CST) Received: from dggeme707-chm.china.huawei.com (10.1.199.103) by DGGEMM404-HUB.china.huawei.com (10.3.20.212) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 9 Jun 2020 10:30:03 +0800 Received: from dggema755-chm.china.huawei.com (10.1.198.197) by dggeme707-chm.china.huawei.com (10.1.199.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Tue, 9 Jun 2020 10:30:03 +0800 Received: from dggema755-chm.china.huawei.com ([10.1.198.197]) by dggema755-chm.china.huawei.com ([10.1.198.197]) with mapi id 15.01.1913.007; Tue, 9 Jun 2020 10:30:02 +0800 From: "liuchao (CR)" To: "Eric W. Biederman" CC: "mingo@kernel.org" , "tglx@linutronix.de" , "linux-kernel@vger.kernel.org" , Hushiyuan , "hewenliang (C)" Subject: Re: [RFC] decrease tsk->signal->live before profile_task_exit Thread-Topic: [RFC] decrease tsk->signal->live before profile_task_exit Thread-Index: AdY+AG0xoFxNBeBNTRuUPpzDg2aFdg== Date: Tue, 9 Jun 2020 02:30:02 +0000 Message-ID: <36882010b4b642a0b752eeeea697e783@huawei.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.166.215.131] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eric W. Biederman writes: > liuchao writes: > > > I want to dermine which thread is the last one to enter do_exit in > > profile_task_exit. But when a lot of threads exit, tsk->signal->live > > is not correct since it decrease after profile_task_exit. > > I don't think that would be wise. > > Any additional code before the sanity checks at the start of do_exit seems > like a bad idea. > > We could probably move the decrement of tsk->signal->live a little earlier, > but not that much earlier in the function. > > Does profile_task_exit even make sense that early in the code? If the code > is doing much of anything that is a completely inappopriate placement of > profile_task_exit. I think so too. Move the decrement of tsk->signal->live after the sanity checks, then profile_task_exit and kcov_task_exit make more sense. > > Eric > > > > Signed-off-by: liuchao > > --- > > kernel/exit.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/exit.c b/kernel/exit.c index > > ce2a75bc0ade..1693764bc356 100644 > > --- a/kernel/exit.c > > +++ b/kernel/exit.c > > @@ -708,6 +708,7 @@ void __noreturn do_exit(long code) > > struct task_struct *tsk = current; > > int group_dead; > > > > + group_dead = atomic_dec_and_test(&tsk->signal->live); > > profile_task_exit(tsk); > > kcov_task_exit(tsk); > > > > @@ -755,7 +756,6 @@ void __noreturn do_exit(long code) > > if (tsk->mm) > > sync_mm_rss(tsk->mm); > > acct_update_integrals(tsk); > > - group_dead = atomic_dec_and_test(&tsk->signal->live); > > if (group_dead) { > > /* > > * If the last thread of global init has exited, panic