Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: "Mark Huang" <mhuang@broadcom.com>
To: "Keith Owens" <kaos@ocs.com.au>
Cc: "'linux-mips@oss.sgi.com'" <linux-mips@oss.sgi.com>
Subject: Re: DBE table ordering
Date: 17 Apr 2002 23:39:16 -0700	[thread overview]
Message-ID: <1019111956.2095.66.camel@mathom> (raw)
In-Reply-To: <30922.1019102135@ocs3.intra.ocs.com.au>

[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]

>From the objdump output, it looks like the exception table is in order
at link time, but the DBE table is definitely out of order. What seems
to be throwing it off is the dummy call to get_dbe() in traps.c. After
sprinkling a few more calls to get_dbe() around the kernel and seeing
what happens during link, it looks like any call to get_dbe() inside an
__init section (or probably any explicitly located section) will throw
off the ordering of the table. 

I'd say just change the binary search to a linear one, or reorder the
table at __init time if O(log n) is that important. If there were 600
entries in the table, sure, but I don't really see the benefit of the
additional code to deal with only a handful, as in most cases.

> The kernel relies on several tables being correctly ordered by the
> linker, including the initialization vectors, so it is a fair bet that
> the linker is correctly appended these tables as the kernel is built.
> What is more likely is that one of the exception table entries was
> created out of order.  Please send the following output to me, not the
> list.
> 
> objdump -h vmlinux
> objdump -s -j __ex_table vmlinux
> nm -a vmlinux
> 


[-- Attachment #2: traps.c.diff --]
[-- Type: text/x-diff, Size: 813 bytes --]

Index: arch/mips/kernel/traps.c
===================================================================
RCS file: /cvs/linux/arch/mips/kernel/traps.c,v
retrieving revision 1.107
diff -u -r1.107 traps.c
--- arch/mips/kernel/traps.c	2002/02/26 23:29:05	1.107
+++ arch/mips/kernel/traps.c	2002/04/18 06:36:06
@@ -360,17 +360,12 @@
 		 unsigned long value)
 {
 	const struct exception_table_entry *mid;
-	long diff;
 
-	while (first < last) {
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-		if (diff < 0)
-			first = mid + 1;
-		else
-			last = mid;
+	for (mid = first; mid <= last; mid++) {
+		if (mid->insn == value)
+			return mid->nextinsn;
 	}
-	return (first == last && first->insn == value) ? first->nextinsn : 0;
+	return 0;
 }
 
 extern spinlock_t modlist_lock;

WARNING: multiple messages have this Message-ID (diff)
From: "Mark Huang" <mhuang@broadcom.com>
To: Keith Owens <kaos@ocs.com.au>
Cc: "'linux-mips@oss.sgi.com'" <linux-mips@oss.sgi.com>
Subject: Re: DBE table ordering
Date: 17 Apr 2002 23:39:16 -0700	[thread overview]
Message-ID: <1019111956.2095.66.camel@mathom> (raw)
Message-ID: <20020418063916.cwszLAPjJZCxEld2KNKeH2pwIMDU_oqDznPHA0qk2Yg@z> (raw)
In-Reply-To: <30922.1019102135@ocs3.intra.ocs.com.au>

[-- Attachment #1: Type: text/plain, Size: 1176 bytes --]

From the objdump output, it looks like the exception table is in order
at link time, but the DBE table is definitely out of order. What seems
to be throwing it off is the dummy call to get_dbe() in traps.c. After
sprinkling a few more calls to get_dbe() around the kernel and seeing
what happens during link, it looks like any call to get_dbe() inside an
__init section (or probably any explicitly located section) will throw
off the ordering of the table. 

I'd say just change the binary search to a linear one, or reorder the
table at __init time if O(log n) is that important. If there were 600
entries in the table, sure, but I don't really see the benefit of the
additional code to deal with only a handful, as in most cases.

> The kernel relies on several tables being correctly ordered by the
> linker, including the initialization vectors, so it is a fair bet that
> the linker is correctly appended these tables as the kernel is built.
> What is more likely is that one of the exception table entries was
> created out of order.  Please send the following output to me, not the
> list.
> 
> objdump -h vmlinux
> objdump -s -j __ex_table vmlinux
> nm -a vmlinux
> 


[-- Attachment #2: traps.c.diff --]
[-- Type: text/x-diff, Size: 813 bytes --]

Index: arch/mips/kernel/traps.c
===================================================================
RCS file: /cvs/linux/arch/mips/kernel/traps.c,v
retrieving revision 1.107
diff -u -r1.107 traps.c
--- arch/mips/kernel/traps.c	2002/02/26 23:29:05	1.107
+++ arch/mips/kernel/traps.c	2002/04/18 06:36:06
@@ -360,17 +360,12 @@
 		 unsigned long value)
 {
 	const struct exception_table_entry *mid;
-	long diff;
 
-	while (first < last) {
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-		if (diff < 0)
-			first = mid + 1;
-		else
-			last = mid;
+	for (mid = first; mid <= last; mid++) {
+		if (mid->insn == value)
+			return mid->nextinsn;
 	}
-	return (first == last && first->insn == value) ? first->nextinsn : 0;
+	return 0;
 }
 
 extern spinlock_t modlist_lock;

  reply	other threads:[~2002-04-18  6:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 22:21 DBE table ordering Mark Huang
2002-04-18  3:55 ` Keith Owens
2002-04-18  6:39   ` Mark Huang [this message]
2002-04-18  6:39     ` Mark Huang
2002-04-18  6:51     ` Keith Owens
2002-04-18  6:51       ` Keith Owens
2002-04-18  9:37       ` Gleb O. Raiko
2002-04-18  9:49         ` Keith Owens
2002-04-18 12:03           ` Gleb O. Raiko
2002-04-18 17:59             ` Maciej W. Rozycki
2002-04-19  8:28               ` Gleb O. Raiko
2002-04-19 12:19                 ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1019111956.2095.66.camel@mathom \
    --to=mhuang@broadcom.com \
    --cc=kaos@ocs.com.au \
    --cc=linux-mips@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox