Re: [PATCH 2/6] ppc64: dynamically allocate h/w interrupt stack

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

 





On 04/07/22 8:29 am, HAGIO KAZUHITO(萩尾 一仁) wrote:
Hi Hari

thank you for the patches.

On 2022/06/29 4:19, Hari Bathini wrote:
Only older kernel (v2.4) used h/w interrupt stack to store frames when
CPU received IPI. Memory used for this in 'struct machine_specific' is
useless for later kernels. For the sake of backward compatibility keep
h/w interrupt stack but dynamically allocate memory for it and save
some bytes from being wasted.

Signed-off-by: Hari Bathini <hbathini@xxxxxxxxxxxxx>
---
   defs.h  |  2 +-
   ppc64.c | 48 +++++++++++++++++++-----------------------------
   2 files changed, 20 insertions(+), 30 deletions(-)

diff --git a/defs.h b/defs.h
index 7d3b734..d1d3ea9 100644
--- a/defs.h
+++ b/defs.h
@@ -6303,7 +6303,7 @@ struct ppc64_vmemmap {
    * Used to store the HW interrupt stack. It is only for 2.4.
    */
   struct machine_specific {
-        ulong hwintrstack[NR_CPUS];
+	ulong *hwintrstack;
           char *hwstackbuf;
           uint hwstacksize;
diff --git a/ppc64.c b/ppc64.c
index 0e1d867..fe96cfa 100644
--- a/ppc64.c
+++ b/ppc64.c
@@ -256,7 +256,7 @@ static int set_ppc64_max_physmem_bits(void)
   }
struct machine_specific ppc64_machine_specific = {
-	.hwintrstack = { 0 },
+	.hwintrstack = NULL,
   	.hwstackbuf = 0,
   	.hwstacksize = 0,
   	.pte_rpn_shift = PTE_RPN_SHIFT_DEFAULT,
@@ -275,7 +275,7 @@ struct machine_specific ppc64_machine_specific = {
   };
struct machine_specific book3e_machine_specific = {
-	.hwintrstack = { 0 },
+	.hwintrstack = NULL,
   	.hwstackbuf = 0,
   	.hwstacksize = 0,
   	.pte_rpn_shift = PTE_RPN_SHIFT_L4_BOOK3E_64K,
@@ -676,6 +676,9 @@ ppc64_init(int when)
   			 */
   			offset = MEMBER_OFFSET("paca_struct", "xHrdIntStack");
   			paca_sym  = symbol_value("paca");
+			if (!(machdep->machspec->hwintrstack =
+			      (ulong *)calloc(NR_CPUS, sizeof(ulong))))
+				error(FATAL, "cannot malloc hwintrstack space.");
   			for (cpu = 0; cpu < kt->cpus; cpu++)  {
   				readmem(paca_sym + (paca_size * cpu) + offset,
   					KVADDR,
@@ -686,14 +689,9 @@ ppc64_init(int when)
   			machdep->machspec->hwstacksize = 8 * machdep->pagesize;
   			if ((machdep->machspec->hwstackbuf = (char *)
   				malloc(machdep->machspec->hwstacksize)) == NULL)
-				error(FATAL, "cannot malloc hwirqstack space.");
-		} else
-			/*
-			 * 'xHrdIntStack' member in "paca_struct" is not
-			 * available for 2.6 kernel.
-			 */
-			BZERO(&machdep->machspec->hwintrstack,
-				NR_CPUS*sizeof(ulong));
+				error(FATAL, "cannot malloc hwirqstack buffer space.");
+		}
+
   		if (!machdep->hz) {
   			machdep->hz = HZ;
   			if (THIS_KERNEL_VERSION >= LINUX(2,6,0))
@@ -846,22 +844,13 @@ ppc64_dump_machdep_table(ulong arg)
   	fprintf(fp, "            is_vmaddr: %s\n",
   		machdep->machspec->is_vmaddr == book3e_is_vmaddr ?
   		"book3e_is_vmaddr()" : "ppc64_is_vmaddr()");
-	fprintf(fp, "    hwintrstack[%d]: ", NR_CPUS);
-       	for (c = 0; c < NR_CPUS; c++) {
-		for (others = 0, i = c; i < NR_CPUS; i++) {
-			if (machdep->machspec->hwintrstack[i])
-				others++;
+	if (machdep->machspec->hwintrstack) {
+		fprintf(fp, "    hwintrstack[%d]: ", NR_CPUS);
+		for (c = 0; c < NR_CPUS; c++) {
+			fprintf(fp, "%s%016lx ",
+				((c % 4) == 0) ? "\n  " : "",
+				machdep->machspec->hwintrstack[c]);
   		}
-		if (!others) {
-			fprintf(fp, "%s%s",
-			        c && ((c % 4) == 0) ? "\n  " : "",
-				c ? "(remainder unused)" : "(unused)");
-			break;
-		}
-
-		fprintf(fp, "%s%016lx ",
-			((c % 4) == 0) ? "\n  " : "",
-			machdep->machspec->hwintrstack[c]);
   	}
   	fprintf(fp, "\n");

I would prefer to print something like "hwintrstack: (unused)" to show
clearly when unused, but this (an empty line?) is also fine if you like.

Right. Printing "hwintrstack: (unused)" for else case would be better..
Let me address all the comments and respin...

Thanks,
Hari

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




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

 

Powered by Linux