[ANNOUNCE] crash version 6.1.1 is available
by Dave Anderson
Download from: http://people.redhat.com/anderson
Changelog:
- Fixes for the ARM "vtop" command display of kernel unity-mapped
virtual addresses. Without the patch, the PGD, PMD values may be
incorrect, and the PAGE value is always incorrectly calculated.
(paawan1982(a)yahoo.com, rabin(a)rab.in)
- Fix for Linux 2.6.34 and later kernels that are configured with
CONFIG_SLUB, but not configured with CONFIG_IKCONFIG, to be able
to determine the kernel's CONFIG_NR_CPUS value. Without the patch,
if the actual number of cpus is larger than the crash utility's
per-architecture NR_CPUS maximum value, then the cpus beyond the
NR_CPUS limit would not be accounted for.
(anderson(a)redhat.com)
- Increment the X86_64 NR_CPUS maximum value from 4096 to 5120.
(anderson(a)redhat.com)
- Try to determine whether the kernel is running as a virtual machine
by using any available kernel-specific data or by dumpfile type.
The results of the hypervisor type search will be stored in the
internal kernel_table data structure, and if a hypervisor type can
be determined, its name will be displayed by the "mach" command. The
result of the hypervisor determination, successful or otherwise, may
be viewed during session initialization if the -d<number> command
line option is invoked, or during runtime via the "help -k" option.
Only applicable to the X86, X86_64 and IA64 architectures.
(anderson(a)redhat.com)
- Allow the "ps command" and "foreach name" command options to contain
more than the kernel's maximum of 15 characters that are stored in
each task's task_struct.comm[] array. Without the patch, the two
string arguments were required to be the possibly-truncated command
name string in order to match.
(anderson(a)redhat.com)
- Enhancement to the "ps" command to allow any of the "command"
arguments to be POSIX extended regular expressions. The expression
string must be encompassed by "'" characters, and will be matched
against the names of all tasks.
(anderson(a)redhat.com)
- Add support for 2GB pages in the S390X virtual-to-physical address
translation function. Required for the new IBM zEC12 Mainframe.
(holzheu(a)linux.vnet.ibm.com)
- Initial preparation for support of the ARM64 architecture.
(anderson(a)redhat.com)
- Fix for the "log" command if a kernel message contains either a
'\n' or a '\t'. Without the patch, the two characters are replaced
with a '.', and the message continues. With the patch applied,
the characters are printed, and if it is a '\n', spaces are inserted
after the linefeed so that the subsequent characters in the message
line up appropriately under the preceding line.
(holzheu(a)linux.vnet.ibm.com, anderson(a)redhat.com)
- Fix for the "kmem -[sS]" options on kernels that configured with both
CONFIG_SLUB and CONFIG_NODES_SHIFT, and that are running on hardware
that generates NUMA node ids that are not numbered consecutively.
Without the patch, both command options fail with the error message
"kmem: invalid kernel virtual address: 8 type: kmem_cache_node
nr_partial".
(anderson(a)redhat.com)
- Fix for the "trace.so" extension module's "trace show" command.
Without the patch, the output showing each trace point is shown
with two hexadecimal virtual addresses instead of displaying them
symbolically using the format "<function> <-- <function>".
(qiaonuohan(a)cn.fujitsu.com)
- Fixes for handling incomplete/invalid ELF or compressed kdump
vmcores whose per-cpu NT_PRSTATUS notes are missing. For example,
this has been seen to happen when kexec/kdump incorrectly recognizes
a Xen DomU kernel as a Xen Dom0 kernel. Without the patch, possible
ramifications would be a NULL pointer dereference during session
intialization when searching for the panic task, or during the "bt"
command on an active task.
(d.hatayama(a)jp.fujitsu.com)
- Implemented a new "runq -g" option that displays CFS runqueue tasks
hierarchically by task_group. Tasks in throttled groups are also
displayed. The "runq" command with no option will no longer display
task_group data for the RT queue.
(zhangyanfei(a)cn.fujitsu.com)
- Patchset for Xen support up to version 4.2:
(1) Fix page tables caching issues,
(2) Use init_tss array or per_cpu__init_tss,
(3) Use per_cpu__crash_notes or crash_notes array,
(4) Try hard to get max_cpus value,
(5) Use cpu_present_map instead of cpu_online_map.
(daniel.kiper(a)oracle.com)
- Fix for the S390X virtual-to-physical address translation to allow
the HW Change-bit override bit (0x100) to be used in page table
entries.
(holzheu(a)linux.vnet.ibm.com)
- Fix for a rarely-seen circumstance in which a kdump ELF vmcore of
a Xen dom0 kernel gets incorrectly identified as a old-style netdump
ELF vmcore. This has only been seen after the original kdump ELF
vmcore was transformed via "makedumpfile -d1". Without the patch,
the crash session fails during initialization with the messages
"crash: invalid size request: 0 type: xen kdump p2m mfn page",
followed by "crash: cannot read xen kdump p2m mfn page". If run
against the Xen hypervisor, the session fails during initialization
with the error message "crash: read error: kernel virtual address:
<address> type: crashing_cpu".
(anderson(a)redhat.com)
11 years, 9 months
[PATCH] s390x: Allow HW Change-bit override for page table entries
by Michael Holzheu
Hi Dave,
s390x: Allow HW Change-bit override for page table entries
The HW Change-bit override (0x100) is used now for s390x. This patch allows
page table entries that have set this bit.
Signed-off-by: Michael Holzheu <holzheu(a)linux.vnet.ibm.com>
---
s390x.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
--- a/s390x.c
+++ b/s390x.c
@@ -600,11 +600,10 @@ static ulong _kl_pg_table_deref_s390x(ul
readmem(table + offset, KVADDR, &entry, sizeof(entry), "entry",
FAULT_ON_ERROR);
/*
- * Return zero if the page table entry has any of the reserved bits
- * set (0x900) or the invalid bit (0x400) is set and it is not a
- * swap entry.
+ * Return zero if the page table entry has the reserved (0x800) or
+ * the invalid (0x400) bit set and it is not a swap entry.
*/
- if ((entry & 0xd00ULL) && !swap_entry(entry))
+ if ((entry & 0xc00ULL) && !swap_entry(entry))
return 0;
/* Page table entry is valid and well formed. */
return entry;
11 years, 9 months
Re: [Crash-utility] Crash-utility Digest, Vol 86, Issue 13
by 俞永明
Hello, Dave,
To begin with, I am sincerely grateful for your detailed suggestions.
I have read the suggetions you gave and finished modifying the relative
parts. The following will demonstrate the modifications.
The first is when it comes to older kernels that do not have cgroups, it
now offers justification of whether the kernel have cgroups and output
information when the kernel do not contain cgroup.
Secondly, you mentioned the cgroups "unabled" in the previous mail,
considerring those inactive cgroups whose root(cgroupfs_root) is not
linked by the active root list, I prefer to display something when there
are no active cgroups other than output the inactive cgroups.
If the inactive cgroups' information is needy, I need to rethink and
find another way to get target data structure.
Thirdly, the unnecessary -h option was deleted and help information was
corrected according to your suggestions.
Lastly, the changed "lscgroup" command add the address of cgroup when
displaying cgroups. For the reason that address length is fixed on a
certain system, the first column of output is used to display the address.
You can check the modifications in the attachment by the same operation
as said in last mail.
Lots of thanks.
Yongming Yu
crash-utility-request(a)redhat.com 写道:
> Send Crash-utility mailing list submissions to
> crash-utility(a)redhat.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://www.redhat.com/mailman/listinfo/crash-utility
> or, via email, send a message with subject or body 'help' to
> crash-utility-request(a)redhat.com
>
> You can reach the person managing the list at
> crash-utility-owner(a)redhat.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Crash-utility digest..."
>
>
> Today's Topics:
>
> 1. Re: [Crash] [PATCH] add a new command: lscgroup (Dave Anderson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 9 Nov 2012 14:52:51 -0500 (EST)
> From: Dave Anderson <anderson(a)redhat.com>
> To: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] [Crash] [PATCH] add a new command:
> lscgroup
> Message-ID:
> <1824583457.29845585.1352490771952.JavaMail.root(a)redhat.com>
> Content-Type: text/plain; charset=utf-8
>
>
>
> ----- Original Message -----
>> Hello Dave,
>>
>> I have been working on a new command named lscgroup to
>> list cgroups' information and finished it recently.
>>
>> This command displays all the cgroups' information or the
>> appointed cgroups' information relatively according to user's
>> input. The following shows the two types of output.
>>
>> 1.Display all the cgroups' information of the system.
>> crash> lscgroup
>> blkio:/
>> blkio:/libvirt
>> blkio:/libvirt/lxc
>> blkio:/libvirt/qemu
>> net_cls:/
>> ...
>> ...
>> cpuset:/
>> cpuset:/libvirt
>> cpuset:/libvirt/lxc
>> cpuset:/libvirt/qemu
>>
>>
>> 2.Display the appointed cgroups' information.
>> crash> lscgroup memory:/ cpuset:/libvirt
>> memory:/
>> memory:/libvirt
>> memory:/libvirt/lxc
>> memory:/libvirt/qemu
>> cpuset:/libvirt
>> cpuset:/libvirt/lxc
>> cpuset:/libvirt/qemu
>>
>> To see more details, please refer to the help information and the patch.
>>
>> To build the module from the top-level crash-<version> directory,
>> enter:
>> $ cp <path-to>/lscgroup.c extensions
>> $ make extensions
>
> Thanks for diving into this kernel subsystem. Given the emergence
> of cgroups, this command could ultimately be considered as a new
> built-in command.
>
> However, that being said, it does need some additional work.
>
> First, for older kernels that don't have cgroups, there should be a
> protection mechanism to prevent this from happening:
>
> crash> sys | grep RELEASE
> RELEASE: 2.6.18-146.el5
> crash> lscgroup
>
> lscgroup: invalid structure member offset: cgroupfs_root_root_list
> FILE: lscgroup.c LINE: 503 FUNCTION: cgroup_list_cgroups()
>
> [/usr/bin/crash] error trace: 4611e1 => 7f3b8f3a19d7 => 7f3b8f3a14e6 => 50b701
>
> 50b701: OFFSET_verify+161
> 4611e1: exec_command+801
>
> lscgroup: invalid structure member offset: cgroupfs_root_root_list
> FILE: lscgroup.c LINE: 503 FUNCTION: cgroup_list_cgroups()
>
> crash>
>
> You should check for the existence of a kernel variable or structure definition,
> and if they don't exist, call command_not_supported().
>
> Secondly, if I am not mistaken, your command only shows "enabled" cgroups?
> So for example, on this RHEL6 system, the command quietly does nothing:
>
> crash> sys | grep RELEASE
> RELEASE: 2.6.32-15.el6.x86_64
> crash> lscgroup
> crash>
>
> Is that the case? I wonder if you should also show cgroups that are
> not enabled, i.e., like /proc/cgroups does? Or at a minimum, it should
> show display something like "(no cgroups enabled)" instead of just
> showing nothing at all.
>
> Thirdly, your help page shows a "-h" option, which is unnecessary:
>
> crash> help lscgroup
>
> NAME
> lscgroup - list all cgroups
>
> SYNOPSIS
> lscgroup lscgroup [<controllers>:<path>] [...][-h]
>
> ...
>
> because it doesn't do anything other than show the SYNOPSIS line
> from the "help lscgroup" output:
>
> crash> lscgroup -h
> Usage:
> lscgroup lscgroup [<controllers>:<path>] [...][-h]
> Enter "help lscgroup" for details.
> crash>
>
> And you should change the third line in help_lscgroup[] from:
>
> char *help_lscgroup[] = {
> "lscgroup",
> "list all cgroups",
> "lscgroup [<controllers>:<path>] [...][-h]",
>
> to:
>
> "[<controllers>:<path>] [...][-h]",
>
> so that "lscgroup" is not printed twice in the "help lscgroup" and
> the "Usage:" output.
>
>
> And lastly, and most importantly, is what the command
> does *not* show.
>
> Consider that most crash commands that delve into kernel
> subsystems typically show information intermingled with
> key data structure addresses. So if there is a bug associated
> with a kernel subsystem, the data structure addresses displayed
> by a crash command can be used as a starting point for debugging
> purposes.
>
> So for example, if there was a bug associated with cgroups, your
> command's output only shows the name strings, but there's nothing
> else to "work with" for debugging. Wouldn't it be more helpful to
> at least display the cgroup and/or the cgroupfs_root addresses?
> Then there would be useful data structure addresses to start with.
>
> Thanks,
> Dave
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
> End of Crash-utility Digest, Vol 86, Issue 13
> *********************************************
>
>
--
--------------------------------------------------
Yu Yongming
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.
(FNST)No. 6 Wenzhu Road, Nanjing, 210012, China
EMail:yuym.fnst(a)cn.fujitsu.com
Regards__
--------------------------------------------------
/* lscgroup.c - list cgroups
*
* Copyright (C) 2012 FUJITSU LIMITED
* Author: Yu Yongming <yuym.fnst(a)cn.fujitsu.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "defs.h"
#define PATHNAME_MAX 200
#define ROOT_MAX 64
#define CG_CONTROLLER_MAX 20
#define CG_HIER_MAX 20
#define FL_LIST 0x1
#define CGROUP_MEMBER_OFFSET_INIT(X,Y,Z) (cgroup_offset_table.X=MEMBER_OFFSET(Y,Z))
#define CGROUP_OFFSET(X) (OFFSET_verify(cgroup_offset_table.X, (char *)__FUNCTION__, __FILE__, __LINE__, #X))
/*
*struct declaration
*/
struct cgroup_offset_table {
long cgroupfs_root_root_list;
long cgroupfs_root_top_cgroup;
long cgroupfs_root_subsys_list;
long cgroupfs_root_actual_subsys_bits;
long cgroupfs_root_name;
long cgroup_sibling;
long cgroup_children;
long cgroup_dentry;
long cgroup_subsys_name;
long cgroup_subsys_sibling;
};
struct cgroup_group_spec {
char path[PATHNAME_MAX];
char *controllers[CG_CONTROLLER_MAX];
};
/*
*function declaration
*/
int _init(void);
int _fini(void);
void cmd_lscgroup(void);
char *help_lscgroup[];
static void cgroup_init(void);
static void get_controller_name(ulong);
static void get_cgroup_name(ulong, char *);
static void parse_top_cgroup(ulong, char *);
static void print_all_cgroups(void);
static int in_cgroupfs_root(char *, struct cgroup_group_spec *);
static ulong locate_top_cgroup(struct cgroup_group_spec *);
static void parse_path(char *, char **);
static ulong locate_cgroup(ulong, ulong, char *);
static void standarlize_path(char *);
static void cgroup_elem_cgroup(struct cgroup_group_spec *);
static void cgroup_list_cgroups(char *, struct cgroup_group_spec **, int);
static int parse_cgroup_spec(struct cgroup_group_spec **, char *);
static void cgroup_free_group_spec(struct cgroup_group_spec *);
/*
* global data
*/
static char controller_name[PATHNAME_MAX];
static struct command_table_entry command_table[] = {
{"lscgroup", cmd_lscgroup, help_lscgroup, 0},
{NULL},
};
static struct cgroup_offset_table cgroup_offset_table = { 0 };
char *help_lscgroup[] = {
"lscgroup",
"list all cgroups",
"[<controllers>:<path>] [...]",
" The command list all/chosen cgroups.",
" <controllers>:<path> defines control groups which subgroups will be shown.",
" If this parameter is not used then the command list all cgroups which are",
" present.",
"\nEXAMPLE",
" display chosen cgroups:\n",
" %s>lscgroup cpuset:/libvirt",
" cpuset:/libvirt",
" cpuset:/libvirt/lxc",
" cpuset:/libvirt/qemu",
" ",
" display all cgroups:\n",
" %s>lscgroup",
" blkio:/",
" blkio:/libvirt",
" blkio:/libvirt/lxc",
" blkio:/libvirt/qemu",
" net_cls:/",
" freezer:/",
" freezer:/libvirt",
" freezer:/libvirt/lxc",
" freezer:/libvirt/qemu",
" devices:/",
" devices:/libvirt",
" devices:/libvirt/lxc",
" devices:/libvirt/qemu",
" memory:/",
" memory:/libvirt",
" memory:/libvirt/lxc",
" memory:/libvirt/qemu",
" cpuacct:/ ",
" cpuacct:/libvirt",
" cpuacct:/libvirt/lxc",
" cpuacct:/libvirt/qemu",
" cpu:/",
" cpu:/libvirt",
" cpu:/libvirt/lxc",
" cpu:/libvirt/qemu",
" cpuset:/",
" cpuset:/libvirt",
" cpuset:/libvirt/lxc",
" cpuset:/libvirt/qemu",
NULL
};
int
_init(void)
{
register_extension(command_table);
return 1;
}
int
_fini(void)
{
return 1;
}
static void
cgroup_init(void)
{
CGROUP_MEMBER_OFFSET_INIT(cgroupfs_root_root_list, "cgroupfs_root",
"root_list");
CGROUP_MEMBER_OFFSET_INIT(cgroupfs_root_top_cgroup, "cgroupfs_root",
"top_cgroup");
CGROUP_MEMBER_OFFSET_INIT(cgroupfs_root_subsys_list, "cgroupfs_root",
"subsys_list");
CGROUP_MEMBER_OFFSET_INIT(cgroupfs_root_actual_subsys_bits,
"cgroupfs_root", "actual_subsys_bits");
CGROUP_MEMBER_OFFSET_INIT(cgroupfs_root_name, "cgroupfs_root",
"name");
CGROUP_MEMBER_OFFSET_INIT(cgroup_sibling, "cgroup", "sibling");
CGROUP_MEMBER_OFFSET_INIT(cgroup_children, "cgroup", "children");
CGROUP_MEMBER_OFFSET_INIT(cgroup_dentry, "cgroup", "dentry");
CGROUP_MEMBER_OFFSET_INIT(cgroup_subsys_name, "cgroup_subsys", "name");
CGROUP_MEMBER_OFFSET_INIT(cgroup_subsys_sibling, "cgroup_subsys",
"sibling");
}
static void
get_controller_name(ulong cgroupfs_root)
{
char name[PATHNAME_MAX];
ulong subsys, next, subsys_list, name_buf, name_addr;
int len;
BZERO(name, PATHNAME_MAX);
BZERO(controller_name, PATHNAME_MAX);
readmem(cgroupfs_root + CGROUP_OFFSET(cgroupfs_root_actual_subsys_bits),
KVADDR, &subsys, sizeof(ulong), "cgroupfs_root_actual_subsys",
FAULT_ON_ERROR);
if(subsys == 0) {
readmem(cgroupfs_root + CGROUP_OFFSET(cgroupfs_root_name),
KVADDR, &name, ROOT_MAX, "cgroupfs_root_name",
FAULT_ON_ERROR);
strcat(controller_name, name);
return ;
}
subsys_list = cgroupfs_root + CGROUP_OFFSET(cgroupfs_root_subsys_list);
readmem(subsys_list, KVADDR, &next, sizeof(ulong),
"cgroupfs_root_subsys_list", FAULT_ON_ERROR);
do {
name_buf = next - CGROUP_OFFSET(cgroup_subsys_sibling)
+ CGROUP_OFFSET(cgroup_subsys_name);
readmem(name_buf, KVADDR, &name_addr, sizeof(ulong),
"cgroup_subsys_name", FAULT_ON_ERROR);
readmem(name_addr, KVADDR, name, sizeof(name),
"char* name", FAULT_ON_ERROR);
strcat(controller_name, name);
strcat(controller_name, ",");
readmem(next, KVADDR, &next, sizeof(ulong),
"list_head", FAULT_ON_ERROR);
} while(next != subsys_list);
len = strlen(controller_name);
controller_name[len-1] = '\0';
}
static void
get_cgroup_name(ulong cgroup, char *name)
{
ulong dentry, name_addr;
char *dentry_buf;
int len;
readmem(cgroup + CGROUP_OFFSET(cgroup_dentry), KVADDR,
&dentry, sizeof(ulong), "cgroup dentry",
FAULT_ON_ERROR);
dentry_buf = GETBUF(SIZE(dentry));
readmem(dentry, KVADDR, dentry_buf, SIZE(dentry),
"dentry", FAULT_ON_ERROR);
len = UINT(dentry_buf + OFFSET(dentry_d_name) + OFFSET(qstr_len));
name_addr = ULONG(dentry_buf + OFFSET(dentry_d_name) + OFFSET(qstr_name));
readmem(name_addr, KVADDR, name, len, "qstr name", FAULT_ON_ERROR);
FREEBUF(dentry_buf);
}
static void
parse_top_cgroup(ulong top_cgroup, char *path)
{
int len;
char tmp_buf[PATHNAME_MAX];
ulong list_head[2], next, child;
BZERO(tmp_buf, PATHNAME_MAX);
get_cgroup_name(top_cgroup, tmp_buf);
if (strlen(path) > 1)
strncat(path, "/", 1);
strncat(path, tmp_buf, strlen(tmp_buf));
fprintf(fp, "%lx\t%s:%s\n", top_cgroup, controller_name, path);
child = top_cgroup + CGROUP_OFFSET(cgroup_children);
readmem(child, KVADDR, list_head, sizeof(ulong) * 2,
"cgroup children", FAULT_ON_ERROR);
if ((list_head[0] == child) && (list_head[1] == child))
return;
next = list_head[0];
while (next != child) {
top_cgroup = next - CGROUP_OFFSET(cgroup_sibling);
readmem(top_cgroup + CGROUP_OFFSET(cgroup_sibling) +
OFFSET(list_head_next), KVADDR, &next, sizeof(ulong),
"cgroup siblings", FAULT_ON_ERROR);
len = strlen(path);
parse_top_cgroup(top_cgroup, path);
path[len] = '\0';
}
}
static void
print_all_cgroups(void)
{
struct syment *roots;
ulong top_cgroup;
ulong list_head[2], next, cgroupfs_root;;
char path_name[PATHNAME_MAX];
char buf1[BUFSIZE];
BZERO(path_name, PATHNAME_MAX);
if (!(roots = symbol_search("roots")))
error(FATAL, "roots symbol does not exist?\n");
readmem(roots->value, KVADDR, list_head, sizeof(ulong) * 2,
"list_head", FAULT_ON_ERROR);
if ((list_head[0] == roots->value) && (list_head[1] == roots->value)) {
fprintf(fp, "no active cgroup hierarchy in the kernel.");
return;
}
//fprintf(fp, " CGROUP_ADDR\t\t <CONTROLLER>:<PATH>\n");
fprintf(fp, "%s\t <CONTROLLER>:<PATH>\n",
mkstring(buf1, VADDR_PRLEN, CENTER, "CGROUP_ADDR"));
next = list_head[0];
while (next != roots->value) {
cgroupfs_root = next - CGROUP_OFFSET(cgroupfs_root_root_list);
get_controller_name(cgroupfs_root);
top_cgroup = cgroupfs_root +
CGROUP_OFFSET(cgroupfs_root_top_cgroup);
/* print infomation of cgroup and subcgroup */
parse_top_cgroup(top_cgroup, path_name);
readmem(next + OFFSET(list_head_next), KVADDR, &next,
sizeof(ulong), "list_head next", FAULT_ON_ERROR);
BZERO(path_name, PATHNAME_MAX);
BZERO(controller_name, PATHNAME_MAX);
}
}
static int
in_cgroupfs_root(char *tmp_name, struct cgroup_group_spec *elem)
{
char *name;
int i = 0;
name = strtok(tmp_name, ",");
while(name != NULL) {
while(elem->controllers[i] != NULL && i < CG_CONTROLLER_MAX) {
if(STREQ(name, elem->controllers[i]))
return 1;
i++;
}
name = strtok(NULL, ",");
i = 0;
}
return 0;
}
static ulong
locate_top_cgroup(struct cgroup_group_spec *elem)
{
struct syment *roots;
ulong top_cgroup;
ulong list_head[2], next, cgroupfs_root;
char tmp_name[PATHNAME_MAX];
if (!(roots = symbol_search("roots")))
error(FATAL, "roots symbol does not exist?");
readmem(roots->value, KVADDR, list_head, sizeof(ulong)*2,
"list_head", FAULT_ON_ERROR);
if ((list_head[0] == roots->value) && (list_head[1] == roots->value))
return 0;
next = list_head[0];
while (next != roots->value) {
/* begin from first root */
cgroupfs_root = next - CGROUP_OFFSET(cgroupfs_root_root_list);
get_controller_name(cgroupfs_root);
strcpy(tmp_name, controller_name);
if (in_cgroupfs_root(tmp_name, elem)) {
top_cgroup = cgroupfs_root +
CGROUP_OFFSET(cgroupfs_root_top_cgroup);
return top_cgroup;
}
readmem(next + OFFSET(list_head_next), KVADDR, &next,
sizeof(ulong), "list_head", FAULT_ON_ERROR);
BZERO(controller_name, PATHNAME_MAX);
}
return 0;
}
/*
* function parse_path and extracts the input path before the first '/' as
* relatively path which will be used to compare with path name of cgroup.
* In addition, it ignores the unnecessary '/' in the path
*/
static void
parse_path(char *path, char **elem_path)
{
char *token;
token = *elem_path;
if (token[0] == '/') {
*path++ = *token++;
} else {
while (*token) {
if (*token == '/' && *(token + 1) == '/') {
token++;
} else if (*token == '/' && *(token + 1) != '/') {
token++;
break;
} else {
*path++ = *token++;
}
}
}
*elem_path = token;
*path = '\0';
}
static ulong
locate_cgroup(ulong current, ulong prev_addr, char *elem_path)
{
char tmp_buf[PATHNAME_MAX];
char path[PATHNAME_MAX];
char *tmp_path = elem_path;
ulong child, sibling, child_offset, sibling_offset;
if (*elem_path == '\0')
return prev_addr;
BZERO(tmp_buf, PATHNAME_MAX);
get_cgroup_name(current, tmp_buf);
parse_path(path, &elem_path);
readmem(current + CGROUP_OFFSET(cgroup_children), KVADDR, &child,
sizeof(ulong), "cgroup children", FAULT_ON_ERROR);
readmem(current + CGROUP_OFFSET(cgroup_sibling), KVADDR, &sibling,
sizeof(ulong), "cgroup sibling", FAULT_ON_ERROR);
child_offset = CGROUP_OFFSET(cgroup_children);
sibling_offset = CGROUP_OFFSET(cgroup_sibling);
/* parse the children if temp=path_name, do change elem_path */
if (STREQ(tmp_buf, path)) {
if ((child - child_offset != current))
return locate_cgroup(child - sibling_offset,
current, elem_path);
else if (*elem_path == '\0')
return current;
} else {
/* parse the sibling if temp !=path_name, do not chage elem_path */
if (((sibling - child_offset) != prev_addr) &&
((sibling - sibling_offset) != current)) {
elem_path = tmp_path;
return locate_cgroup(sibling - sibling_offset,
prev_addr, elem_path);
}
}
return 0;
}
/*
* make the input path begin with character '/' and end without character '/'
* to cope with the situation that the input path may be like "/xxxxx",
* "xxxxx", "xxxxx/", or "/xxxxx/"
*/
static void
standarlize_path(char *path)
{
int len;
len = strlen(path) - 1;
if (path[len] == '/')
path[len] = '\0';
if (path[0] != '/') {
len = strlen(path);
path[len + 1] = '\0';
while (len) {
path[len] = path[len - 1];
len--;
}
path[0] = '/';
}
}
static void
mani_path(char *path)
{
int len;
standarlize_path(path);
if (STREQ(path, "/")) {
*path = '\0';
return ;
}
len = strlen(path);
while (path[len] != '/') {
path[len] = '\0';
len--;
}
path[len] = '\0';
path[0] = '/';
}
static void
cgroup_elem_cgroup(struct cgroup_group_spec *list_elem)
{
ulong top_cgroup;
ulong cgroup;
char path_name[PATHNAME_MAX];
char buf1[BUFSIZE];
top_cgroup = locate_top_cgroup(list_elem);
if (top_cgroup == 0) {
fprintf(fp, "cannot find top cgroup, check the input.\n");
return ;
}
strcpy(path_name, list_elem->path);
standarlize_path(path_name);
cgroup = locate_cgroup(top_cgroup, top_cgroup, path_name);
if (cgroup == 0) {
fprintf(fp, "can not find cgroup %s, check the input.\n",
list_elem->path);
return ;
}
mani_path(list_elem->path);
fprintf(fp, "%s\t <CONTROLLER>:<PATH>\n",
mkstring(buf1, VADDR_PRLEN, CENTER, "CGROUP_ADDR"));
parse_top_cgroup(cgroup, list_elem->path);
}
static void
cgroup_list_cgroups(char *tname, struct cgroup_group_spec *cgroup_list[],
int flags)
{
int i;
i = 0;
cgroup_init();
if(cgroup_offset_table.cgroupfs_root_root_list == -1) {
fprintf(fp, "cgroup does not exist, check kernel version.");
return ;
}
if ((flags & FL_LIST) == 0) {
/* list all the cgroups */
print_all_cgroups();
} else {
/* list the specified cgroups */
while ((cgroup_list[i]->path != NULL)) {
cgroup_elem_cgroup(cgroup_list[i]);
i++;
}
}
}
static int
parse_cgroup_spec(struct cgroup_group_spec **list, char *optarg)
{
struct cgroup_group_spec *ptr;
int i, j;
char *controller, *path, *temp;
ptr = *list;
for (i = 0; i < CG_HIER_MAX; i++, ptr++) {
if (!list[i])
break;
}
if (i == CG_HIER_MAX) {
fprintf(fp, "Max allowed hierarchies %d reached\n",
CG_HIER_MAX);
return -1;
}
controller = strtok(optarg, ":");
if (!controller)
return -1;
path = strtok(NULL, ":");
if (!path)
return -1;
list[i] = (struct cgroup_group_spec *)GETBUF(sizeof(**list));
j = 0;
do {
if (j == 0)
temp = strtok(controller, ",");
else
temp = strtok(NULL, ",");
if (temp) {
list[i]->controllers[j] = strdup(temp);
if (!list[i]->controllers[j]) {
FREEBUF(list[i]);
fprintf(fp, "%s\n", strerror(errno));
return -1;
}
}
j++;
} while (temp && (j < (CG_CONTROLLER_MAX - 1)));
strncpy(list[i]->path, path, strlen(path));
return 0;
}
static void
cgroup_free_group_spec(struct cgroup_group_spec *elem)
{
int i;
if (!elem)
return;
for (i = 0; i < CG_CONTROLLER_MAX; i++) {
if (elem->controllers[i])
free(elem->controllers[i]);
}
FREEBUF(elem);
}
void
cmd_lscgroup(void)
{
int c, i, ret, flags;
struct cgroup_group_spec *cgroup_list[CG_HIER_MAX];
ret = flags = 0;
while ((c = getopt(argcnt, args, "")) != EOF) {
switch(c) {
default:
cmd_usage(pc->curcmd, SYNOPSIS);
return ;
}
}
if (argerrs)
cmd_usage(pc->curcmd, SYNOPSIS);
BZERO(cgroup_list, sizeof(cgroup_list));
if (optind < argcnt)
flags |= FL_LIST;
while (args[optind]) {
ret = parse_cgroup_spec(cgroup_list, args[optind]);
if (ret) {
fprintf(fp, "%s: cgroup controller"
" and path parsing failed(%s)\n",
args[0], args[optind]);
}
optind++;
}
cgroup_list_cgroups(args[0], cgroup_list, flags);
if (!cgroup_list[0])
return;
for (i = 0; i < CG_HIER_MAX; i++)
cgroup_free_group_spec(cgroup_list[i]);
}
11 years, 9 months
Re: [Crash-utility] how to generate xen hypervisor core though kdump or other way?
by Daniel Kiper
Hi,
> The latest crash still can't analyse the vmcore.
>
> HjCloud:/mnt/winimg/crash/2012-10-01-08:11 # crash_new -f /boot/xen-syms-4.1.3_02-0.5.1 /boot/xen-syms-dbg-4.1.3_02-0.5.1 vmcore
Hmmm... I hope that you applied my latest patches.
If yes, is it possible to generate small as possible
crash dump and post it somewhere with Xen binary
and symbol file?
Daniel
11 years, 9 months
SCM access of crash
by arif hossain
Hi,
Is there any SCM public repo for crash? like git/svn or anything?
Cheers
arif
11 years, 9 months