From patchwork Thu Feb 22 16:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 204852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp43164dyb; Thu, 22 Feb 2024 08:11:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVsSZ9facghpdAakBn1LnihsBANxxY297tcfO2L2GN1U6dvcgyCliD2nlcxO1PAT+aZgdPYrsHbTCHQ7uiaZ+l0it+D/w== X-Google-Smtp-Source: AGHT+IGOgqHw9AdYWXW5dZjgXvW6qZzvI/hBOGzvrCl74siYss9p8BRlAtKfKVKOyn7pcPyMpoHl X-Received: by 2002:a05:6a00:1a8b:b0:6e2:853e:3d60 with SMTP id e11-20020a056a001a8b00b006e2853e3d60mr4737213pfv.13.1708618284512; Thu, 22 Feb 2024 08:11:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708618284; cv=pass; d=google.com; s=arc-20160816; b=H1NTYWFNTeGLCb6OJwzELHPQHjxVY/lHHvsnG2GGFRpU/Y2MjNKvci8XSI6nBe/9Fb CI+Ct5y8Dfqm35iPqEYVdZ1NjQsPh2kZjKxQcmI2G6bZmjSQ8ldjBDmz14QxY5E/k5m9 k3vMgvI5zFwIK6+xKRSMLQp2PiLAOd9QX67Ik2JK6gEWsd3rHvoheJLBPvjFIAS05MVr L2W7O/i2OC/Nmugc6cg7xbYwNvuk+zyeRyTSM7tYzPw4QFRUmbx/6cQBqpCKXhesynFl 0MgTGC7VxnlCdH43PoqFu5qvvu82PyClv+BZocnd+4PRifnxzXt6lSBuW4pLjKxn7yoS SHwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:subject:cc:to:from :message-id:dkim-signature; bh=vjLg0TSWsTe0chZQ3fuBODGo/vzvbbkVGlo25W/YgL8=; fh=E+fjSkszu/3wtcymzZVrQck5XVLw8YkYnkF0SUB03B0=; b=e65mYiZY5NmmrmTUhIGCtMEBRS3nfy9359P4yOn3zum1KJUkIwzIkIrQFOKaYf9AAo MrMOwmocdAU5VAbfhJp7l/KYm62uEeqrDmZd4hxO3bJ40vr7sca2PkkQ4ei0j1SQDw78 c7zuIsqAmuR6CK5xwSoLqVhzpd15UsZKHJIAz94uq5Gr0Zd1D4AvnKRO4bhGsfDgOGC1 CgF26b/Yzw2H81lQ0rWm3nNtZRRRRF9tPjGMhXG1twTlaacuS3n9sMajvV4y5VPsdSD4 jb0RTqZQq5WZkAH/eyY0G2xi+NAoFxhuwDBd45s50mX3glEwaZVdHeZw5MI4waecwC6Z YHPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=owEkeYMT; arc=pass (i=1 spf=pass spfdomain=foxmail.com dkim=pass dkdomain=foxmail.com dmarc=pass fromdomain=foxmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76860-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76860-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ca27-20020a056a02069b00b005dc500d9af0si10819118pgb.450.2024.02.22.08.11.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 08:11:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76860-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=owEkeYMT; arc=pass (i=1 spf=pass spfdomain=foxmail.com dkim=pass dkdomain=foxmail.com dmarc=pass fromdomain=foxmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76860-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76860-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5E68F288773 for ; Thu, 22 Feb 2024 16:11:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEEEA153BD4; Thu, 22 Feb 2024 16:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b="owEkeYMT" Received: from out203-205-221-231.mail.qq.com (out203-205-221-231.mail.qq.com [203.205.221.231]) (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 74B57151CC5 for ; Thu, 22 Feb 2024 16:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.221.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708618204; cv=none; b=UIzJtW1nKXHmUGBi18QxXP0DMAiBmQer2ziGTQGBOlQNMPUYL8UeULJZNuWyxhngTxY2e8QU+U+idQ5EElxC+TO4GYERAjjqAmt0F4c5ezSgWxG8j0UUesmYiP7FcvJAIgIV+j0zMwhLiTsPTdCfiUWFEx3f3uIz3rgAkTZviWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708618204; c=relaxed/simple; bh=VAARJbyByjfYUowrYEBvOr5VJx+E5jEyLas79aJZyFg=; h=Message-ID:From:To:Cc:Subject:Date:MIME-Version; b=C17Q3nYcCW0mmmk78pFzC2IivKdkx3+psPGUX7UaSM4ssqj9Yohc6fJWmjtj1STyVfpfpGWSc7rYC9w9btWwydrXWbabvojjC9kE+H3yhuDx6OkPzSyaEC0QeABq3QR+ZHgfGXn4KYKj1YCaViO1jgaqsQzvRUNj1TWjrq4GmEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com; spf=pass smtp.mailfrom=foxmail.com; dkim=pass (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b=owEkeYMT; arc=none smtp.client-ip=203.205.221.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foxmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1708617892; bh=vjLg0TSWsTe0chZQ3fuBODGo/vzvbbkVGlo25W/YgL8=; h=From:To:Cc:Subject:Date; b=owEkeYMTlWA81AQ2Ov455FK/7iNjh3ILUq4B2dPH3HRoJf5LdJFLczkRRS9en/olx V1l7rmOQSm6MKe0huQbmJFv8QQHSMcA8++jfp36OfWTsEqdQS+OXdtiLQe2/31pKhO G+8RayQWbZZMYPPcvwptgNogfcWQKFmVbo2OLluM= Received: from localhost.localdomain ([2409:8a60:2a61:ef40:7404:388f:486a:7747]) by newxmesmtplogicsvrszb6-0.qq.com (NewEsmtp) with SMTP id 131B565A; Fri, 23 Feb 2024 00:04:49 +0800 X-QQ-mid: xmsmtpt1708617889t56zrz7dp Message-ID: X-QQ-XMAILINFO: N3l5ASPewLWqAyF+hdEE/ByG4KGYO1CseUekNA69wAbtfaBeXNyKtLVasEGJN0 qy5g6p+FH26qGZHzdo5XnP3/bUsbmc58txge5SphCJ26cjze7bnV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c: Wen Yang , Oleg Nesterov , Mathieu Desnoyers , Mel Gorman , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] exit: add a tracepoint for profiling a task that is starting to exit Date: Fri, 23 Feb 2024 00:04:34 +0800 X-OQ-MSGID: <20240222160434.350595-1-wenyang.linux@foxmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791616125927791346 X-GMAIL-MSGID: 1791616125927791346 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. Commit 2d4bcf886e42 ("exit: Remove profile_task_exit & profile_munmap") simplified the code, but also removed profile_task_exit(), which may prevent third-party kernel modules from detecting process exits timely. Add the new trace_sched_profile_task_exit() this way a user-space monitor could detect the exits and potentially make some preparations in advance. Signed-off-by: Wen Yang Cc: Oleg Nesterov Cc: Steven Rostedt 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 | 1 + 2 files changed, 29 insertions(+) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index dbb01b4b7451..750b2f0bdf69 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -341,6 +341,34 @@ DEFINE_EVENT(sched_process_template, sched_wait_task, TP_PROTO(struct task_struct *p), TP_ARGS(p)); +/* + * Tracepoint for profiling a task that is starting to exit: + */ +TRACE_EVENT(sched_profile_task_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 a waiting task: */ diff --git a/kernel/exit.c b/kernel/exit.c index 493647fd7c07..f675f879a1b2 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_profile_task_exit(tsk, code); kcov_task_exit(tsk); kmsan_task_exit(tsk); From patchwork Thu Feb 22 16:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 204853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp51620dyb; Thu, 22 Feb 2024 08:24:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVZGn1+MQEzjFbTwctc/wwdrtpvb+GhtN8BqctVfPSDgtrsdxt8kIsy9yxKP4aEJTtEwg+YSqzHBvesxCR6vBCsW5Dnxw== X-Google-Smtp-Source: AGHT+IFqdEBcbQhY7N+f22mxb8oVD8BYvrQvhWva5YhN+zF4hO6YbM5rUQKpveHEsSKeo6XUH44D X-Received: by 2002:a05:6a20:c6c8:b0:1a0:c3e6:313e with SMTP id gw8-20020a056a20c6c800b001a0c3e6313emr5388772pzb.28.1708619084400; Thu, 22 Feb 2024 08:24:44 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t23-20020a62d157000000b006e0dd1fc7aasi10423318pfl.187.2024.02.22.08.24.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 08:24:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76850-ouuuleilei=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=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=C2pw+fnC; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-76850-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76850-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.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 56334B29EDA for ; Thu, 22 Feb 2024 16:06:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BD3A1509A1; Thu, 22 Feb 2024 16:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b="C2pw+fnC" Received: from out162-62-63-194.mail.qq.com (out162-62-63-194.mail.qq.com [162.62.63.194]) (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 1F5D115098A for ; Thu, 22 Feb 2024 16:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.62.63.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708617917; cv=none; b=KOE6taDZWH9Bs5A+LylBPvONBbWj+51frCwD3Z4pQ5uAXCrT7qlmTEM+cM/uhH7y19qZT4Nklpd+2wz1pmNnpUDbc81tC5cRmSa3N+BxfML7WrJfl/5910FkZ9AvFx/1Qk4kQQ0+tDpNlxTZwAqpLskAmuLJOYLwf7ut07EuLtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708617917; c=relaxed/simple; bh=ae7acFbeFbOsSBOJq7Wm0wlb7xN42xulyX2kNqEdUOo=; h=Message-ID:From:To:Cc:Subject:Date:MIME-Version; b=lBS0DJk/SXnOQdnxV8LMt90hy/l5/sgfkYa8WsN/jKsyDg5JakymrmeknuHdw5ib1CS3u4tHoVGKw8KHUtuq8MvT+vuvYpTtHjTnZS+yncTGmErQY3B+Ft2eY8sQDsEBOqbIqyVbT2SRcxx1v1t/LimfkR3OLiap5JQ4ruXAeDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com; spf=pass smtp.mailfrom=foxmail.com; dkim=pass (1024-bit key) header.d=foxmail.com header.i=@foxmail.com header.b=C2pw+fnC; arc=none smtp.client-ip=162.62.63.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foxmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foxmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1708617904; bh=zZh0WkZk+9GyZffXATDDdHfCvt2/6IAILrMFkC15vkQ=; h=From:To:Cc:Subject:Date; b=C2pw+fnCMVx8xK7NaPwqIQvCS5H+DCeMsCVWLdIfq1pUbLfSwHgqhN9aCTE1BwmUF KjW7TwYEwmy4zckquuYDk8Gb3MOwsNzYb6yrHo0ZIIzyBZMb7R+pMUp4T/8SFy1uer 1DfMbu3vC8ujcyPKSrY++iTomni9wYJvUJm6oCX4= Received: from localhost.localdomain ([2409:8a60:2a61:ef40:7404:388f:486a:7747]) by newxmesmtplogicsvrszb9-1.qq.com (NewEsmtp) with SMTP id 1408404F; Fri, 23 Feb 2024 00:05:00 +0800 X-QQ-mid: xmsmtpt1708617900tg2p8wddx Message-ID: X-QQ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tB2lRqgp0tcz6rOXCieF9v97M09bBg/TzssZERY1gQ4FHg0bNFOWD9y3sgQ== X-QQ-XMRINFO: MPJ6Tf5t3I/ycC2BItcBVIA= From: wenyang.linux@foxmail.com To: Christian Brauner , Andrew Morton , Oleg Nesterov Cc: Wen Yang , Thomas Gleixner , Sebastian Andrzej Siewior , Luis Chamberlain , Mike Christie , Dmitry Vyukov , Vincent Whitchurch , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] kernel/signal.c: explicitly initialize si_code and use ksig->info uniformly Date: Fri, 23 Feb 2024 00:04:57 +0800 X-OQ-MSGID: <20240222160457.350657-1-wenyang.linux@foxmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791616965078654800 X-GMAIL-MSGID: 1791616965078654800 From: Wen Yang By explicitly initializing ksig->info.si_code and uniformly using ksig->info, get_signal() function could be slightly optimized, as folowes: clear_siginfo(&ksig->info); ksig->info.si_signo = signr = SIGKILL; --> missed si_code sigdelset(¤t->pending.signal, SIGKILL); trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, --> unnecessary SEND_SIG_NOINFO &sighand->action[SIGKILL - 1]); recalc_sigpending(); goto fatal; .. fatal: .. if (sig_kernel_coredump(signr)) { .. do_coredump(&ksig->info); --> contains si_code } No functional change intended. Signed-off-by: Wen Yang Cc: Oleg Nesterov Cc: Andrew Morton Cc: Christian Brauner Cc: Thomas Gleixner Cc: Sebastian Andrzej Siewior Cc: Luis Chamberlain Cc: Mike Christie Cc: Dmitry Vyukov Cc: Vincent Whitchurch Cc: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org --- kernel/signal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/signal.c b/kernel/signal.c index 9b40109f0c56..8cab55bbec2f 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2732,8 +2732,9 @@ bool get_signal(struct ksignal *ksig) signal->group_exec_task) { clear_siginfo(&ksig->info); ksig->info.si_signo = signr = SIGKILL; + ksig->info.si_code = SI_USER; sigdelset(¤t->pending.signal, SIGKILL); - trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, + trace_signal_deliver(SIGKILL, &ksig->info, &sighand->action[SIGKILL - 1]); recalc_sigpending(); goto fatal;