Re: [PATCH] Remove mfinfo[64] used by get_wchan()

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

 



Atsushi Nemoto wrote:
> On Fri, 18 Aug 2006 09:50:57 +0200, Franck Bui-Huu <vagabon.xyz@xxxxxxxxx> wrote:
>>>> +	unsigned long size = 0;
>>> You must pass some non-zero size even if CONFIG_KALLSYMS was not set.
>>> Otherwise schedule_mfi will not be initialized as expected.  Actually,
>>> this is not a problem of this patch, but we missed this point on
>>> previous cleanups for the get_frame_info()...
>> or maybe we can just fix get_frame_info() and make it more robust ?
> 
> Maybe.  But info->func_size == 0 is valid input when it was called via
> show_backtrace.  If an exception occured on a first instruction of a
> function, get_frame_info() should return 1.  So it would be easy to
> give some appropriate (128?) size here.
> 

Does something like this seem correct ? If an exception occured on a first
instruction of a function, show_backtrace() will call get_frame_info()
with info->func_size != 0 but very small. In this case it returns 1.

If the caller of get_frame_info() set info->func_size = 0, then it doesn't
know the size of the function, and we assume it to 128 instructions.

		Franck

-- >8 --


diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 951bf9c..5b18806 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -311,12 +311,19 @@ static inline int is_sp_move_ins(union m
 static int get_frame_info(struct mips_frame_info *info)
 {
 	union mips_instruction *ip = info->func;
-	int i, max_insns =
-		min(128UL, info->func_size / sizeof(union mips_instruction));
+	unsigned max_insns = info->func_size / sizeof(union mips_instruction);
+	unsigned i;
 
 	info->pc_offset = -1;
 	info->frame_size = 0;
 
+	if (!ip)
+		goto err;
+	
+	if (max_insns == 0)
+		max_insns = 128U;
+	max_insns = min(128U, max_insns);
+
 	for (i = 0; i < max_insns; i++, ip++) {
 
 		if (is_jal_jalr_jr_ins(ip))
@@ -337,6 +344,7 @@ static int get_frame_info(struct mips_fr
 	if (info->pc_offset < 0) /* leaf */
 		return 1;
 	/* prologue seems boggus... */
+err:
 	return -1;
 }


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux