License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2006-07-14 07:24:42 +00:00
|
|
|
/* getdelays.c
|
|
|
|
*
|
|
|
|
* Utility to get per-pid and per-tgid delay accounting statistics
|
|
|
|
* Also illustrates usage of the taskstats interface
|
|
|
|
*
|
|
|
|
* Copyright (C) Shailabh Nagar, IBM Corp. 2005
|
|
|
|
* Copyright (C) Balbir Singh, IBM Corp. 2006
|
2006-07-14 07:24:45 +00:00
|
|
|
* Copyright (c) Jay Lan, SGI. 2006
|
2006-07-14 07:24:42 +00:00
|
|
|
*
|
2006-12-10 10:19:55 +00:00
|
|
|
* Compile with
|
|
|
|
* gcc -I/usr/src/linux/include getdelays.c -o getdelays
|
2006-07-14 07:24:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <poll.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/socket.h>
|
2010-10-27 22:34:42 +00:00
|
|
|
#include <sys/wait.h>
|
2006-07-14 07:24:42 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include <linux/genetlink.h>
|
|
|
|
#include <linux/taskstats.h>
|
2007-11-15 00:59:14 +00:00
|
|
|
#include <linux/cgroupstats.h>
|
2006-07-14 07:24:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic macros for dealing with netlink sockets. Might be duplicated
|
|
|
|
* elsewhere. It is recommended that commercial grade applications use
|
|
|
|
* libnl or libnetlink and use the interfaces provided by the library
|
|
|
|
*/
|
|
|
|
#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
|
|
|
|
#define GENLMSG_PAYLOAD(glh) (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN)
|
|
|
|
#define NLA_DATA(na) ((void *)((char*)(na) + NLA_HDRLEN))
|
|
|
|
#define NLA_PAYLOAD(len) (len - NLA_HDRLEN)
|
|
|
|
|
2006-12-10 10:19:55 +00:00
|
|
|
#define err(code, fmt, arg...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, fmt, ##arg); \
|
|
|
|
exit(code); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
int done;
|
|
|
|
int rcvbufsz;
|
|
|
|
char name[100];
|
|
|
|
int dbg;
|
|
|
|
int print_delays;
|
[PATCH] io-accounting: add to getdelays
Wire up the IO accounting into getdelays.c.
Usage:
To display I/O stats for each exitting task:
vmm:/home/akpm> ./getdelays -m0,1,2,3 -i -l
cpumask 0 maskset 1
printing IO accounting
listen forever
rm: read=8192, write=0, cancelled_write=0
cvs: read=733184, write=4255744, cancelled_write=4096
make: read=217088, write=0, cancelled_write=0
cc1: read=4263936, write=12288, cancelled_write=0
as: read=811008, write=8192, cancelled_write=0
gcc: read=323584, write=0, cancelled_write=12288
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=4096
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=1011712, write=16384, cancelled_write=0
collect2: read=626688, write=0, cancelled_write=0
gcc: read=204800, write=0, cancelled_write=0
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=8192, write=16384, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
cc1: read=0, write=4096, cancelled_write=0
ld: read=4096, write=12288, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
To display I/O stats for a particular presently-running task:
vmm:/home/akpm> ./getdelays -i -p $(pidof crond)
printing IO accounting
crond: read=61440, write=0, cancelled_write=0
Cc: Jay Lan <jlan@sgi.com>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Chris Sturtivant <csturtiv@sgi.com>
Cc: Tony Ernst <tee@sgi.com>
Cc: Guillaume Thouvenin <guillaume.thouvenin@bull.net>
Cc: David Wright <daw@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 10:19:56 +00:00
|
|
|
int print_io_accounting;
|
2007-07-16 06:40:48 +00:00
|
|
|
int print_task_context_switch_counts;
|
2006-12-10 10:19:55 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
#define PRINTF(fmt, arg...) { \
|
|
|
|
if (dbg) { \
|
|
|
|
printf(fmt, ##arg); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Maximum size of response requested or message sent */
|
2006-11-03 06:07:26 +00:00
|
|
|
#define MAX_MSG_SIZE 1024
|
2006-07-14 07:24:45 +00:00
|
|
|
/* Maximum number of cpus expected to be specified in a cpumask */
|
|
|
|
#define MAX_CPUS 32
|
|
|
|
|
|
|
|
struct msgtemplate {
|
|
|
|
struct nlmsghdr n;
|
|
|
|
struct genlmsghdr g;
|
|
|
|
char buf[MAX_MSG_SIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
char cpumask[100+6*MAX_CPUS];
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2007-05-08 07:30:13 +00:00
|
|
|
static void usage(void)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] "
|
|
|
|
"[-m cpumask] [-t tgid] [-p pid]\n");
|
|
|
|
fprintf(stderr, " -d: print delayacct stats\n");
|
|
|
|
fprintf(stderr, " -i: print IO accounting (works only with -p)\n");
|
|
|
|
fprintf(stderr, " -l: listen forever\n");
|
|
|
|
fprintf(stderr, " -v: debug on\n");
|
2007-11-15 00:59:14 +00:00
|
|
|
fprintf(stderr, " -C: container path\n");
|
2007-05-08 07:30:13 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 07:24:42 +00:00
|
|
|
/*
|
|
|
|
* Create a raw netlink socket and bind
|
|
|
|
*/
|
2006-07-14 07:24:45 +00:00
|
|
|
static int create_nl_socket(int protocol)
|
2006-07-14 07:24:42 +00:00
|
|
|
{
|
2006-07-14 07:24:45 +00:00
|
|
|
int fd;
|
|
|
|
struct sockaddr_nl local;
|
|
|
|
|
|
|
|
fd = socket(AF_NETLINK, SOCK_RAW, protocol);
|
|
|
|
if (fd < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (rcvbufsz)
|
|
|
|
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
|
|
|
|
&rcvbufsz, sizeof(rcvbufsz)) < 0) {
|
2012-08-08 18:56:14 +00:00
|
|
|
fprintf(stderr, "Unable to set socket rcv buf size to %d\n",
|
2006-12-10 10:19:55 +00:00
|
|
|
rcvbufsz);
|
2012-08-08 18:56:14 +00:00
|
|
|
goto error;
|
2006-07-14 07:24:45 +00:00
|
|
|
}
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
memset(&local, 0, sizeof(local));
|
|
|
|
local.nl_family = AF_NETLINK;
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
if (bind(fd, (struct sockaddr *) &local, sizeof(local)) < 0)
|
|
|
|
goto error;
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
return fd;
|
|
|
|
error:
|
|
|
|
close(fd);
|
|
|
|
return -1;
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid,
|
2006-07-14 07:24:45 +00:00
|
|
|
__u8 genl_cmd, __u16 nla_type,
|
|
|
|
void *nla_data, int nla_len)
|
2006-07-14 07:24:42 +00:00
|
|
|
{
|
2006-07-14 07:24:45 +00:00
|
|
|
struct nlattr *na;
|
|
|
|
struct sockaddr_nl nladdr;
|
|
|
|
int r, buflen;
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
struct msgtemplate msg;
|
|
|
|
|
|
|
|
msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
|
|
|
|
msg.n.nlmsg_type = nlmsg_type;
|
|
|
|
msg.n.nlmsg_flags = NLM_F_REQUEST;
|
|
|
|
msg.n.nlmsg_seq = 0;
|
|
|
|
msg.n.nlmsg_pid = nlmsg_pid;
|
|
|
|
msg.g.cmd = genl_cmd;
|
|
|
|
msg.g.version = 0x1;
|
|
|
|
na = (struct nlattr *) GENLMSG_DATA(&msg);
|
|
|
|
na->nla_type = nla_type;
|
|
|
|
na->nla_len = nla_len + 1 + NLA_HDRLEN;
|
|
|
|
memcpy(NLA_DATA(na), nla_data, nla_len);
|
|
|
|
msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
|
|
|
|
|
|
|
|
buf = (char *) &msg;
|
|
|
|
buflen = msg.n.nlmsg_len ;
|
|
|
|
memset(&nladdr, 0, sizeof(nladdr));
|
|
|
|
nladdr.nl_family = AF_NETLINK;
|
|
|
|
while ((r = sendto(sd, buf, buflen, 0, (struct sockaddr *) &nladdr,
|
|
|
|
sizeof(nladdr))) < buflen) {
|
|
|
|
if (r > 0) {
|
|
|
|
buf += r;
|
|
|
|
buflen -= r;
|
|
|
|
} else if (errno != EAGAIN)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
|
2006-07-14 07:24:42 +00:00
|
|
|
/*
|
|
|
|
* Probe the controller in genetlink to find the family id
|
|
|
|
* for the TASKSTATS family
|
|
|
|
*/
|
2009-09-22 23:43:42 +00:00
|
|
|
static int get_family_id(int sd)
|
2006-07-14 07:24:42 +00:00
|
|
|
{
|
2006-07-14 07:24:45 +00:00
|
|
|
struct {
|
|
|
|
struct nlmsghdr n;
|
|
|
|
struct genlmsghdr g;
|
|
|
|
char buf[256];
|
|
|
|
} ans;
|
|
|
|
|
2008-02-08 12:21:56 +00:00
|
|
|
int id = 0, rc;
|
2006-07-14 07:24:45 +00:00
|
|
|
struct nlattr *na;
|
|
|
|
int rep_len;
|
|
|
|
|
|
|
|
strcpy(name, TASKSTATS_GENL_NAME);
|
|
|
|
rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
|
|
|
|
CTRL_ATTR_FAMILY_NAME, (void *)name,
|
|
|
|
strlen(TASKSTATS_GENL_NAME)+1);
|
2011-05-26 23:25:15 +00:00
|
|
|
if (rc < 0)
|
|
|
|
return 0; /* sendto() failure? */
|
2006-07-14 07:24:45 +00:00
|
|
|
|
|
|
|
rep_len = recv(sd, &ans, sizeof(ans), 0);
|
|
|
|
if (ans.n.nlmsg_type == NLMSG_ERROR ||
|
|
|
|
(rep_len < 0) || !NLMSG_OK((&ans.n), rep_len))
|
|
|
|
return 0;
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
na = (struct nlattr *) GENLMSG_DATA(&ans);
|
|
|
|
na = (struct nlattr *) ((char *) na + NLA_ALIGN(na->nla_len));
|
|
|
|
if (na->nla_type == CTRL_ATTR_FAMILY_ID) {
|
|
|
|
id = *(__u16 *) NLA_DATA(na);
|
|
|
|
}
|
|
|
|
return id;
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
|
|
|
|
2011-05-26 23:25:16 +00:00
|
|
|
#define average_ms(t, c) (t / 1000000ULL / (c ? c : 1))
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void print_delayacct(struct taskstats *t)
|
2006-07-14 07:24:42 +00:00
|
|
|
{
|
2011-05-26 23:25:16 +00:00
|
|
|
printf("\n\nCPU %15s%15s%15s%15s%15s\n"
|
|
|
|
" %15llu%15llu%15llu%15llu%15.3fms\n"
|
|
|
|
"IO %15s%15s%15s\n"
|
|
|
|
" %15llu%15llu%15llums\n"
|
|
|
|
"SWAP %15s%15s%15s\n"
|
|
|
|
" %15llu%15llu%15llums\n"
|
|
|
|
"RECLAIM %12s%15s%15s\n"
|
2018-10-26 22:06:08 +00:00
|
|
|
" %15llu%15llu%15llums\n"
|
|
|
|
"THRASHING%12s%15s%15s\n"
|
2011-05-26 23:25:16 +00:00
|
|
|
" %15llu%15llu%15llums\n",
|
|
|
|
"count", "real total", "virtual total",
|
|
|
|
"delay total", "delay average",
|
docsrc: fix getdelays printk formats
Fix printf format type warnings (seen on alpha & ia64):
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 7 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 8 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 9 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 12 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 13 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 16 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 17 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:236: warning: 'cmd_type' may be used uninitialized in this function
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-08-12 22:09:10 +00:00
|
|
|
(unsigned long long)t->cpu_count,
|
|
|
|
(unsigned long long)t->cpu_run_real_total,
|
|
|
|
(unsigned long long)t->cpu_run_virtual_total,
|
|
|
|
(unsigned long long)t->cpu_delay_total,
|
2011-05-26 23:25:16 +00:00
|
|
|
average_ms((double)t->cpu_delay_total, t->cpu_count),
|
|
|
|
"count", "delay total", "delay average",
|
docsrc: fix getdelays printk formats
Fix printf format type warnings (seen on alpha & ia64):
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 7 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 8 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 9 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 12 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 13 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 16 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 17 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:236: warning: 'cmd_type' may be used uninitialized in this function
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-08-12 22:09:10 +00:00
|
|
|
(unsigned long long)t->blkio_count,
|
|
|
|
(unsigned long long)t->blkio_delay_total,
|
2011-05-26 23:25:16 +00:00
|
|
|
average_ms(t->blkio_delay_total, t->blkio_count),
|
|
|
|
"count", "delay total", "delay average",
|
docsrc: fix getdelays printk formats
Fix printf format type warnings (seen on alpha & ia64):
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 7 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 8 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 9 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 12 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 13 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 16 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 17 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:236: warning: 'cmd_type' may be used uninitialized in this function
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-08-12 22:09:10 +00:00
|
|
|
(unsigned long long)t->swapin_count,
|
|
|
|
(unsigned long long)t->swapin_delay_total,
|
2011-05-26 23:25:16 +00:00
|
|
|
average_ms(t->swapin_delay_total, t->swapin_count),
|
|
|
|
"count", "delay total", "delay average",
|
docsrc: fix getdelays printk formats
Fix printf format type warnings (seen on alpha & ia64):
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 7 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 8 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 9 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 12 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 13 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 16 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 17 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:236: warning: 'cmd_type' may be used uninitialized in this function
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-08-12 22:09:10 +00:00
|
|
|
(unsigned long long)t->freepages_count,
|
2011-05-26 23:25:16 +00:00
|
|
|
(unsigned long long)t->freepages_delay_total,
|
2018-10-26 22:06:08 +00:00
|
|
|
average_ms(t->freepages_delay_total, t->freepages_count),
|
|
|
|
"count", "delay total", "delay average",
|
|
|
|
(unsigned long long)t->thrashing_count,
|
|
|
|
(unsigned long long)t->thrashing_delay_total,
|
|
|
|
average_ms(t->thrashing_delay_total, t->thrashing_count));
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void task_context_switch_counts(struct taskstats *t)
|
2007-07-16 06:40:48 +00:00
|
|
|
{
|
|
|
|
printf("\n\nTask %15s%15s\n"
|
2008-02-08 12:21:56 +00:00
|
|
|
" %15llu%15llu\n",
|
2007-07-16 06:40:48 +00:00
|
|
|
"voluntary", "nonvoluntary",
|
docsrc: fix getdelays printk formats
Fix printf format type warnings (seen on alpha & ia64):
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 7 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 8 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 9 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 12 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 13 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 16 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 17 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:236: warning: 'cmd_type' may be used uninitialized in this function
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-08-12 22:09:10 +00:00
|
|
|
(unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw);
|
2007-07-16 06:40:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void print_cgroupstats(struct cgroupstats *c)
|
2007-11-15 00:59:14 +00:00
|
|
|
{
|
|
|
|
printf("sleeping %llu, blocked %llu, running %llu, stopped %llu, "
|
docsrc: fix getdelays printk formats
Fix printf format type warnings (seen on alpha & ia64):
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 7 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 8 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 9 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 12 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 13 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 16 has type '__u64'
Documentation/accounting/getdelays.c:206: warning: format '%15llu' expects type 'long long unsigned int', but argument 17 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:214: warning: format '%15llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type '__u64'
Documentation/accounting/getdelays.c:221: warning: format '%llu' expects type 'long long unsigned int', but argument 6 has type '__u64'
Documentation/accounting/getdelays.c:236: warning: 'cmd_type' may be used uninitialized in this function
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-08-12 22:09:10 +00:00
|
|
|
"uninterruptible %llu\n", (unsigned long long)c->nr_sleeping,
|
|
|
|
(unsigned long long)c->nr_io_wait,
|
|
|
|
(unsigned long long)c->nr_running,
|
|
|
|
(unsigned long long)c->nr_stopped,
|
|
|
|
(unsigned long long)c->nr_uninterruptible);
|
2007-11-15 00:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void print_ioacct(struct taskstats *t)
|
[PATCH] io-accounting: add to getdelays
Wire up the IO accounting into getdelays.c.
Usage:
To display I/O stats for each exitting task:
vmm:/home/akpm> ./getdelays -m0,1,2,3 -i -l
cpumask 0 maskset 1
printing IO accounting
listen forever
rm: read=8192, write=0, cancelled_write=0
cvs: read=733184, write=4255744, cancelled_write=4096
make: read=217088, write=0, cancelled_write=0
cc1: read=4263936, write=12288, cancelled_write=0
as: read=811008, write=8192, cancelled_write=0
gcc: read=323584, write=0, cancelled_write=12288
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=4096
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=1011712, write=16384, cancelled_write=0
collect2: read=626688, write=0, cancelled_write=0
gcc: read=204800, write=0, cancelled_write=0
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=8192, write=16384, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
cc1: read=0, write=4096, cancelled_write=0
ld: read=4096, write=12288, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
To display I/O stats for a particular presently-running task:
vmm:/home/akpm> ./getdelays -i -p $(pidof crond)
printing IO accounting
crond: read=61440, write=0, cancelled_write=0
Cc: Jay Lan <jlan@sgi.com>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Chris Sturtivant <csturtiv@sgi.com>
Cc: Tony Ernst <tee@sgi.com>
Cc: Guillaume Thouvenin <guillaume.thouvenin@bull.net>
Cc: David Wright <daw@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 10:19:56 +00:00
|
|
|
{
|
|
|
|
printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
|
|
|
|
t->ac_comm,
|
|
|
|
(unsigned long long)t->read_bytes,
|
|
|
|
(unsigned long long)t->write_bytes,
|
|
|
|
(unsigned long long)t->cancelled_write_bytes);
|
|
|
|
}
|
|
|
|
|
2006-07-14 07:24:42 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2009-06-16 22:33:46 +00:00
|
|
|
int c, rc, rep_len, aggr_len, len2;
|
|
|
|
int cmd_type = TASKSTATS_CMD_ATTR_UNSPEC;
|
2006-07-14 07:24:45 +00:00
|
|
|
__u16 id;
|
|
|
|
__u32 mypid;
|
|
|
|
|
|
|
|
struct nlattr *na;
|
|
|
|
int nl_sd = -1;
|
|
|
|
int len = 0;
|
|
|
|
pid_t tid = 0;
|
|
|
|
pid_t rtid = 0;
|
|
|
|
|
|
|
|
int fd = 0;
|
|
|
|
int count = 0;
|
|
|
|
int write_file = 0;
|
|
|
|
int maskset = 0;
|
2007-05-08 07:30:25 +00:00
|
|
|
char *logfile = NULL;
|
2006-07-14 07:24:45 +00:00
|
|
|
int loop = 0;
|
2007-11-15 00:59:14 +00:00
|
|
|
int containerset = 0;
|
2013-07-03 22:09:08 +00:00
|
|
|
char *containerpath = NULL;
|
2007-11-15 00:59:14 +00:00
|
|
|
int cfd = 0;
|
2010-10-27 22:34:42 +00:00
|
|
|
int forking = 0;
|
|
|
|
sigset_t sigset;
|
2006-07-14 07:24:45 +00:00
|
|
|
|
|
|
|
struct msgtemplate msg;
|
|
|
|
|
2010-10-27 22:34:42 +00:00
|
|
|
while (!forking) {
|
|
|
|
c = getopt(argc, argv, "qdiw:r:m:t:p:vlC:c:");
|
2006-07-14 07:24:45 +00:00
|
|
|
if (c < 0)
|
|
|
|
break;
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
switch (c) {
|
|
|
|
case 'd':
|
|
|
|
printf("print delayacct stats ON\n");
|
|
|
|
print_delays = 1;
|
|
|
|
break;
|
[PATCH] io-accounting: add to getdelays
Wire up the IO accounting into getdelays.c.
Usage:
To display I/O stats for each exitting task:
vmm:/home/akpm> ./getdelays -m0,1,2,3 -i -l
cpumask 0 maskset 1
printing IO accounting
listen forever
rm: read=8192, write=0, cancelled_write=0
cvs: read=733184, write=4255744, cancelled_write=4096
make: read=217088, write=0, cancelled_write=0
cc1: read=4263936, write=12288, cancelled_write=0
as: read=811008, write=8192, cancelled_write=0
gcc: read=323584, write=0, cancelled_write=12288
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=4096
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=1011712, write=16384, cancelled_write=0
collect2: read=626688, write=0, cancelled_write=0
gcc: read=204800, write=0, cancelled_write=0
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=8192, write=16384, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
cc1: read=0, write=4096, cancelled_write=0
ld: read=4096, write=12288, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
To display I/O stats for a particular presently-running task:
vmm:/home/akpm> ./getdelays -i -p $(pidof crond)
printing IO accounting
crond: read=61440, write=0, cancelled_write=0
Cc: Jay Lan <jlan@sgi.com>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Chris Sturtivant <csturtiv@sgi.com>
Cc: Tony Ernst <tee@sgi.com>
Cc: Guillaume Thouvenin <guillaume.thouvenin@bull.net>
Cc: David Wright <daw@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 10:19:56 +00:00
|
|
|
case 'i':
|
|
|
|
printf("printing IO accounting\n");
|
|
|
|
print_io_accounting = 1;
|
|
|
|
break;
|
2007-07-16 06:40:48 +00:00
|
|
|
case 'q':
|
|
|
|
printf("printing task/process context switch rates\n");
|
|
|
|
print_task_context_switch_counts = 1;
|
|
|
|
break;
|
2007-11-15 00:59:14 +00:00
|
|
|
case 'C':
|
|
|
|
containerset = 1;
|
2013-07-03 22:09:08 +00:00
|
|
|
containerpath = optarg;
|
2007-11-15 00:59:14 +00:00
|
|
|
break;
|
2006-07-14 07:24:45 +00:00
|
|
|
case 'w':
|
2007-05-08 07:30:25 +00:00
|
|
|
logfile = strdup(optarg);
|
2006-07-14 07:24:45 +00:00
|
|
|
printf("write to file %s\n", logfile);
|
|
|
|
write_file = 1;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
rcvbufsz = atoi(optarg);
|
|
|
|
printf("receive buf size %d\n", rcvbufsz);
|
|
|
|
if (rcvbufsz < 0)
|
|
|
|
err(1, "Invalid rcv buf size\n");
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
strncpy(cpumask, optarg, sizeof(cpumask));
|
2014-06-23 20:22:04 +00:00
|
|
|
cpumask[sizeof(cpumask) - 1] = '\0';
|
2006-07-14 07:24:45 +00:00
|
|
|
maskset = 1;
|
|
|
|
printf("cpumask %s maskset %d\n", cpumask, maskset);
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
tid = atoi(optarg);
|
|
|
|
if (!tid)
|
|
|
|
err(1, "Invalid tgid\n");
|
|
|
|
cmd_type = TASKSTATS_CMD_ATTR_TGID;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
tid = atoi(optarg);
|
|
|
|
if (!tid)
|
|
|
|
err(1, "Invalid pid\n");
|
|
|
|
cmd_type = TASKSTATS_CMD_ATTR_PID;
|
|
|
|
break;
|
2010-10-27 22:34:42 +00:00
|
|
|
case 'c':
|
|
|
|
|
|
|
|
/* Block SIGCHLD for sigwait() later */
|
|
|
|
if (sigemptyset(&sigset) == -1)
|
|
|
|
err(1, "Failed to empty sigset");
|
|
|
|
if (sigaddset(&sigset, SIGCHLD))
|
|
|
|
err(1, "Failed to set sigchld in sigset");
|
|
|
|
sigprocmask(SIG_BLOCK, &sigset, NULL);
|
|
|
|
|
|
|
|
/* fork/exec a child */
|
|
|
|
tid = fork();
|
|
|
|
if (tid < 0)
|
|
|
|
err(1, "Fork failed\n");
|
|
|
|
if (tid == 0)
|
|
|
|
if (execvp(argv[optind - 1],
|
|
|
|
&argv[optind - 1]) < 0)
|
|
|
|
exit(-1);
|
|
|
|
|
|
|
|
/* Set the command type and avoid further processing */
|
|
|
|
cmd_type = TASKSTATS_CMD_ATTR_PID;
|
|
|
|
forking = 1;
|
|
|
|
break;
|
2006-07-14 07:24:45 +00:00
|
|
|
case 'v':
|
|
|
|
printf("debug on\n");
|
|
|
|
dbg = 1;
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
printf("listen forever\n");
|
|
|
|
loop = 1;
|
|
|
|
break;
|
|
|
|
default:
|
2007-05-08 07:30:13 +00:00
|
|
|
usage();
|
2006-07-14 07:24:45 +00:00
|
|
|
exit(-1);
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
if (write_file) {
|
|
|
|
fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC,
|
|
|
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
|
|
|
if (fd == -1) {
|
|
|
|
perror("Cannot open output file\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2015-12-24 10:05:32 +00:00
|
|
|
nl_sd = create_nl_socket(NETLINK_GENERIC);
|
|
|
|
if (nl_sd < 0)
|
2006-07-14 07:24:45 +00:00
|
|
|
err(1, "error creating Netlink socket\n");
|
2006-07-14 07:24:42 +00:00
|
|
|
|
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
mypid = getpid();
|
|
|
|
id = get_family_id(nl_sd);
|
|
|
|
if (!id) {
|
2006-12-10 10:19:55 +00:00
|
|
|
fprintf(stderr, "Error getting family id, errno %d\n", errno);
|
2006-07-14 07:24:45 +00:00
|
|
|
goto err;
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
2006-07-14 07:24:45 +00:00
|
|
|
PRINTF("family id %d\n", id);
|
|
|
|
|
|
|
|
if (maskset) {
|
|
|
|
rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
|
|
|
|
TASKSTATS_CMD_ATTR_REGISTER_CPUMASK,
|
2006-10-01 06:28:54 +00:00
|
|
|
&cpumask, strlen(cpumask) + 1);
|
2006-07-14 07:24:45 +00:00
|
|
|
PRINTF("Sent register cpumask, retval %d\n", rc);
|
|
|
|
if (rc < 0) {
|
2006-12-10 10:19:55 +00:00
|
|
|
fprintf(stderr, "error sending register cpumask\n");
|
2006-07-14 07:24:45 +00:00
|
|
|
goto err;
|
|
|
|
}
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
|
|
|
|
2007-11-15 00:59:14 +00:00
|
|
|
if (tid && containerset) {
|
|
|
|
fprintf(stderr, "Select either -t or -C, not both\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:34:42 +00:00
|
|
|
/*
|
|
|
|
* If we forked a child, wait for it to exit. Cannot use waitpid()
|
|
|
|
* as all the delicious data would be reaped as part of the wait
|
|
|
|
*/
|
|
|
|
if (tid && forking) {
|
|
|
|
int sig_received;
|
|
|
|
sigwait(&sigset, &sig_received);
|
|
|
|
}
|
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
if (tid) {
|
|
|
|
rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
|
|
|
|
cmd_type, &tid, sizeof(__u32));
|
|
|
|
PRINTF("Sent pid/tgid, retval %d\n", rc);
|
|
|
|
if (rc < 0) {
|
2006-12-10 10:19:55 +00:00
|
|
|
fprintf(stderr, "error sending tid/tgid cmd\n");
|
2006-07-14 07:24:45 +00:00
|
|
|
goto done;
|
|
|
|
}
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
|
|
|
|
2007-11-15 00:59:14 +00:00
|
|
|
if (containerset) {
|
|
|
|
cfd = open(containerpath, O_RDONLY);
|
|
|
|
if (cfd < 0) {
|
|
|
|
perror("error opening container file");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
rc = send_cmd(nl_sd, id, mypid, CGROUPSTATS_CMD_GET,
|
|
|
|
CGROUPSTATS_CMD_ATTR_FD, &cfd, sizeof(__u32));
|
|
|
|
if (rc < 0) {
|
|
|
|
perror("error sending cgroupstats command");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
2009-01-15 21:51:00 +00:00
|
|
|
if (!maskset && !tid && !containerset) {
|
|
|
|
usage();
|
|
|
|
goto err;
|
|
|
|
}
|
2007-11-15 00:59:14 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
do {
|
|
|
|
rep_len = recv(nl_sd, &msg, sizeof(msg), 0);
|
|
|
|
PRINTF("received %d bytes\n", rep_len);
|
2006-07-14 07:24:42 +00:00
|
|
|
|
2006-07-14 07:24:45 +00:00
|
|
|
if (rep_len < 0) {
|
2006-12-10 10:19:55 +00:00
|
|
|
fprintf(stderr, "nonfatal reply error: errno %d\n",
|
|
|
|
errno);
|
2006-07-14 07:24:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (msg.n.nlmsg_type == NLMSG_ERROR ||
|
|
|
|
!NLMSG_OK((&msg.n), rep_len)) {
|
2006-10-01 06:28:54 +00:00
|
|
|
struct nlmsgerr *err = NLMSG_DATA(&msg);
|
2006-12-10 10:19:55 +00:00
|
|
|
fprintf(stderr, "fatal reply error, errno %d\n",
|
|
|
|
err->error);
|
2006-07-14 07:24:45 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2008-02-08 12:21:56 +00:00
|
|
|
PRINTF("nlmsghdr size=%zu, nlmsg_len=%d, rep_len=%d\n",
|
2006-07-14 07:24:45 +00:00
|
|
|
sizeof(struct nlmsghdr), msg.n.nlmsg_len, rep_len);
|
|
|
|
|
|
|
|
|
|
|
|
rep_len = GENLMSG_PAYLOAD(&msg.n);
|
|
|
|
|
|
|
|
na = (struct nlattr *) GENLMSG_DATA(&msg);
|
|
|
|
len = 0;
|
|
|
|
while (len < rep_len) {
|
|
|
|
len += NLA_ALIGN(na->nla_len);
|
|
|
|
switch (na->nla_type) {
|
|
|
|
case TASKSTATS_TYPE_AGGR_TGID:
|
|
|
|
/* Fall through */
|
|
|
|
case TASKSTATS_TYPE_AGGR_PID:
|
|
|
|
aggr_len = NLA_PAYLOAD(na->nla_len);
|
|
|
|
len2 = 0;
|
|
|
|
/* For nested attributes, na follows */
|
|
|
|
na = (struct nlattr *) NLA_DATA(na);
|
|
|
|
done = 0;
|
|
|
|
while (len2 < aggr_len) {
|
|
|
|
switch (na->nla_type) {
|
|
|
|
case TASKSTATS_TYPE_PID:
|
|
|
|
rtid = *(int *) NLA_DATA(na);
|
|
|
|
if (print_delays)
|
|
|
|
printf("PID\t%d\n", rtid);
|
|
|
|
break;
|
|
|
|
case TASKSTATS_TYPE_TGID:
|
|
|
|
rtid = *(int *) NLA_DATA(na);
|
|
|
|
if (print_delays)
|
|
|
|
printf("TGID\t%d\n", rtid);
|
|
|
|
break;
|
|
|
|
case TASKSTATS_TYPE_STATS:
|
|
|
|
count++;
|
|
|
|
if (print_delays)
|
|
|
|
print_delayacct((struct taskstats *) NLA_DATA(na));
|
[PATCH] io-accounting: add to getdelays
Wire up the IO accounting into getdelays.c.
Usage:
To display I/O stats for each exitting task:
vmm:/home/akpm> ./getdelays -m0,1,2,3 -i -l
cpumask 0 maskset 1
printing IO accounting
listen forever
rm: read=8192, write=0, cancelled_write=0
cvs: read=733184, write=4255744, cancelled_write=4096
make: read=217088, write=0, cancelled_write=0
cc1: read=4263936, write=12288, cancelled_write=0
as: read=811008, write=8192, cancelled_write=0
gcc: read=323584, write=0, cancelled_write=12288
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=4096
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=1011712, write=16384, cancelled_write=0
collect2: read=626688, write=0, cancelled_write=0
gcc: read=204800, write=0, cancelled_write=0
cc1: read=0, write=8192, cancelled_write=0
as: read=4096, write=4096, cancelled_write=0
gcc: read=16384, write=0, cancelled_write=8192
ld: read=8192, write=16384, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
cc1: read=0, write=4096, cancelled_write=0
ld: read=4096, write=12288, cancelled_write=0
collect2: read=49152, write=0, cancelled_write=0
gcc: read=0, write=0, cancelled_write=0
To display I/O stats for a particular presently-running task:
vmm:/home/akpm> ./getdelays -i -p $(pidof crond)
printing IO accounting
crond: read=61440, write=0, cancelled_write=0
Cc: Jay Lan <jlan@sgi.com>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Chris Sturtivant <csturtiv@sgi.com>
Cc: Tony Ernst <tee@sgi.com>
Cc: Guillaume Thouvenin <guillaume.thouvenin@bull.net>
Cc: David Wright <daw@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 10:19:56 +00:00
|
|
|
if (print_io_accounting)
|
|
|
|
print_ioacct((struct taskstats *) NLA_DATA(na));
|
2007-07-16 06:40:48 +00:00
|
|
|
if (print_task_context_switch_counts)
|
|
|
|
task_context_switch_counts((struct taskstats *) NLA_DATA(na));
|
2006-07-14 07:24:45 +00:00
|
|
|
if (fd) {
|
|
|
|
if (write(fd, NLA_DATA(na), na->nla_len) < 0) {
|
|
|
|
err(1,"write error\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!loop)
|
|
|
|
goto done;
|
|
|
|
break;
|
2016-04-27 15:53:08 +00:00
|
|
|
case TASKSTATS_TYPE_NULL:
|
|
|
|
break;
|
2006-07-14 07:24:45 +00:00
|
|
|
default:
|
2006-12-10 10:19:55 +00:00
|
|
|
fprintf(stderr, "Unknown nested"
|
|
|
|
" nla_type %d\n",
|
|
|
|
na->nla_type);
|
2006-07-14 07:24:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
len2 += NLA_ALIGN(na->nla_len);
|
2016-04-27 15:53:08 +00:00
|
|
|
na = (struct nlattr *)((char *)na +
|
|
|
|
NLA_ALIGN(na->nla_len));
|
2006-07-14 07:24:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-11-15 00:59:14 +00:00
|
|
|
case CGROUPSTATS_TYPE_CGROUP_STATS:
|
|
|
|
print_cgroupstats(NLA_DATA(na));
|
|
|
|
break;
|
2006-07-14 07:24:45 +00:00
|
|
|
default:
|
2006-12-10 10:19:55 +00:00
|
|
|
fprintf(stderr, "Unknown nla_type %d\n",
|
|
|
|
na->nla_type);
|
2010-12-22 01:24:30 +00:00
|
|
|
case TASKSTATS_TYPE_NULL:
|
2006-07-14 07:24:45 +00:00
|
|
|
break;
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
2006-07-14 07:24:45 +00:00
|
|
|
na = (struct nlattr *) (GENLMSG_DATA(&msg) + len);
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
2006-07-14 07:24:45 +00:00
|
|
|
} while (loop);
|
|
|
|
done:
|
|
|
|
if (maskset) {
|
|
|
|
rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
|
|
|
|
TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK,
|
2006-10-01 06:28:54 +00:00
|
|
|
&cpumask, strlen(cpumask) + 1);
|
2006-07-14 07:24:45 +00:00
|
|
|
printf("Sent deregister mask, retval %d\n", rc);
|
|
|
|
if (rc < 0)
|
|
|
|
err(rc, "error sending deregister cpumask\n");
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|
2006-07-14 07:24:45 +00:00
|
|
|
err:
|
|
|
|
close(nl_sd);
|
|
|
|
if (fd)
|
|
|
|
close(fd);
|
2007-11-15 00:59:14 +00:00
|
|
|
if (cfd)
|
|
|
|
close(cfd);
|
2006-07-14 07:24:45 +00:00
|
|
|
return 0;
|
2006-07-14 07:24:42 +00:00
|
|
|
}
|