[patch crash v2 1/2] net -n option renamed to -N
by Vasily Averin
ipcs and mount commands uses -n key as namespace pointer
here we clear the place for similar option in net command
Signed-off-by: Vasily Averin <vvs(a)openvz.org>
---
help.c | 6 +++---
net.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/help.c b/help.c
index 6aa3e20..780966b 100644
--- a/help.c
+++ b/help.c
@@ -6452,7 +6452,7 @@ NULL
char *help_net[] = {
"net",
"network command",
-"[-a] [[-s | -S [-xd]] [-R ref] [pid | taskp]] [-n addr]",
+"[-a] [[-s | -S [-xd]] [-R ref] [pid | taskp]] [-N addr]",
" Display various network related data:\n",
" -a display the ARP cache.",
" -s display open network socket/sock addresses, their family and type,",
@@ -6462,7 +6462,7 @@ char *help_net[] = {
" of both structures.",
" -x override default output format with hexadecimal format.",
" -d override default output format with decimal format.",
-" -n addr translates an IPv4 address expressed as a decimal or hexadecimal",
+" -N addr translates an IPv4 address expressed as a decimal or hexadecimal",
" value into a standard numbers-and-dots notation.",
" -R ref socket or sock address, or file descriptor.",
" pid a process PID.",
@@ -6531,7 +6531,7 @@ char *help_net[] = {
" ...",
" "
" Translate the rcv_saddr from above into dotted-decimal notation:\n",
-" %s> net -n 1041236234",
+" %s> net -N 1041236234",
" 10.1.16.62",
" ",
" From \"foreach\", find all tasks with references to socket c08ea3cc:\n",
diff --git a/net.c b/net.c
index 93491df..cdd424c 100644
--- a/net.c
+++ b/net.c
@@ -304,7 +304,7 @@ net_init(void)
* The net command...
*/
-#define NETOPTS "n:asSR:xd"
+#define NETOPTS "N:asSR:xd"
#define s_FLAG FOREACH_s_FLAG
#define S_FLAG FOREACH_S_FLAG
#define x_FLAG FOREACH_x_FLAG
@@ -351,7 +351,7 @@ cmd_net(void)
dump_arp();
break;
- case 'n':
+ case 'N':
value = stol(optarg, FAULT_ON_ERROR, NULL);
in_addr.s_addr = (in_addr_t)value;
fprintf(fp, "%s\n", inet_ntoa(in_addr));
--
1.9.1
9 years, 11 months
[patch crash v2 0/2]
by Vasily Averin
Dear Dave,
thank you very much for your feedback,
I've prepared new version of patches with following changes:
v2:
- compilation was fixed
- nsproxy_net_ns moved to end of existing offset_table
- -n key behavior was changed, now it can work without pid/task argument:
"net" without arguments shows information about init_net
"net -n" -- gets net namespace reference from current task
"net -n pid|taskp" -- from specified task
- "net -n" example was added into help
- show_net_devices_v3: rollback to using of init_net on kernels without
nsproxy support
- tested, seems works correctly on RHEL6-based OpenVZ kernel
Vasily Averin (2):
net -n option renamed to -N
namespace support for net command
defs.h | 1 +
help.c | 14 +++++++++++---
net.c | 58 ++++++++++++++++++++++++++++++++++++++++++----------------
symbols.c | 2 ++
4 files changed, 56 insertions(+), 19 deletions(-)
--
1.9.1
9 years, 11 months
[RFC patch crash 0/2] namespace support for net command
by Vasily Averin
Dear Dave,
I would like to ask you to take a look and comment this patch set.
I would like to add namespace support to net command.
Currently crash already have ipcs and mount commands that supports namespaces,
however it still had no command to look at list network devices and IP addresses,
related to non-default network namespace. In OpenVZ we have separate network
namespaces for each containers, and we would like to have ability to quickly
get list of netdevices and IPs in container related to crashed process.
Also I believe it should be useful for LXC/Docker containers too.
Mount and ipcs have used -n key to point at according namespace,
however this key was in use in net command. With some doubts I've decided to move
existing -n command to -N, and use -n key as namespace pointer, as in other commands.
Please let me know if it is unacceptable or you have some better ideas.
Vasily Averin (2):
net -n option renamed to -N
namespace support for net command
defs.h | 1 +
help.c | 9 ++++++---
net.c | 48 ++++++++++++++++++++++++++++++++++--------------
symbols.c | 2 ++
4 files changed, 43 insertions(+), 17 deletions(-)
--
1.9.1
9 years, 12 months
[RFC PATCH v2 0/2] Show memory overcommit data in dump_kmeminfo()
by Aaron Tomlin
The first patch changes dump_kmeminfo() to report overcommit information
similar to that displayed under the proc/meminfo file. It may be useful to
indicate memory over commitment abuse, for example with forced vmcores from
system hangs due to shortage of memory. The intended output is as follows:
crash> kmem -i
PAGES TOTAL PERCENTAGE
TOTAL MEM 1965332 7.5 GB ----
FREE 78080 305 MB 3% of TOTAL MEM
USED 1887252 7.2 GB 96% of TOTAL MEM
SHARED 789954 3 GB 40% of TOTAL MEM
BUFFERS 110606 432.1 MB 5% of TOTAL MEM
CACHED 1212645 4.6 GB 61% of TOTAL MEM
SLAB 146563 572.5 MB 7% of TOTAL MEM
TOTAL SWAP 1970175 7.5 GB ----
SWAP USED 5 20 KB 0% of TOTAL SWAP
SWAP FREE 1970170 7.5 GB 99% of TOTAL SWAP
COMMIT LIMIT 2952841 11.3 GB ----
COMMITTED 1150595 4.4 GB 38% of TOTAL LIMIT
The second patch simply removes the mention of dump_zone_page_usage()
availability from kmem's help page.
Tested under 3.16.4-200.fc20.x86_64 only.
Though this should work under RHEL5 (2.6.18) and above.
Aaron Tomlin (2):
kmem: Show memory commitment data in kmem output
help: Remove mention of dump_zone_page_usage()
help.c | 40 ++++++++---------
memory.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 155 insertions(+), 38 deletions(-)
--
1.9.3
9 years, 12 months
[PATCH] crash: Show kernel tainted status in display_sys_stats()
by Aaron Tomlin
The sys command displays essential system information and it is often
shown by default when crash is started in non-silent mode. It might be
considered helpful to report if the kernel is tainted or not when
sys is run without any arguments. This patch makes this change.
The intended output is as follows:
KERNEL: /usr/lib/debug/lib/modules/3.16.4-200.fc20.x86_64/vmlinux
DUMPFILE: /dev/crash
CPUS: 4
DATE: Fri Nov 21 15:02:56 2014
UPTIME: 6 days, 07:41:22
LOAD AVERAGE: 0.29, 0.20, 0.15
TASKS: 397
NODENAME: atomlin.usersys.redhat.com
RELEASE: 3.16.4-200.fc20.x86_64
VERSION: #1 SMP Mon Oct 6 12:57:00 UTC 2014
TAINTED: YES
MACHINE: x86_64 (2693 Mhz)
MEMORY: 7.7 GB
PID: 12172
COMMAND: "crash"
TASK: ffff8801b0aacf00 [THREAD_INFO: ffff8801b1e1c000]
CPU: 0
STATE: TASK_RUNNING (ACTIVE)
If the tainted_mask or tainted symbol does not exist then nothing is
displayed.
Signed-off-by: Aaron Tomlin <atomlin(a)redhat.com>
---
kernel.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel.c b/kernel.c
index 1cb0967..a22ce60 100644
--- a/kernel.c
+++ b/kernel.c
@@ -4691,8 +4691,12 @@ display_sys_stats(void)
{
struct new_utsname *uts;
char buf[BUFSIZE];
+ ulong tainted_mask;
+ int tainted;
ulong mhz;
+ tainted_mask = tainted = 0;
+
uts = &kt->utsname;
// if (!(pc->flags & RUNTIME) && !DUMPFILE() && !GDB_PATCHED())
@@ -4834,6 +4838,13 @@ display_sys_stats(void)
fprintf(fp, " NODENAME: %s\n", uts->nodename);
fprintf(fp, " RELEASE: %s\n", uts->release);
fprintf(fp, " VERSION: %s\n", uts->version);
+ if (kernel_symbol_exists("tainted_mask")) {
+ get_symbol_data("tainted_mask", sizeof(ulong), &tainted_mask);
+ fprintf(fp, " TAINTED: %s\n", tainted_mask ? "YES" : "NO");
+ } else if (kernel_symbol_exists("tainted")) {
+ get_symbol_data("tainted", sizeof(int), &tainted);
+ fprintf(fp, " TAINTED: %s\n", tainted ? "YES" : "NO");
+ }
fprintf(fp, " MACHINE: %s ", uts->machine);
if ((mhz = machdep->processor_speed()))
fprintf(fp, "(%ld Mhz)\n", mhz);
--
1.9.3
9 years, 12 months
[RFC patch crash 2/2] namespace support for net command
by Vasily Averin
now "net -n pid|task" should show list of network devices in specifed network namespace
Signed-off-by: Vasily Averin <vvs(a)openvz.org>
---
defs.h | 1 +
help.c | 5 ++++-
net.c | 46 +++++++++++++++++++++++++++++++++-------------
symbols.c | 2 ++
4 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/defs.h b/defs.h
index dc2d65a..350dcf5 100644
--- a/defs.h
+++ b/defs.h
@@ -1824,6 +1824,7 @@ struct offset_table { /* stash of commonly-used offsets */
long kern_ipc_perm_id;
long kern_ipc_perm_seq;
long nsproxy_ipc_ns;
+ long nsproxy_net_ns;
long shmem_inode_info_swapped;
long shmem_inode_info_vfs_inode;
long shm_file_data_file;
diff --git a/help.c b/help.c
index 780966b..0ba666b 100644
--- a/help.c
+++ b/help.c
@@ -6452,7 +6452,7 @@ NULL
char *help_net[] = {
"net",
"network command",
-"[-a] [[-s | -S [-xd]] [-R ref] [pid | taskp]] [-N addr]",
+"[-a] [[-s | -S [-xd]] [-R ref] [-n] [pid | taskp]] [-N addr]",
" Display various network related data:\n",
" -a display the ARP cache.",
" -s display open network socket/sock addresses, their family and type,",
@@ -6465,6 +6465,9 @@ char *help_net[] = {
" -N addr translates an IPv4 address expressed as a decimal or hexadecimal",
" value into a standard numbers-and-dots notation.",
" -R ref socket or sock address, or file descriptor.",
+" For kernels supporting namespaces, the -n option may be used to",
+" display the network devices with respect to the namespace of a",
+" specified task:\n",
" pid a process PID.",
" taskp a hexadecimal task_struct pointer.\n",
" If no arguments are entered, the list of network devices, names and IP",
diff --git a/net.c b/net.c
index cdd424c..642ac20 100644
--- a/net.c
+++ b/net.c
@@ -64,9 +64,9 @@ struct devinfo {
/* bytes needed for <ip address>:<port> notation */
#define BYTES_IP_TUPLE (BYTES_IP_ADDR + BYTES_PORT_NUM + 1)
-static void show_net_devices(void);
-static void show_net_devices_v2(void);
-static void show_net_devices_v3(void);
+static void show_net_devices(ulong);
+static void show_net_devices_v2(ulong);
+static void show_net_devices_v3(ulong);
static void print_neighbour_q(ulong, int);
static void get_netdev_info(ulong, struct devinfo *);
static void get_device_name(ulong, char *);
@@ -304,7 +304,7 @@ net_init(void)
* The net command...
*/
-#define NETOPTS "N:asSR:xd"
+#define NETOPTS "N:asSR:xdn:"
#define s_FLAG FOREACH_s_FLAG
#define S_FLAG FOREACH_S_FLAG
#define x_FLAG FOREACH_x_FLAG
@@ -326,6 +326,8 @@ cmd_net(void)
int c;
ulong sflag;
ulong value;
+ ulong task;
+ struct task_context *tc = NULL;
struct in_addr in_addr;
struct reference reference, *ref;
@@ -387,6 +389,18 @@ cmd_net(void)
sflag |= d_FLAG;
break;
+ case 'n':
+ switch (str_to_context(optarg, &value, &tc)) {
+ case STR_PID:
+ case STR_TASK:
+ break;
+ case STR_INVALID:
+ error(FATAL, "invalid task or pid value: %s\n",
+ optarg);
+ break;
+ }
+ break;
+
default:
argerrs++;
break;
@@ -399,8 +413,9 @@ cmd_net(void)
if (sflag)
dump_sockets(sflag, ref);
- if (argcnt == 1)
- show_net_devices();
+ task = tc ? tc->task : pid_to_task(0);
+ if ((argcnt == 1) || tc )
+ show_net_devices(task);
}
/*
@@ -408,17 +423,17 @@ cmd_net(void)
*/
static void
-show_net_devices(void)
+show_net_devices(ulong task)
{
ulong next;
long flen;
char buf[BUFSIZE];
if (symbol_exists("dev_base_head")) {
- show_net_devices_v2();
+ show_net_devices_v2(task);
return;
} else if (symbol_exists("init_net")) {
- show_net_devices_v3();
+ show_net_devices_v3(task);
return;
}
@@ -452,7 +467,7 @@ show_net_devices(void)
}
static void
-show_net_devices_v2(void)
+show_net_devices_v2(ulong task)
{
struct list_data list_data, *ld;
char *net_device_buf;
@@ -501,7 +516,7 @@ show_net_devices_v2(void)
}
static void
-show_net_devices_v3(void)
+show_net_devices_v3(ulong task)
{
struct list_data list_data, *ld;
char *net_device_buf;
@@ -523,8 +538,13 @@ show_net_devices_v3(void)
ld = &list_data;
BZERO(ld, sizeof(struct list_data));
ld->flags |= LIST_ALLOCATE;
- ld->start = ld->end =
- symbol_value("init_net") + OFFSET(net_dev_base_head);
+ readmem(task + OFFSET(task_struct_nsproxy), KVADDR, &nsproxy_p,
+ sizeof(ulong), "task_struct.nsproxy", FAULT_ON_ERROR);
+ if (!readmem(nsproxy_p + OFFSET(nsproxy_net_ns), KVADDR, &net_ns_p,
+ sizeof(ulong), "nsproxy.net_ns", RETURN_ON_ERROR|QUIET))
+ error(FATAL, "cannot determine net_namespace location!\n");
+
+ ld->start = ld->end = net_ns_p + OFFSET(net_dev_base_head);
ld->list_head_offset = OFFSET(net_device_dev_list);
ndevcnt = do_list(ld);
diff --git a/symbols.c b/symbols.c
index cebff52..cb642f6 100644
--- a/symbols.c
+++ b/symbols.c
@@ -9295,6 +9295,8 @@ dump_offset_table(char *spec, ulong makestruct)
OFFSET(kern_ipc_perm_seq));
fprintf(fp, " nsproxy_ipc_ns: %ld\n",
OFFSET(nsproxy_ipc_ns));
+ fprintf(fp, " nsproxy_net_ns: %ld\n",
+ OFFSET(nsproxy_net_ns));
fprintf(fp, " shmem_inode_info_swapped: %ld\n",
OFFSET(shmem_inode_info_swapped));
fprintf(fp, " shmem_inode_info_vfs_inode: %ld\n",
--
1.9.1
9 years, 12 months
[RFC patch crash 1/2] net -n option renamed to -N
by Vasily Averin
ipcs and mount commands uses -n key as namespace pointer
clear place for similar option in net command
Signed-off-by: Vasily Averin <vvs(a)openvz.org>
---
help.c | 6 +++---
net.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/help.c b/help.c
index 6aa3e20..780966b 100644
--- a/help.c
+++ b/help.c
@@ -6452,7 +6452,7 @@ NULL
char *help_net[] = {
"net",
"network command",
-"[-a] [[-s | -S [-xd]] [-R ref] [pid | taskp]] [-n addr]",
+"[-a] [[-s | -S [-xd]] [-R ref] [pid | taskp]] [-N addr]",
" Display various network related data:\n",
" -a display the ARP cache.",
" -s display open network socket/sock addresses, their family and type,",
@@ -6462,7 +6462,7 @@ char *help_net[] = {
" of both structures.",
" -x override default output format with hexadecimal format.",
" -d override default output format with decimal format.",
-" -n addr translates an IPv4 address expressed as a decimal or hexadecimal",
+" -N addr translates an IPv4 address expressed as a decimal or hexadecimal",
" value into a standard numbers-and-dots notation.",
" -R ref socket or sock address, or file descriptor.",
" pid a process PID.",
@@ -6531,7 +6531,7 @@ char *help_net[] = {
" ...",
" "
" Translate the rcv_saddr from above into dotted-decimal notation:\n",
-" %s> net -n 1041236234",
+" %s> net -N 1041236234",
" 10.1.16.62",
" ",
" From \"foreach\", find all tasks with references to socket c08ea3cc:\n",
diff --git a/net.c b/net.c
index 93491df..cdd424c 100644
--- a/net.c
+++ b/net.c
@@ -304,7 +304,7 @@ net_init(void)
* The net command...
*/
-#define NETOPTS "n:asSR:xd"
+#define NETOPTS "N:asSR:xd"
#define s_FLAG FOREACH_s_FLAG
#define S_FLAG FOREACH_S_FLAG
#define x_FLAG FOREACH_x_FLAG
@@ -351,7 +351,7 @@ cmd_net(void)
dump_arp();
break;
- case 'n':
+ case 'N':
value = stol(optarg, FAULT_ON_ERROR, NULL);
in_addr.s_addr = (in_addr_t)value;
fprintf(fp, "%s\n", inet_ntoa(in_addr));
--
1.9.1
9 years, 12 months
(no subject)
by Karlsson, Jan
Hi Dave,
I have been looking at the trace extension that you deliver together with crash. In the kernel I look at the trace_array is defined as:
struct trace_array {
struct list_head list;
char *name;
struct trace_buffer trace_buffer;
#ifdef CONFIG_TRACER_MAX_TRACE
/*
*/
struct trace_buffer max_buffer;
bool allocated_snapshot;
#endif
....
However trace.c assumes that if the trace_buffer field exists then the max_buffer field also exists, which is not true. So if CONFIG_TRACER_MAX_TRACE is not defined in the kernel then the trace extension will fail when it is loaded with a message that the max_buffer field does not exist.
To fix this then the statements:
init_offset(trace_array, max_buffer);
in the function init_offsets and
ftrace_int_max_tr_trace();
in function ftrace_init should not be executed if the max_buffer field is not present. I have tested this and it works for me.
Jan
Jan Karlsson
Senior Software Engineer
System Assurance
Sony Mobile Communications
Tel: +46 703 062 174
jan.karlsson(a)sonymobile.com<mailto:Firstname.Lastname@sonymobile.com>
sonymobile.com<http://sonymobile.com/>
[cid:image001.gif@01D00E16.22AD0C60]
9 years, 12 months