Skip to contentSkip to conversation

2.4.21-rc2-cset-1129 hugetlb, unwind fixes

PATCH In review Keith Owens 4 participants 5 messages May 28, 2003 – May 31, 2003 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.21-rc2-cset-1129 hugetlb, unwind fixes

2.4.21-rc2-cset-1129 is 9 days old so some of these may have been fixed already.

fs/proc/proc_misc.c:
Allow build with CONFIG_HUGETLB_PAGE=n.

arch/ia64/kernel/unwind.c:
Only call get_scratch_regs() when pt is really needed. The premature calls to get_scratch_regs() would pick up the wrong address for pt if the register was in switch_stack and pt_regs had not been reached yet, e.g. unw_access_ar(&info, UNW_AR_BSPSTORE,...) before pt_regs had been reached.

Correct debugging code that had the wrong the number of parameters and referred to non-existent variables. Only shows up with

    CFLAGS_unwind.o += -DUNW_DEBUG=<number>.

Index: 21-rc2.3/fs/proc/proc_misc.c

fs/proc/proc_misc.c Wed, 28 May 2003 16:57:30 +1000 kaos (linux-2.4/o/b/48_proc_misc. 1.1.1.1.1.1.1.17 644) renamed from fs/proc/proc_misc.c Wed, 28 May 2003 16:39:56 +1000 kaos (linux-2.4/o/b/48_proc_misc. 1.1.1.1.1.1.1.17 644) +2 -0
@@ -208,7 +208,9 @@ static int meminfo_read_proc(char *page,
 		K(i.totalswap),
 		K(i.freeswap));
 
+#ifdef CONFIG_HUGETLB_PAGE
 	len += hugetlb_report_meminfo(page + len);
+#endif
 
 	return proc_calc_metrics(page, start, off, count, eof, len);
 #undef B

Index: 21-rc2.3/arch/ia64/kernel/unwind.c

arch/ia64/kernel/unwind.c Wed, 28 May 2003 17:05:42 +1000 kaos (linux-2.4/r/c/42_unwind.c 1.1.2.1.1.2.3.1.1.1.1.4 644) renamed from arch/ia64/kernel/unwind.c Sun, 18 May 2003 15:06:40 +1000 kaos (linux-2.4/r/c/42_unwind.c 1.1.2.1.1.2.3.1.1.1.1.4 644) +11 -11
@@ -371,12 +371,11 @@ unw_access_br (struct unw_frame_info *in
 	unsigned long *addr;
 	struct pt_regs *pt;
 
-	pt = get_scratch_regs(info);
 	switch (regnum) {
 		/* scratch: */
-	      case 0: addr = &pt->b0; break;
-	      case 6: addr = &pt->b6; break;
-	      case 7: addr = &pt->b7; break;
+	      case 0: pt = get_scratch_regs(info); addr = &pt->b0; break;
+	      case 6: pt = get_scratch_regs(info); addr = &pt->b6; break;
+	      case 7: pt = get_scratch_regs(info); addr = &pt->b7; break;
 
 		/* preserved: */
 	      case 1: case 2: case 3: case 4: case 5:
@@ -409,15 +408,15 @@ unw_access_fr (struct unw_frame_info *in
 		return -1;
 	}
 
-	pt = get_scratch_regs(info);
-
 	if (regnum <= 5) {
 		addr = *(&info->f2_loc + (regnum - 2));
 		if (!addr)
 			addr = &info->sw->f2 + (regnum - 2);
 	} else if (regnum <= 15) {
-		if (regnum <= 9)
+		if (regnum <= 9) {
+			pt = get_scratch_regs(info);
 			addr = &pt->f6  + (regnum - 6);
+		}
 		else
 			addr = &info->sw->f10 + (regnum - 10);
 	} else if (regnum <= 31) {
@@ -447,7 +446,6 @@ unw_access_ar (struct unw_frame_info *in
 	unsigned long *addr;
 	struct pt_regs *pt;
 
-	pt = get_scratch_regs(info);
 	switch (regnum) {
 	      case UNW_AR_BSP:
 		addr = info->bsp_loc;
@@ -502,10 +500,12 @@ unw_access_ar (struct unw_frame_info *in
 		break;
 
 	      case UNW_AR_RSC:
+		pt = get_scratch_regs(info);
 		addr = &pt->ar_rsc;
 		break;
 
 	      case UNW_AR_CCV:
+		pt = get_scratch_regs(info);
 		addr = &pt->ar_ccv;
 		break;
 
@@ -1931,7 +1931,7 @@ init_frame_info (struct unw_frame_info *
 		   "  pr     0x%lx\n"
 		   "  sw     0x%lx\n"
 		   "  sp     0x%lx\n",
-		   __FUNCTION__, (unsigned long) task, rbslimit, rbstop, stktop, stklimit,
+		   __FUNCTION__, (unsigned long) t, rbslimit, rbstop, stktop, stklimit,
 		   info->pr, (unsigned long) info->sw, info->sp);
 	STAT(unw.stat.api.init_time += ia64_get_itc() - start; local_irq_restore(flags));
 }
@@ -1952,7 +1952,7 @@ unw_init_from_interruption (struct unw_f
 		   "  bsp    0x%lx\n"
 		   "  sof    0x%lx\n"
 		   "  ip     0x%lx\n",
-		   info->bsp, sof, info->ip);
+		   __FUNCTION__, info->bsp, sof, info->ip);
 	find_save_locs(info);
 }
 
@@ -1970,7 +1970,7 @@ unw_init_frame_info (struct unw_frame_in
 		   "  bsp    0x%lx\n"
 		   "  sol    0x%lx\n"
 		   "  ip     0x%lx\n",
-		   info->bsp, sol, info->ip);
+		   __FUNCTION__, info->bsp, sol, info->ip);
 	find_save_locs(info);
 }
 
#1 lore raw

Thanks Keith for pointing out the issue with fs/proc/proc_misc.c for !CONFIG_HUGETLB_PAGE. Please use the attached small patch for fs/proc/proc_misc.c (as is there in 2.5).

Quoted 141 lines

-----Original Message-----
From: Keith Owens [mailto:[email protected]]
Sent: Wednesday, May 28, 2003 12:17 AM
To: [email protected]
Subject: [Linux-ia64] [patch] 2.4.21-rc2-cset-1129 hugetlb, unwind fixes

2.4.21-rc2-cset-1129 is 9 days old so some of these may have been fixed already.

fs/proc/proc_misc.c:
Allow build with CONFIG_HUGETLB_PAGE=n.

arch/ia64/kernel/unwind.c:
Only call get_scratch_regs() when pt is really needed. The
premature
calls to get_scratch_regs() would pick up the wrong address
for pt if
the register was in switch_stack and pt_regs had not been reached yet, e.g. unw_access_ar(&info, UNW_AR_BSPSTORE,...) before pt_regs had been reached.

Correct debugging code that had the wrong the number of parameters and referred to non-existent variables. Only shows up with

    CFLAGS_unwind.o += -DUNW_DEBUG=<number>.

Index: 21-rc2.3/fs/proc/proc_misc.c
--- 21-rc2.3/fs/proc/proc_misc.c Wed, 28 May 2003 16:39:56 +1000 kaos (linux-2.4/o/b/48_proc_misc. 1.1.1.1.1.1.1.17 644) +++ 21-rc2.3(w)/fs/proc/proc_misc.c Wed, 28 May 2003 16:57:30 +1000 kaos
+++ (linux-2.4/o/b/48_proc_misc. 1.1.1.1.1.1.1.17 644)

(quoted diff) +2 -0
@@ -208,7 +208,9 @@ static int meminfo_read_proc(char *page,
 		K(i.totalswap),
 		K(i.freeswap));
 
+#ifdef CONFIG_HUGETLB_PAGE
 	len += hugetlb_report_meminfo(page + len);
+#endif
 
 	return proc_calc_metrics(page, start, off, count, eof, 

len); #undef B
Index: 21-rc2.3/arch/ia64/kernel/unwind.c
--- 21-rc2.3/arch/ia64/kernel/unwind.c Sun, 18 May 2003 15:06:40 +1000 kaos (linux-2.4/r/c/42_unwind.c 1.1.2.1.1.2.3.1.1.1.1.4 644)
+++ 21-rc2.3(w)/arch/ia64/kernel/unwind.c Wed, 28 May 2003 17:05:42 +++ +1000 kaos (linux-2.4/r/c/42_unwind.c 1.1.2.1.1.2.3.1.1.1.1.4 644)

(quoted diff) +3 -4
@@ -371,12 +371,11 @@ unw_access_br (struct unw_frame_info *in
 	unsigned long *addr;
 	struct pt_regs *pt;
 
-	pt = get_scratch_regs(info);
 	switch (regnum) {
 		/* scratch: */
-	      case 0: addr = &pt->b0; break;
-	      case 6: addr = &pt->b6; break;
-	      case 7: addr = &pt->b7; break;
+	      case 0: pt = get_scratch_regs(info); addr = 
 &pt->b0; break;
+	      case 6: pt = get_scratch_regs(info); addr = 
 &pt->b6; break;
+	      case 7: pt = get_scratch_regs(info); addr = 
 &pt->b7; break;
(quoted diff) +7 -5
 		/* preserved: */
 	      case 1: case 2: case 3: case 4: case 5:
@@ -409,15 +408,15 @@ unw_access_fr (struct unw_frame_info *in
 		return -1;
 	}
 
-	pt = get_scratch_regs(info);
-
 	if (regnum <= 5) {
 		addr = *(&info->f2_loc + (regnum - 2));
 		if (!addr)
 			addr = &info->sw->f2 + (regnum - 2);
 	} else if (regnum <= 15) {
-		if (regnum <= 9)
+		if (regnum <= 9) {
+			pt = get_scratch_regs(info);
 			addr = &pt->f6  + (regnum - 6);
+		}
 		else
 			addr = &info->sw->f10 + (regnum - 10);
 	} else if (regnum <= 31) {
@@ -447,7 +446,6 @@ unw_access_ar (struct unw_frame_info *in
 	unsigned long *addr;
 	struct pt_regs *pt;
 
-	pt = get_scratch_regs(info);
 	switch (regnum) {
 	      case UNW_AR_BSP:
 		addr = info->bsp_loc;
@@ -502,10 +500,12 @@ unw_access_ar (struct unw_frame_info *in
 		break;
 
 	      case UNW_AR_RSC:
+		pt = get_scratch_regs(info);
 		addr = &pt->ar_rsc;
 		break;
 
 	      case UNW_AR_CCV:
+		pt = get_scratch_regs(info);
 		addr = &pt->ar_ccv;
 		break;
 
@@ -1931,7 +1931,7 @@ init_frame_info (struct unw_frame_info *
 		   "  pr     0x%lx\n"
 		   "  sw     0x%lx\n"
 		   "  sp     0x%lx\n",
-		   __FUNCTION__, (unsigned long) task, 
 rbslimit, rbstop, stktop, stklimit,
+		   __FUNCTION__, (unsigned long) t, rbslimit, 
 rbstop, stktop, 
+stklimit,
 		   info->pr, (unsigned long) info->sw, info->sp);
 	STAT(unw.stat.api.init_time += ia64_get_itc() - start; 

local_irq_restore(flags)); } @@ -1952,7 +1952,7 @@ unw_init_from_interruption (struct unw_f

(quoted diff) +2 -2
 		   "  bsp    0x%lx\n"
 		   "  sof    0x%lx\n"
 		   "  ip     0x%lx\n",
-		   info->bsp, sof, info->ip);
+		   __FUNCTION__, info->bsp, sof, info->ip);
 	find_save_locs(info);
 }
@@ -1970,7 +1970,7 @@ unw_init_frame_info (struct unw_frame_in
 		   "  bsp    0x%lx\n"
 		   "  sol    0x%lx\n"
 		   "  ip     0x%lx\n",
-		   info->bsp, sol, info->ip);
+		   __FUNCTION__, info->bsp, sol, info->ip);
 	find_save_locs(info);
 }
 
Quoted 5 lines

_______________________________________________
Linux-IA64 mailing list [email protected]
http://lists.linuxia64.org/lists/listinfo/linu> x-ia64

fs/proc/proc_misc.c +1 -0
diff -Nur A/fs/proc/proc_misc.c B/fs/proc/proc_misc.c
@@ -36,6 +36,7 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/seq_file.h>
+#include <linux/hugetlb.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
#2 lore raw
In reply to Keith Owens
Quoted 3 lines · Rohit

Thanks Keith for pointing out the issue with fs/proc/proc_misc.c for !CONFIG_HUGETLB_PAGE. Please use the attached small patch for fs/proc/proc_misc.c (as is there in 2.5).

I applied Rohit's patch (adding the #include of <linux/hugetlb.h>) to 2.4 so it's the same as 2.5.

Bjorn

#3 lore raw
In reply to Keith Owens
Quoted 10 lines · Keith Owens

arch/ia64/kernel/unwind.c:
Only call get_scratch_regs() when pt is really needed. The premature calls to get_scratch_regs() would pick up the wrong address for pt if the register was in switch_stack and pt_regs had not been reached yet, e.g. unw_access_ar(&info, UNW_AR_BSPSTORE,...) before pt_regs had been reached.

Correct debugging code that had the wrong the number of parameters and referred to non-existent variables. Only shows up with

    CFLAGS_unwind.o += -DUNW_DEBUG=<number>.

It looks like these changes should be applicable to 2.5 as well. I'd like to avoid gratuitous differences with 2.5, so can you get David to apply them there first? (I'm not implying that your fixes are gratuitous, just that since David is "Mr. Unwind", he may make minor changes when applying your patch, and I might as well get those at the same time. :-)

Bjorn

#4 lore raw
In reply to Keith Owens
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens

Keith> arch/ia64/kernel/unwind.c: Only call get_scratch_regs() when Keith> pt is really needed. The premature calls to Keith> get_scratch_regs() would pick up the wrong address for pt if Keith> the register was in switch_stack and pt_regs had not been Keith> reached yet, e.g. unw_access_ar(&info, UNW_AR_BSPSTORE,...) Keith> before pt_regs had been reached.

This looks fine to me. Can you send me a 2.5 patch?

	--david