Re: Re: [PATCH] crash: add pcpu_info support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dave Anderson wrote:
Dave Anderson wrote:
 > Is it necessary that the "pcpu_info" check in get_active_set()
 > needs to come before the "runqueues" and "per_cpu__runqueues"
 > checks?  I'd prefer it to be done last if at all possible.

Never mind -- I see that in your kernel patch you do this:

-       struct task_struct *curr, *idle;
+       struct task_struct *curr;

so the pcpu_info check can be deferred in get_idle_threads()
but not in get_active_set().

Ideally I'd still like to defer it in get_active_set(), but it's
probably not worth the extra effort.

Actually, I still think it doesn't need to be checked first,
since your kernel patch also removes the per_cpu__runqueues
declaration:

-static DEFINE_PER_CPU(struct rq, runqueues);

So unless you've resurrected the "runqueues" symbol somewhere
it seemingly doesn't need to be checked first.

Anyway, here's how I'd like to do it.  I can envision you
gents coming back in the future with other OpenVZ-specific
requests, so I've added a new ARCH_OPENVZ flag for a clearer
way to segregate your code.

Can you please verify (and fix if necessary) the attached patch?
It's 4.0-4.13.

Thanks,
  Dave


Index: defs.h
===================================================================
RCS file: /nfs/projects/cvs/crash/defs.h,v
retrieving revision 1.339
diff -u -r1.339 defs.h
--- defs.h	11 Jan 2008 16:52:04 -0000	1.339
+++ defs.h	16 Jan 2008 16:45:00 -0000
@@ -467,10 +467,12 @@
 #define BUGVERBOSE_OFF       (0x1000000)
 #define RELOC_SET            (0x2000000)
 #define RELOC_FORCE          (0x4000000)
+#define ARCH_OPENVZ          (0x8000000)
 
 #define GCC_VERSION_DEPRECATED (GCC_3_2|GCC_3_2_3|GCC_2_96|GCC_3_3_2|GCC_3_3_3)
 
-#define XEN()  (kt->flags & ARCH_XEN)
+#define XEN()    (kt->flags & ARCH_XEN)
+#define OPENVZ() (kt->flags & ARCH_OPENVZ)
 
 #define XEN_MACHINE_TO_MFN(m)    ((ulonglong)(m) >> PAGESHIFT())
 #define XEN_PFN_TO_PSEUDO(p)     ((ulonglong)(p) << PAGESHIFT())
@@ -1437,6 +1439,9 @@
 	long zone_present_pages;
 	long zone_flags;
 	long zone_pages_scanned;
+	long pcpu_info_vcpu;
+	long pcpu_info_idle;
+	long vcpu_struct_rq;
 };
 
 struct size_table {         /* stash of commonly-used sizes */
@@ -1540,6 +1545,8 @@
 	long upid;
 	long kmem_cache_cpu;
 	long cfs_rq;
+	long pcpu_info;
+	long vcpu_struct;
 };
 
 struct array_table {
Index: kernel.c
===================================================================
RCS file: /nfs/projects/cvs/crash/kernel.c,v
retrieving revision 1.180
diff -u -r1.180 kernel.c
--- kernel.c	26 Nov 2007 20:27:08 -0000	1.180
+++ kernel.c	16 Jan 2008 16:55:33 -0000
@@ -475,6 +475,19 @@
 	if (!(kt->flags & DWARF_UNWIND))
 		kt->flags |= NO_DWARF_UNWIND; 
 
+	/* 
+	 *  OpenVZ 
+	 */
+	if (kernel_symbol_exists("pcpu_info") && 
+	    STRUCT_EXISTS("pcpu_info") && STRUCT_EXISTS("vcpu_struct")) {
+		MEMBER_OFFSET_INIT(pcpu_info_vcpu, "pcpu_info", "vcpu");
+		MEMBER_OFFSET_INIT(pcpu_info_idle, "pcpu_info", "idle");
+		MEMBER_OFFSET_INIT(vcpu_struct_rq, "vcpu_struct", "rq");
+		STRUCT_SIZE_INIT(pcpu_info, "pcpu_info");
+		STRUCT_SIZE_INIT(vcpu_struct, "vcpu_struct");
+		kt->flags |= ARCH_OPENVZ;
+	}
+
 	BUG_bytes_init();
 }
 
@@ -3757,6 +3770,8 @@
 		fprintf(fp, "%sUSE_OLD_BT", others++ ? "|" : "");
 	if (kt->flags & ARCH_XEN)
 		fprintf(fp, "%sARCH_XEN", others++ ? "|" : "");
+	if (kt->flags & ARCH_OPENVZ)
+		fprintf(fp, "%sARCH_OPENVZ", others++ ? "|" : "");
 	if (kt->flags & NO_IKCONFIG)
 		fprintf(fp, "%sNO_IKCONFIG", others++ ? "|" : "");
 	if (kt->flags & DWARF_UNWIND)
Index: symbols.c
===================================================================
RCS file: /nfs/projects/cvs/crash/symbols.c,v
retrieving revision 1.156
diff -u -r1.156 symbols.c
--- symbols.c	4 Jan 2008 16:57:08 -0000	1.156
+++ symbols.c	16 Jan 2008 17:01:59 -0000
@@ -6991,6 +6991,12 @@
 		OFFSET(cfs_rq_tasks_timeline));
 	fprintf(fp, "                  rt_rq_active: %ld\n",
 		OFFSET(rt_rq_active));
+	fprintf(fp, "                pcpu_info_vcpu: %ld\n",
+		OFFSET(pcpu_info_vcpu));
+	fprintf(fp, "                pcpu_info_idle: %ld\n",
+		OFFSET(pcpu_info_idle));
+	fprintf(fp, "                vcpu_struct_rq: %ld\n",
+		OFFSET(vcpu_struct_rq));
 
 	fprintf(fp, "\n                    size_table:\n");
 	fprintf(fp, "                          page: %ld\n", SIZE(page));
@@ -7147,6 +7153,10 @@
 		SIZE(rlimit));
 	fprintf(fp, "                        cfs_rq: %ld\n", 
 		SIZE(cfs_rq));
+	fprintf(fp, "                     pcpu_info: %ld\n", 
+		SIZE(pcpu_info));
+	fprintf(fp, "                   vcpu_struct: %ld\n", 
+		SIZE(vcpu_struct));
 
         fprintf(fp, "\n                   array_table:\n");
 	/*
Index: task.c
===================================================================
RCS file: /nfs/projects/cvs/crash/task.c,v
retrieving revision 1.135
diff -u -r1.135 task.c
--- task.c	17 Dec 2007 18:35:38 -0000	1.135
+++ task.c	16 Jan 2008 17:44:46 -0000
@@ -5831,6 +5831,16 @@
 			cnt++;
 		else
                 	BZERO(tasklist, sizeof(ulong) * NR_CPUS);
+	} else if (OPENVZ()) {
+		runq = symbol_value("pcpu_info");
+		runqbuf = GETBUF(SIZE(pcpu_info));
+		for (i = 0; i < nr_cpus; i++, runq += SIZE(pcpu_info)) {
+			readmem(runq, KVADDR, runqbuf, SIZE(pcpu_info),
+				"pcpu info", FAULT_ON_ERROR);
+			tasklist[i] = ULONG(runqbuf + OFFSET(pcpu_info_idle));
+			if (IS_KVADDR(tasklist[i]))
+				cnt++;
+		}
 	}
 
 	if (runqbuf)
@@ -5924,14 +5934,38 @@
 	} else if (symbol_exists("per_cpu__runqueues")) {
 		runq = symbol_value("per_cpu__runqueues");
 		per_cpu = TRUE;
-	} else
+	} else if (OPENVZ())
+		runq = symbol_value("pcpu_info");
+	else
 		return FALSE;
 
         BZERO(tt->active_set, sizeof(ulong) * NR_CPUS);
         runqbuf = GETBUF(SIZE(runqueue));
 	cnt = 0;
 
-	if (VALID_MEMBER(runqueue_curr) && per_cpu) {
+	if (OPENVZ()) {
+		ulong vcpu_struct; 
+		char *pcpu_info_buf, *vcpu_struct_buf;
+
+		pcpu_info_buf   = GETBUF(SIZE(pcpu_info));
+		vcpu_struct_buf = GETBUF(SIZE(vcpu_struct));
+
+		for (i = 0; i < kt->cpus; i++, runq += SIZE(pcpu_info)) {
+			readmem(runq, KVADDR, pcpu_info_buf, 
+				SIZE(pcpu_info), "pcpu_info", FAULT_ON_ERROR);
+			vcpu_struct= ULONG(pcpu_info_buf +
+				OFFSET(pcpu_info_vcpu));
+			readmem(vcpu_struct, KVADDR, vcpu_struct_buf, 
+				SIZE(vcpu_struct), "pcpu_info->vcpu",
+				FAULT_ON_ERROR);
+			tt->active_set[i] = ULONG(vcpu_struct_buf +
+				OFFSET(vcpu_struct_rq) + OFFSET(runqueue_curr));
+			if (IS_KVADDR(tt->active_set[i]))
+				cnt++;
+		}
+		FREEBUF(pcpu_info_buf);
+		FREEBUF(vcpu_struct_buf);
+	} else if (VALID_MEMBER(runqueue_curr) && per_cpu) {
                	for (i = 0; i < kt->cpus; i++) {
                         if ((kt->flags & SMP) && (kt->flags & PER_CPU_OFF)) {
                                 runq = symbol_value("per_cpu__runqueues") +
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux