Received: by 10.192.165.148 with SMTP id m20csp4270191imm; Mon, 30 Apr 2018 15:13:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpVTnsRjgZSfPynhokypwKfszzvNcOMVpm2LjFdnZuo3mNacZSQkRUlvVqCCXbqgX3Ndcs0 X-Received: by 2002:a65:4d8f:: with SMTP id p15-v6mr6975629pgq.305.1525126416357; Mon, 30 Apr 2018 15:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525126416; cv=none; d=google.com; s=arc-20160816; b=sHmf7bCL3QmJfXGr1/yPvctkOwxjNSy1MZOvWjnGDYTQcRSKI5K7P4rqgCk/IxOYPZ ASpfpNAY8AwlT5apbYrWRqh5LY1MUGFqpvwJAztwnJwM4chLb6Db36Tz9ZefVOLCbeQR 2hUIW/UI1Rb8vqQIp0PUvoBgb83+0bUYc18bYhRK3FCc+39QqwU0Fv+SbMdg/kVicfp7 oU+xsJbv1HfF4qlkhCauE+n1KDolUFM6zh1i+l3UQnU/yjpGNDQ6KKuzkJVvnhQqpIk/ brETPkyfsQwI2HZNZIkBjDC4mLhhmzPH3Wov3kJPRUyIAfj9ktg6t3BmmDU7T52HUftj v/pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=HsN5FewGQ8Ge58JqpxNMtpWU+NjKNYmU2CNSOIgo+MI=; b=B5OSwd7dQF9mZgnQNOWBBt/1Mj17ihLvSeaXuOyQuqlMnxzcjp0CSWBD2zE7C8opjc 3xZ93mjnD2cO5700MAfzhXpGCKuHdz2qk49J9Z3gIx43saF8NIa1xw5NVQx7jdGUGJ+t E0YzT/ll+UND9Bo4jo/12EYAP2bHy/DSF9Ja4yJD8J7XeI/U0gC9znlsbGGeRbeKU0MP sGCCkNokLQwAZ5uf8xYMCbvcxu0N15EHQ+/+ASxdRnt6DzWhCAdsLCYsEAVuCA84Tfml 5BwzN1aqeDbIh0OWWIIR4Vzle7K7bgLDbi8jIh4wv4ZSyRbzIRW9R8c7jSvvaF7HmS+Z pdSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=mouLevI0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2-v6si6659954pgf.354.2018.04.30.15.13.08; Mon, 30 Apr 2018 15:13:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=mouLevI0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754243AbeD3WM6 (ORCPT + 99 others); Mon, 30 Apr 2018 18:12:58 -0400 Received: from aer-iport-3.cisco.com ([173.38.203.53]:1879 "EHLO aer-iport-3.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751497AbeD3WM4 (ORCPT ); Mon, 30 Apr 2018 18:12:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2643; q=dns/txt; s=iport; t=1525126376; x=1526335976; h=from:to:cc:subject:date:message-id; bh=l42xLHTlpCJyQqqdfRU2vlisVrnre013rOiF40DCDIs=; b=mouLevI00ih7I7ErgTYfRbs/AuSp4T6VQlRKjRsqjv0xN8fGDpdDN8+z KHdcMXfo9OWoWV4iMburMm6EOBZkyxmYdWIEMlvgFaoBVMNoXn6Q269CS OZee/aL2dX/ErtTDWCx+wYuoqnZJUnN1YVGDMM20uw8pv7uPFu5HXZtNX c=; X-IronPort-AV: E=Sophos;i="5.49,348,1520899200"; d="scan'208";a="3468025" Received: from aer-iport-nat.cisco.com (HELO aer-core-3.cisco.com) ([173.38.203.22]) by aer-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Apr 2018 22:12:55 +0000 Received: from vycislitel.cisco.com (ams3-vpn-dhcp6203.cisco.com [10.61.88.58]) (authenticated bits=0) by aer-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id w3UMCkOd002289 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 30 Apr 2018 22:12:54 GMT From: Stefan Strogin To: Evgeniy Polyakov , David Miller , netdev@vger.kernel.org Cc: Stefan Strogin , linux-kernel@vger.kernel.org, xe-linux-external@cisco.com, Jesper Derehag , Matt Helsley Subject: [PATCH RESEND] connector: add parent pid and tgid to coredump and exit events Date: Tue, 1 May 2018 01:04:29 +0300 Message-Id: <20180430220429.14788-1-sstrogin@cisco.com> X-Mailer: git-send-email 2.16.1 X-Auto-Response-Suppress: DR, OOF, AutoReply X-Authenticated-User: sstrogin Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The intention is to get notified of process failures as soon as possible, before a possible core dumping (which could be very long) (e.g. in some process-manager). Coredump and exit process events are perfect for such use cases (see 2b5faa4c553f "connector: Added coredumping event to the process connector"). The problem is that for now the process-manager cannot know the parent of a dying process using connectors. This could be useful if the process-manager should monitor for failures only children of certain parents, so we could filter the coredump and exit events by parent process and/or thread ID. Add parent pid and tgid to coredump and exit process connectors event data. Signed-off-by: Stefan Strogin Acked-by: Evgeniy Polyakov --- drivers/connector/cn_proc.c | 4 ++++ include/uapi/linux/cn_proc.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index a782ce87715c..ed5e42461094 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c @@ -262,6 +262,8 @@ void proc_coredump_connector(struct task_struct *task) ev->what = PROC_EVENT_COREDUMP; ev->event_data.coredump.process_pid = task->pid; ev->event_data.coredump.process_tgid = task->tgid; + ev->event_data.coredump.parent_pid = task->real_parent->pid; + ev->event_data.coredump.parent_tgid = task->real_parent->tgid; memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); msg->ack = 0; /* not used */ @@ -288,6 +290,8 @@ void proc_exit_connector(struct task_struct *task) ev->event_data.exit.process_tgid = task->tgid; ev->event_data.exit.exit_code = task->exit_code; ev->event_data.exit.exit_signal = task->exit_signal; + ev->event_data.exit.parent_pid = task->real_parent->pid; + ev->event_data.exit.parent_tgid = task->real_parent->tgid; memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); msg->ack = 0; /* not used */ diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h index 68ff25414700..db210625cee8 100644 --- a/include/uapi/linux/cn_proc.h +++ b/include/uapi/linux/cn_proc.h @@ -116,12 +116,16 @@ struct proc_event { struct coredump_proc_event { __kernel_pid_t process_pid; __kernel_pid_t process_tgid; + __kernel_pid_t parent_pid; + __kernel_pid_t parent_tgid; } coredump; struct exit_proc_event { __kernel_pid_t process_pid; __kernel_pid_t process_tgid; __u32 exit_code, exit_signal; + __kernel_pid_t parent_pid; + __kernel_pid_t parent_tgid; } exit; } event_data; -- 2.16.1