From patchwork Wed Nov 8 20:49:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 835987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yXJbD1Fq4z9s7g for ; Thu, 9 Nov 2017 08:00:08 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A1C87C48; Wed, 8 Nov 2017 21:00:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A7E7598A for ; Wed, 8 Nov 2017 21:00:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4FC684F5 for ; Wed, 8 Nov 2017 21:00:04 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 08 Nov 2017 13:00:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,365,1505804400"; d="scan'208";a="171276130" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by orsmga005.jf.intel.com with ESMTP; 08 Nov 2017 13:00:02 -0800 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Wed, 8 Nov 2017 20:49:26 +0000 Message-Id: <1510174167-71108-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/2] process: Extend get_process_info() for additional fields. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This commit enables the fields relating to process name and the core number the process was last scheduled. The fields will be used by keepalive monitoring framework in future commits. This commit also fixes the following "sparse" warning: lib/process.c:439:16: error: use of assignment suppression and length modifier together in gnu_scanf format [-Werror=format=]. Signed-off-by: Bhanuprakash Bodireddy --- lib/process.c | 43 +++++++++++++++++++++++-------------------- lib/process.h | 2 ++ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/process.c b/lib/process.c index dd678cd..78de4b8 100644 --- a/lib/process.c +++ b/lib/process.c @@ -64,7 +64,8 @@ struct raw_process_info { long long int uptime; /* ms since started. */ long long int cputime; /* ms of CPU used during 'uptime'. */ pid_t ppid; /* Parent. */ - char name[18]; /* Name (surrounded by parentheses). */ + int core_id; /* Core id last executed on. */ + char name[18]; /* Name. */ }; /* Pipe used to signal child termination. */ @@ -421,7 +422,7 @@ get_raw_process_info(pid_t pid, struct raw_process_info *raw) n = fscanf(stream, "%*d " /* (1. pid) */ - "%17s " /* 2. process name */ + "(%17[^)]) " /* 2. process name */ "%*c " /* (3. state) */ "%lu " /* 4. ppid */ "%*d " /* (5. pgid) */ @@ -444,33 +445,34 @@ get_raw_process_info(pid_t pid, struct raw_process_info *raw) "%llu " /* 22. start_time */ "%llu " /* 23. vsize */ "%llu " /* 24. rss */ + "%*u " /* (25. rsslim) */ + "%*u " /* (26. start_code) */ + "%*u " /* (27. end_code) */ + "%*u " /* (28. start_stack) */ + "%*u " /* (29. esp) */ + "%*u " /* (30. eip) */ + "%*u " /* (31. pending signals) */ + "%*u " /* (32. blocked signals) */ + "%*u " /* (33. ignored signals) */ + "%*u " /* (34. caught signals) */ + "%*u " /* (35. whcan) */ + "%*u " /* (36. always 0) */ + "%*u " /* (37. always 0) */ + "%*d " /* (38. exit_signal) */ + "%d " /* 39. task_cpu */ #if 0 /* These are here for documentation but #if'd out to save * actually parsing them from the stream for no benefit. */ - "%*lu " /* (25. rsslim) */ - "%*lu " /* (26. start_code) */ - "%*lu " /* (27. end_code) */ - "%*lu " /* (28. start_stack) */ - "%*lu " /* (29. esp) */ - "%*lu " /* (30. eip) */ - "%*lu " /* (31. pending signals) */ - "%*lu " /* (32. blocked signals) */ - "%*lu " /* (33. ignored signals) */ - "%*lu " /* (34. caught signals) */ - "%*lu " /* (35. whcan) */ - "%*lu " /* (36. always 0) */ - "%*lu " /* (37. always 0) */ - "%*d " /* (38. exit_signal) */ - "%*d " /* (39. task_cpu) */ "%*u " /* (40. rt_priority) */ "%*u " /* (41. policy) */ "%*llu " /* (42. blkio_ticks) */ "%*lu " /* (43. gtime) */ "%*ld" /* (44. cgtime) */ #endif - , raw->name, &ppid, &utime, &stime, &start_time, &vsize, &rss); + , raw->name, &ppid, &utime, &stime, &start_time, + &vsize, &rss, &raw->core_id); fclose(stream); - if (n != 7) { + if (n != 8) { VLOG_ERR_ONCE("%s: fscanf failed", file_name); return false; } @@ -496,12 +498,14 @@ get_process_info(pid_t pid, struct process_info *pinfo) return false; } + ovs_strlcpy(pinfo->name, child.name, sizeof pinfo->name); pinfo->vsz = child.vsz; pinfo->rss = child.rss; pinfo->booted = child.uptime; pinfo->crashes = 0; pinfo->uptime = child.uptime; pinfo->cputime = child.cputime; + pinfo->core_id = child.core_id; if (child.ppid) { struct raw_process_info parent; @@ -579,7 +583,6 @@ process_run(void) #endif } - /* Causes the next call to poll_block() to wake up when process 'p' has * exited. */ void diff --git a/lib/process.h b/lib/process.h index 999ac68..8c52820 100644 --- a/lib/process.h +++ b/lib/process.h @@ -29,6 +29,8 @@ struct process_info { int crashes; /* # of crashes (usually 0). */ long long int uptime; /* ms since last (re)started by monitor. */ long long int cputime; /* ms of CPU used during 'uptime'. */ + int core_id; + char name[18]; }; /* Starting and monitoring subprocesses. From patchwork Wed Nov 8 20:49:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 835988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yXJbk39p9z9s7G for ; Thu, 9 Nov 2017 08:00:34 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8CE83C46; Wed, 8 Nov 2017 21:00:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id EF9D298A for ; Wed, 8 Nov 2017 21:00:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B25B34F5 for ; Wed, 8 Nov 2017 21:00:05 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 08 Nov 2017 13:00:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,365,1505804400"; d="scan'208";a="171276162" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by orsmga005.jf.intel.com with ESMTP; 08 Nov 2017 13:00:02 -0800 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Wed, 8 Nov 2017 20:49:27 +0000 Message-Id: <1510174167-71108-2-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1510174167-71108-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1510174167-71108-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/2] system-stats: Include core number in the process stats. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When dumping process statistics, include the the core number the process was last scheduled. With 'other_config:enable-statistics=true', Before: {cpu="28", file_systems="/,8474624,7826220 /workspace,223835956,199394160", load_average="1.29,1.76,1.33", memory="65861460,27457540,3813488,1999868,0", process_ovs-vswitchd="4685896,17452,362920,0,383967,383967", process_ovsdb-server="48088,5172,60,0,384057,384057"} After: {cpu="28", file_systems="/,8474624,7826308 /workspace,223835956,199394172", load_average="1.30,1.04,1.13", memory="65861460,27469176,3815252,1999868,0", process_ovs-vswitchd="4686020,17360,127380,0,148406,148406,3", process_ovsdb-server="48096,5212,30,0,148496,148496,4"} eg: process vsz , rss , cputime, crashes, booted, uptime, core_id ovs-vswitchd="4686020,17360, 127380, 0 , 148406, 148406, 3" Signed-off-by: Bhanuprakash Bodireddy --- vswitchd/system-stats.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vswitchd/system-stats.c b/vswitchd/system-stats.c index b780476..aaab676 100644 --- a/vswitchd/system-stats.c +++ b/vswitchd/system-stats.c @@ -205,9 +205,10 @@ get_process_stats(struct smap *stats) (int) (extension - de->d_name), de->d_name); if (!smap_get(stats, key)) { if (LINUX && get_process_info(pid, &pinfo)) { - smap_add_format(stats, key, "%lu,%lu,%lld,%d,%lld,%lld", + smap_add_format(stats, key, "%lu,%lu,%lld,%d,%lld,%lld,%d", pinfo.vsz, pinfo.rss, pinfo.cputime, - pinfo.crashes, pinfo.booted, pinfo.uptime); + pinfo.crashes, pinfo.booted, pinfo.uptime, + pinfo.core_id); } else { smap_add(stats, key, ""); }