Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1530627rbb; Mon, 26 Feb 2024 12:15:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV44+nTATClhrl6RIaz2ATSVNjopeQPhWfE7X0iiAPb5Ff2m924vuTJKCLpnZWK+0Jcz5vB7M2N6t+fP4sSmVJI2r2CLjAoT6BF+giQSw== X-Google-Smtp-Source: AGHT+IH0OherA8UIk9m+n4R4ess5MpgMGjQ/Myaczjvz4SKwUtMOkfe+fqpX6SG5fMF/9vaQ1fa5 X-Received: by 2002:a05:6a00:929e:b0:6e5:457e:645d with SMTP id jw30-20020a056a00929e00b006e5457e645dmr545894pfb.31.1708978558600; Mon, 26 Feb 2024 12:15:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708978558; cv=pass; d=google.com; s=arc-20160816; b=tyUvGKbvVjAO2X/egj+SJI4l8PqCvCcGKapBxARRv/YIJensJZD2cq2lce2lWDc80T BpVuHEfnE8U4W2K6GDxnzaqWpf4L/wMWpU83sPWg58MbbB8Au6H7bZrL9AUEoUQ6PLYA nzzqW1M5O3TeuV7sL2l7IiPSPrWX2sfdxHiY/A+o+dNNb4Wp+Q8KVB6upJTdHf+S7ezq s4yhIo7kj0d9mF+2d10eQdEw4+Rcb5+9eVmKhkMTRx7JCsWpy2FXh/Y25cTtVPJRsMSa RjpKM689hcuOYa5tVXpZRw0Roxx6X9UQdM4Etjfbontgl9LFkdq8LkVx26o6Q900kZ5G Ilwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=5i7BL5hCOxaRnKdA86IrwzpsGPN6Vv17A+A9wPGIjok=; fh=sNRxQ1SU3zEWXhWh6Qeg13H7fAyTOZ4fLXjgQvZBmTg=; b=A64DGqjXPMF6OHeapoxVwFwAfw2nh7zHQPpx43D7QaX+EbLFQW+dQ8ttVlGVuRFizn aspKt/BUoEzcIoIcTnwj3z+9OiUGDHM4gMashRiLES/hgwbbONso4oul/42rIz4bQEld WsuWVrSDkb9jsbdtbYSsSQn98qH/BHbvgnyxwa5zbmVEtU6UkwVL67i3+GuXuW97ygQB EiUUp+fhqeUgXoUbEdlP4EiaGY/+Omsfg8qIPaNP0+Xl90B1UtEUMA2aLLgTa0+IBo7i abs6hlGY3xp1WbI5RgRDaht2qlvmrkOfg763n6TOnHIoWv8odnRW0QO01hyKjlB3Bu0z pxTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZrSDcFM4; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82265-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82265-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id jc40-20020a056a006ca800b006e46df30033si4336329pfb.48.2024.02.26.12.15.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 12:15:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82265-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZrSDcFM4; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82265-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82265-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4BF0BB22A46 for ; Mon, 26 Feb 2024 19:46:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9387D12FF9E; Mon, 26 Feb 2024 19:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZrSDcFM4" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A68B060BA1 for ; Mon, 26 Feb 2024 19:46:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708976763; cv=none; b=lwutWdlFl6FpIoD5SAOicwasnlb9nBb/Wmcdbs1zvGGIKQg1+pt2dEjXf0hiQaOFyWs1N/XoxerFffhZXcB+t64MagzrGLzZU33tMS2Opn35OdUhj09HJYpnDZcA+JAeAwZcHY631KsvXDWNHL+rj3JLisQsk6ZKme+v/xgFVOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708976763; c=relaxed/simple; bh=PRIi2ZULSVf7CQK4g6AhLe5g/jZELpR4BhlNwOtoOjA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dGHjjsNMxGx2iXwnNoQCziHLq0NW5HY2qXoC2uO6PquIQO4GR0GFivd26I2xfeUrP9UVZwdWcNiDWjWrbVng0NMwjcfG6B8C5GpzaQM06ZkXkhEdAroGEQoozCC16eSQPM58+d5aA7n4TS3ZHgPc7a0Kh8+xUnxud0g21NNXFeg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZrSDcFM4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708976760; 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=5i7BL5hCOxaRnKdA86IrwzpsGPN6Vv17A+A9wPGIjok=; b=ZrSDcFM4dkhB9bqBwmVggrqvCJKo5gkNm5HoTx3LYcR+fqj1p1rnhoh0pbiJgCwu4kt3jg 964xryatqQEZDgq3ZA4ijsmy+7457UwjC1V1C4MeykWO42bfid8Grzik+daxOmkNpmXNBf MDhY1YoSUt9qt+mf9wdVFUVNzWk3TlE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-BQH8IQO6OxaTExHoz-2osw-1; Mon, 26 Feb 2024 14:45:58 -0500 X-MC-Unique: BQH8IQO6OxaTExHoz-2osw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69A6685A58B; Mon, 26 Feb 2024 19:45:57 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.85]) by smtp.corp.redhat.com (Postfix) with SMTP id 7CFA22022AAA; Mon, 26 Feb 2024 19:45:55 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 26 Feb 2024 20:44:38 +0100 (CET) Date: Mon, 26 Feb 2024 20:44:35 +0100 From: Oleg Nesterov To: wenyang.linux@foxmail.com Cc: Steven Rostedt , Masami Hiramatsu , Ingo Molnar , Mathieu Desnoyers , Mel Gorman , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] exit: add exit_code to trace_sched_process_exit and move it earlier in do_exit() Message-ID: <20240226194434.GC9510@redhat.com> References: Precedence: bulk X-Mailing-List: linux-kernel@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/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 Well. since I have already participated in the previous discussions... As I said, I can't ack this (user-visible) patch even if I tried to suggest this from the very beginning, I leave it to the maintainers. I see nothing wrong in this change, but let me ask: do we really need to report the exit code? this makes this patch even more user-visible and I have no idea if it can break the current users. On 02/23, wenyang.linux@foxmail.com wrote: > > From: Wen Yang > > Currently coredump_task_exit() takes some time to wait for the generation > of the dump file. But if the user-space wants to receive a notification > as soon as possible it maybe inconvenient. > > Add exit_code to the TP trace_sched_process_exit() and move it earlier in > do_exit(). This way a user-space monitor could detect the exits and > potentially make some preparations in advance. > > Suggested-by: Steven Rostedt > Signed-off-by: Wen Yang > Cc: Steven Rostedt > Cc: Oleg Nesterov > Cc: Masami Hiramatsu > Cc: Mathieu Desnoyers > Cc: Ingo Molnar > Cc: Mel Gorman > Cc: Peter Zijlstra > Cc: linux-kernel@vger.kernel.org > --- > include/trace/events/sched.h | 28 +++++++++++++++++++++++++--- > kernel/exit.c | 2 +- > 2 files changed, 26 insertions(+), 4 deletions(-) > > diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h > index dbb01b4b7451..c2e8655fd453 100644 > --- a/include/trace/events/sched.h > +++ b/include/trace/events/sched.h > @@ -330,9 +330,31 @@ DEFINE_EVENT(sched_process_template, sched_process_free, > /* > * Tracepoint for a task exiting: > */ > -DEFINE_EVENT(sched_process_template, sched_process_exit, > - TP_PROTO(struct task_struct *p), > - TP_ARGS(p)); > +TRACE_EVENT(sched_process_exit, > + > + TP_PROTO(struct task_struct *task, long code), > + > + TP_ARGS(task, code), > + > + TP_STRUCT__entry( > + __array( char, comm, TASK_COMM_LEN ) > + __field( pid_t, pid ) > + __field( int, prio ) > + __field( long, code ) > + ), > + > + TP_fast_assign( > + memcpy(__entry->comm, task->comm, TASK_COMM_LEN); > + __entry->pid = task->pid; > + __entry->prio = task->prio; > + __entry->code = code; > + ), > + > + TP_printk("comm=%s pid=%d prio=%d exit_code=0x%lx", > + __entry->comm, __entry->pid, __entry->prio, > + __entry->code) > +); > + > > /* > * Tracepoint for waiting on task to unschedule: > diff --git a/kernel/exit.c b/kernel/exit.c > index 493647fd7c07..48b6ed7f7760 100644 > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -826,6 +826,7 @@ void __noreturn do_exit(long code) > > WARN_ON(tsk->plug); > > + trace_sched_process_exit(tsk, code); > kcov_task_exit(tsk); > kmsan_task_exit(tsk); > > @@ -866,7 +867,6 @@ void __noreturn do_exit(long code) > > if (group_dead) > acct_process(); > - trace_sched_process_exit(tsk); > > exit_sem(tsk); > exit_shm(tsk); > -- > 2.25.1 >