Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1297412rdb; Mon, 19 Feb 2024 10:16:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTMvcnsLG/A2PzJXpm+h+FSMk6HulqhSmOnxDxlAbfOvYSnJ3405DRXvTci/8zk1qOiO/TMaqum3NjJShGMOGVy2QrEubUjNpoA2ob5A== X-Google-Smtp-Source: AGHT+IF8uOyN78D0stP/HqhKf+4l9JF+LkJ11hB6ujWagR+pG67S+LfDVkz8SYID9ehHsx4Krymk X-Received: by 2002:a05:6a20:9c97:b0:19e:bca3:213f with SMTP id mj23-20020a056a209c9700b0019ebca3213fmr17608475pzb.52.1708366609478; Mon, 19 Feb 2024 10:16:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708366609; cv=pass; d=google.com; s=arc-20160816; b=ctOdFzq6SQUcgrVf2xFW2+jJFbGC+KBnj/VWWyfp6KYImPlEBOxJGfkj3+dgyzhD5W JNI7TLFS4G+OkQZcY2+4iWAnkkBxFESy0dV4lnMTsKjUSbVnGSuyBxAEPdqv6qF/Uuk1 IRGpNfB26aWFM66YuhNk/3HAi5vVT641BCQZbo5soYFdpynJzm2y5tr9VpYLnipDCwv4 Y3yuIFoxWF/vXXbQMWo1P3+bTOIBMDtXuhBSPKh4Jvy/p9yDy3bz4lauGUoKVvysWuYT q2hvQrvdSgvifI8NeffuM2HlpxNiYL/W+6MTbrXXdRw3a0vUCZa7OcCeao91wP8efY// /aBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=11mzCRGs3VV78T1JeUist7w9BhM0rn1WxYStH+TUmXw=; fh=jslzOlrd0dfsFmYWpRQE+sEXiTXVavH6iY++riXhL3w=; b=0c00ZKPpDlmDJkevIpMOz8V5eppkT1tk+eIS6hMivx5B7nNjhOwSRwK5l3KZNw7nT+ sr1deSJOfWXpklT4RhldhuW3MOLxHH2MEmZUHHgrlmolAt1+JEM+s1Kwn322iqYhmWND 2EMGbKYzH2CXnJv4+F9JI/cMnmXxLzA8ktQE35p9gqfQHRIow/AesNYEnbZxaI5jyLvI 7ULRFg5yNNHuQk/r7pde/zzn2etypC4Z3ibceh+zHw2+oCeI2P6gDfofgQ1h6WqgjgK1 rQnNM7w2Kn6DdpUmBF3B2jUushZwMfWQvs6xAeWuL6R/AYutH5/RA1IBOaifivlS69n8 WG5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=nQ8mYB5r; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-71797-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id jc34-20020a056a006ca200b006e473370f21si664558pfb.399.2024.02.19.10.16.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 10:16:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71797-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=@efficios.com header.s=smtpout1 header.b=nQ8mYB5r; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-71797-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.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 700E0B2274A for ; Mon, 19 Feb 2024 18:10:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05570481AF; Mon, 19 Feb 2024 18:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="nQ8mYB5r" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (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 991D347F5D for ; Mon, 19 Feb 2024 18:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708366200; cv=none; b=pHFRr0bqJOR8TxDUWETI2XRm24n8Yii3B9ixb0uHId6nMrLAQGgelSakBLsxmmssPRt9JLWEIs3v6FQhok7qxybDFxjUiaeFppQNqi5CSSjfHtq1OiikqYDg69NZd945wvKHVKhIkBLkACSrucGNu65vf+kRDhS8KwHW8eltFGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708366200; c=relaxed/simple; bh=RfBCXLwyCUeqZQEFpji75aPuuqXowh06NHelS8dUuSc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SY6MllDQpdEkE6k9vypwsaOklp4szWnRjWrsR8lyNa3xQ84zH9tXVblQ/N78lICqkmiGQKtXL0dhE2tDKA/aprcAzaKLqzfhBSWvZG69SDGjLw4Va2dwHeqL2sHo1i0pK29lgADTWK46zOyak6f2pXFBxJzoCFT4jic0BE+pNRQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=nQ8mYB5r; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1708365676; bh=RfBCXLwyCUeqZQEFpji75aPuuqXowh06NHelS8dUuSc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nQ8mYB5rDyHcJmVZ2AurI90Bg6HQ+uf8P+ck8e1SDJoxe53nNWLTxDwDG4c7NRKNm 548aH/nzgVX4jc7NOUXKC1w64SCbKxfvZb03abl3IAU/1oTs9ukktX2l0g68+5pLMM G9h0UNGNMUapjggYBysuJvzwVW+wDM3QHDYi8PDRP6DvCaxhiaqfO3gBsQnyMhKqIR DtF6FiWubxDBrhYvk+O+3iaqX1UmXDY7dteeGdenzFERonD1osDlqr8NdymuPndcvf F2GMzzHjTShTfQz4pjM52OgOHg1JCCF7lAzrnYMhajHlYMxBR7JCPz+XyQjKXg84cp FgRe3CF5ExTLQ== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Tdr2444BqzZyH; Mon, 19 Feb 2024 13:01:16 -0500 (EST) Message-ID: <776b842b-b19f-44bf-bc34-ac756fce7466@efficios.com> Date: Mon, 19 Feb 2024 13:01:16 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] coredump debugging: add a tracepoint to report the coredumping Content-Language: en-US To: Steven Rostedt , Oleg Nesterov Cc: wenyang.linux@foxmail.com, Masami Hiramatsu , Ingo Molnar , Mel Gorman , Peter Zijlstra , linux-kernel@vger.kernel.org References: <20240217104924.GB10393@redhat.com> <20240219112926.77ac16f8@gandalf.local.home> <20240219170038.GA710@redhat.com> <20240219122825.31579a1e@gandalf.local.home> From: Mathieu Desnoyers In-Reply-To: <20240219122825.31579a1e@gandalf.local.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024-02-19 12:28, Steven Rostedt wrote: > On Mon, 19 Feb 2024 18:00:38 +0100 > Oleg Nesterov wrote: > >>> void __noreturn do_exit(long code) >>> { >>> struct task_struct *tsk = current; >>> int group_dead; >>> >>> [...] >>> acct_collect(code, group_dead); >>> if (group_dead) >>> tty_audit_exit(); >>> audit_free(tsk); >>> >>> tsk->exit_code = code; >>> taskstats_exit(tsk, group_dead); >>> >>> exit_mm(); >>> >>> if (group_dead) >>> acct_process(); >>> trace_sched_process_exit(tsk); >>> >>> There's a lot that happens before we trigger the above event. >> >> and a lot after. > > True. There really isn't a meaningful location here is there? > > I actually use this tracepoint in my pid tracing. > > The set_ftrace_pid and set_event_pid from /sys/kernel/tracing will add and > remove PIDs if the options function-fork or event-fork are set respectively. > > I hook to the sched_process_fork tracepoint to add new PIDs if the parent > pid is already in one of the files, and remove a PID via the > sched_process_exit function. No ? Those hook on sched_process_free, which is the actual point where the task is freed (AFAIR after it's been a zombie and then waited for by another task). kernel/trace/trace_events.c: void trace_event_follow_fork(struct trace_array *tr, bool enable) { if (enable) { register_trace_prio_sched_process_fork(event_filter_pid_sched_process_fork, tr, INT_MIN); register_trace_prio_sched_process_free(event_filter_pid_sched_process_exit, tr, INT_MAX); } else { unregister_trace_sched_process_fork(event_filter_pid_sched_process_fork, tr); unregister_trace_sched_process_free(event_filter_pid_sched_process_exit, tr); } } kernel/trace/ftrace.c: void ftrace_pid_follow_fork(struct trace_array *tr, bool enable) { if (enable) { register_trace_sched_process_fork(ftrace_pid_follow_sched_process_fork, tr); register_trace_sched_process_free(ftrace_pid_follow_sched_process_exit, tr); } else { unregister_trace_sched_process_fork(ftrace_pid_follow_sched_process_fork, tr); unregister_trace_sched_process_free(ftrace_pid_follow_sched_process_exit, tr); } } AFAIU, "sched_process_exit" is issued close to the point where the task exits (it should not go back to userspace after that). "sched_process_free" is done when the task is really being removed. Between "sched_process_exit" and "sched_process_free", the task can still be observed by a trace analysis looking at sched and signal events: it's a zombie at that stage. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com