From 521ea19d1c941786d4b7feeff7ff5352336d4f64 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 18 Jul 2011 15:19:40 +0000 Subject: [PATCH] - Remove the eintrcnt/eintrnames usage and introduce the concept of sintrcnt/sintrnames which are symbols containing the size of the 2 tables. - For amd64/i386 remove the storage of intr* stuff from assembly files. This area can be widely improved by applying the same to other architectures and likely finding an unified approach among them and move the whole code to be MI. More work in this area is expected to happen fairly soon. No MFC is previewed for this patch. Tested by: pluknet Reviewed by: jhb Approved by: re (kib) --- sys/amd64/amd64/genassym.c | 1 - sys/amd64/amd64/intr_machdep.c | 5 +++++ sys/amd64/amd64/support.S | 12 ------------ sys/arm/arm/irq_dispatch.S | 10 ++++++---- sys/arm/sa11x0/sa11x0_irq.S | 13 ++++--------- sys/i386/i386/genassym.c | 1 - sys/i386/i386/intr_machdep.c | 5 +++++ sys/i386/i386/support.s | 12 ------------ sys/ia64/ia64/locore.S | 7 +++++-- sys/kern/kern_clock.c | 2 +- sys/kern/kern_intr.c | 11 ++++++----- sys/mips/mips/exception.S | 11 +++++++---- sys/powerpc/aim/locore32.S | 7 +++++-- sys/powerpc/aim/locore64.S | 7 +++++-- sys/powerpc/booke/locore.S | 7 +++++-- sys/sparc64/sparc64/exception.S | 11 +++++++---- sys/sparc64/sparc64/intr_machdep.c | 2 +- sys/sys/interrupt.h | 4 ++-- usr.bin/vmstat/vmstat.c | 14 ++++++-------- 19 files changed, 70 insertions(+), 72 deletions(-) diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index aba790d0bd5..1c9abd5ab1b 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -201,7 +201,6 @@ ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_rflags)); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); -ASSYM(MAXCPU, MAXCPU); ASSYM(MAXCOMLEN, MAXCOMLEN); ASSYM(MAXPATHLEN, MAXPATHLEN); ASSYM(PC_SIZEOF, sizeof(struct pcpu)); diff --git a/sys/amd64/amd64/intr_machdep.c b/sys/amd64/amd64/intr_machdep.c index 3a8953153ff..b5822b6f4f3 100644 --- a/sys/amd64/amd64/intr_machdep.c +++ b/sys/amd64/amd64/intr_machdep.c @@ -80,6 +80,11 @@ static STAILQ_HEAD(, pic) pics; static int assign_cpu; #endif +u_long intrcnt[INTRCNT_COUNT]; +char intrnames[INTRCNT_COUNT * (MAXCOMLEN + 1)]; +size_t sintrcnt = sizeof(intrcnt); +size_t sintrnames = sizeof(intrnames); + static int intr_assign_cpu(void *arg, u_char cpu); static void intr_disable_src(void *arg); static void intr_init(void *__dummy); diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index d3522ec52e0..fed852c77b0 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -38,18 +38,6 @@ #include "assym.s" - .data - ALIGN_DATA - .globl intrcnt, eintrcnt -intrcnt: - .space INTRCNT_COUNT * 8 -eintrcnt: - - .globl intrnames, eintrnames -intrnames: - .space INTRCNT_COUNT * (MAXCOMLEN + 1) -eintrnames: - .text /* diff --git a/sys/arm/arm/irq_dispatch.S b/sys/arm/arm/irq_dispatch.S index 862471761b4..e3577565ed3 100644 --- a/sys/arm/arm/irq_dispatch.S +++ b/sys/arm/arm/irq_dispatch.S @@ -102,14 +102,16 @@ ASENTRY_NP(irq_entry) .align 0 - .global _C_LABEL(intrnames), _C_LABEL(eintrnames) - .global _C_LABEL(intrcnt), _C_LABEL(eintrcnt) + .global _C_LABEL(intrnames), _C_LABEL(sintrnames) + .global _C_LABEL(intrcnt), _C_LABEL(sintrcnt) _C_LABEL(intrnames): .space NIRQ * (MAXCOMLEN + 1) -_C_LABEL(eintrnames): _C_LABEL(intrcnt): .space NIRQ * 4 -_C_LABEL(eintrcnt): +_C_LABEL(sintrnames): + .word NIRQ * (MAXCOMLEN + 1) +_C_LABEL(sintrcnt): + .word NIRQ * 4 .global _C_LABEL(current_intr_depth) _C_LABEL(current_intr_depth): diff --git a/sys/arm/sa11x0/sa11x0_irq.S b/sys/arm/sa11x0/sa11x0_irq.S index 30f250cfc25..3cc3d14f7c3 100644 --- a/sys/arm/sa11x0/sa11x0_irq.S +++ b/sys/arm/sa11x0/sa11x0_irq.S @@ -118,16 +118,11 @@ ENTRY(sa11x0_activateirqs) mov r1, #0xffffffff str r1, [r0, #(SAIPIC_MR)] mov pc, lr -#ifdef IRQSTATS -Lintrcnt: - .word _C_LABEL(intrcnt) -#endif - .global _C_LABEL(intrnames), _C_LABEL(eintrnames) - .global _C_LABEL(eintrcnt) + .global _C_LABEL(intrnames), _C_LABEL(sintrnames) _C_LABEL(intrnames): -_C_LABEL(eintrnames): -_C_LABEL(eintrcnt): +_C_LABEL(sintrnames): + .word 0 .globl _C_LABEL(intrcnt), _C_LABEL(sintrcnt) @@ -135,4 +130,4 @@ _C_LABEL(intrcnt): .space ICU_LEN*4 /* XXX Should be linked to number of interrupts */ _C_LABEL(sintrcnt): - .space 32*4 + .word ICU_LEN*4 diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 5ae90029fba..9acc4f4e272 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -180,7 +180,6 @@ ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); -ASSYM(MAXCPU, MAXCPU); ASSYM(MAXCOMLEN, MAXCOMLEN); ASSYM(MAXPATHLEN, MAXPATHLEN); ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo)); diff --git a/sys/i386/i386/intr_machdep.c b/sys/i386/i386/intr_machdep.c index 56529f7b5b0..eb6bfa1b9e4 100644 --- a/sys/i386/i386/intr_machdep.c +++ b/sys/i386/i386/intr_machdep.c @@ -71,6 +71,11 @@ static STAILQ_HEAD(, pic) pics; static int assign_cpu; #endif +u_long intrcnt[INTRCNT_COUNT]; +char intrnames[INTRCNT_COUNT * (MAXCOMLEN + 1)]; +size_t sintrcnt = sizeof(intrcnt); +size_t sintrnames = sizeof(intrnames); + static int intr_assign_cpu(void *arg, u_char cpu); static void intr_disable_src(void *arg); static void intr_init(void *__dummy); diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 0c55f6f6b73..29a258cc0be 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -41,18 +41,6 @@ #define IDXSHIFT 10 - .data - ALIGN_DATA - .globl intrcnt, eintrcnt -intrcnt: - .space INTRCNT_COUNT * 4 -eintrcnt: - - .globl intrnames, eintrnames -intrnames: - .space INTRCNT_COUNT * (MAXCOMLEN + 1) -eintrnames: - .text /* diff --git a/sys/ia64/ia64/locore.S b/sys/ia64/ia64/locore.S index b2d096953c6..d4c1190f5d8 100644 --- a/sys/ia64/ia64/locore.S +++ b/sys/ia64/ia64/locore.S @@ -206,11 +206,14 @@ intr_n = 1 .byte 0 intr_n = intr_n + 1 .endr -EXPORT(eintrnames) +EXPORT(sintrnames) + .word INTRCNT_COUNT * INTRNAME_LEN + .align 8 EXPORT(intrcnt) .fill INTRCNT_COUNT, 8, 0 -EXPORT(eintrcnt) +EXPORT(sintrcnt) + .word INTRCNT_COUNT .text // in0: image base diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index f3f49cafa8e..681b64504db 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -842,7 +842,7 @@ watchdog_fire(void) curintr = intrcnt; curname = intrnames; inttotal = 0; - nintr = eintrcnt - intrcnt; + nintr = sintrcnt; printf("interrupt total\n"); while (--nintr >= 0) { diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 9cde5903f47..b9ed881224b 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -1869,8 +1869,7 @@ SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, static int sysctl_intrnames(SYSCTL_HANDLER_ARGS) { - return (sysctl_handle_opaque(oidp, intrnames, eintrnames - intrnames, - req)); + return (sysctl_handle_opaque(oidp, intrnames, sintrnames, req)); } SYSCTL_PROC(_hw, OID_AUTO, intrnames, CTLTYPE_OPAQUE | CTLFLAG_RD, @@ -1879,8 +1878,7 @@ SYSCTL_PROC(_hw, OID_AUTO, intrnames, CTLTYPE_OPAQUE | CTLFLAG_RD, static int sysctl_intrcnt(SYSCTL_HANDLER_ARGS) { - return (sysctl_handle_opaque(oidp, intrcnt, - (char *)eintrcnt - (char *)intrcnt, req)); + return (sysctl_handle_opaque(oidp, intrcnt, sintrcnt, req)); } SYSCTL_PROC(_hw, OID_AUTO, intrcnt, CTLTYPE_OPAQUE | CTLFLAG_RD, @@ -1894,9 +1892,12 @@ DB_SHOW_COMMAND(intrcnt, db_show_intrcnt) { u_long *i; char *cp; + u_int j; cp = intrnames; - for (i = intrcnt; i != eintrcnt && !db_pager_quit; i++) { + j = 0; + for (i = intrcnt; j < (sintrcnt / sizeof(u_long)) && !db_pager_quit; + i++, j++) { if (*cp == '\0') break; if (*i != 0) diff --git a/sys/mips/mips/exception.S b/sys/mips/mips/exception.S index 7b64462fdf5..ed7554bc7c0 100644 --- a/sys/mips/mips/exception.S +++ b/sys/mips/mips/exception.S @@ -1134,16 +1134,19 @@ END(MipsFPTrap) */ .data .globl intrcnt - .globl eintrcnt + .globl sintrcnt .globl intrnames - .globl eintrnames + .globl sintrnames intrnames: .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 -eintrnames: +sintrnames: + .word INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 + .align 4 intrcnt: .space INTRCNT_COUNT * 4 * 2 -eintrcnt: +sintrcnt: + .word INTRCNT_COUNT * 4 * 2 /* diff --git a/sys/powerpc/aim/locore32.S b/sys/powerpc/aim/locore32.S index d0a37781669..ed74af2fc71 100644 --- a/sys/powerpc/aim/locore32.S +++ b/sys/powerpc/aim/locore32.S @@ -90,11 +90,14 @@ GLOBAL(esym) #define INTRCNT_COUNT 256 /* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */ GLOBAL(intrnames) .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 -GLOBAL(eintrnames) +GLOBAL(sintrnames) + .word INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 + .align 4 GLOBAL(intrcnt) .space INTRCNT_COUNT * 4 * 2 -GLOBAL(eintrcnt) +GLOBAL(sintrcnt) + .word INTRCNT_COUNT * 4 * 2 .text .globl btext diff --git a/sys/powerpc/aim/locore64.S b/sys/powerpc/aim/locore64.S index 5af5e3a53ef..9a54b79a4cd 100644 --- a/sys/powerpc/aim/locore64.S +++ b/sys/powerpc/aim/locore64.S @@ -90,11 +90,14 @@ GLOBAL(esym) #define INTRCNT_COUNT 256 /* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */ GLOBAL(intrnames) .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 -GLOBAL(eintrnames) +GLOBAL(sintrnames) + .word INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 + .align 4 GLOBAL(intrcnt) .space INTRCNT_COUNT * 4 * 2 -GLOBAL(eintrcnt) +GLOBAL(sintrcnt) + .word INTRCNT_COUNT * 4 * 2 .text .globl btext diff --git a/sys/powerpc/booke/locore.S b/sys/powerpc/booke/locore.S index de7effc64f3..216962d09e3 100644 --- a/sys/powerpc/booke/locore.S +++ b/sys/powerpc/booke/locore.S @@ -789,10 +789,13 @@ GLOBAL(kernload) .long 0 GLOBAL(intrnames) .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 -GLOBAL(eintrnames) +GLOBAL(sintrnames) + .word INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 + .align 4 GLOBAL(intrcnt) .space INTRCNT_COUNT * 4 * 2 -GLOBAL(eintrcnt) +GLOBAL(sintrcnt) + .word INTRCNT_COUNT * 4 * 2 #include diff --git a/sys/sparc64/sparc64/exception.S b/sys/sparc64/sparc64/exception.S index 5ef50a373bf..fa2f2d5cfd4 100644 --- a/sys/sparc64/sparc64/exception.S +++ b/sys/sparc64/sparc64/exception.S @@ -371,14 +371,17 @@ END(rsf_fatal) .data _ALIGN_DATA - .globl intrnames, eintrnames + .globl intrnames, sintrnames intrnames: .space IV_MAX * (MAXCOMLEN + 1) -eintrnames: - .globl intrcnt, eintrcnt +sintrnames: + .word IV_MAX * (MAXCOMLEN + 1) + + .globl intrcnt, sintrcnt intrcnt: .space IV_MAX * 8 -eintrcnt: +sintrcnt: + .word IV_MAX * 8 .text diff --git a/sys/sparc64/sparc64/intr_machdep.c b/sys/sparc64/sparc64/intr_machdep.c index 112ddabc021..9a7e92fa6a2 100644 --- a/sys/sparc64/sparc64/intr_machdep.c +++ b/sys/sparc64/sparc64/intr_machdep.c @@ -171,7 +171,7 @@ static int intrcnt_setname(const char *name, int index) { - if (intrnames + (MAXCOMLEN + 1) * index >= eintrnames) + if ((MAXCOMLEN + 1) * index >= sintrnames) return (E2BIG); snprintf(intrnames + (MAXCOMLEN + 1) * index, MAXCOMLEN + 1, "%-*s", MAXCOMLEN, name); diff --git a/sys/sys/interrupt.h b/sys/sys/interrupt.h index fb253ae7a37..3dace82ed3b 100644 --- a/sys/sys/interrupt.h +++ b/sys/sys/interrupt.h @@ -149,10 +149,10 @@ extern struct intr_event *clk_intr_event; extern void *vm_ih; /* Counts and names for statistics (defined in MD code). */ -extern u_long eintrcnt[]; /* end of intrcnt[] */ -extern char eintrnames[]; /* end of intrnames[] */ extern u_long intrcnt[]; /* counts for for each device and stray */ extern char intrnames[]; /* string table containing device names */ +extern size_t sintrcnt; /* size of intrcnt table */ +extern size_t sintrnames; /* size of intrnames table */ #ifdef DDB void db_dump_intr_event(struct intr_event *ie, int handlers); diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index d31fdb54502..39e71fab8d3 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -90,12 +90,12 @@ static struct nlist namelist[] = { { "_nchstats" }, #define X_INTRNAMES 5 { "_intrnames" }, -#define X_EINTRNAMES 6 - { "_eintrnames" }, +#define X_SINTRNAMES 6 + { "_sintrnames" }, #define X_INTRCNT 7 { "_intrcnt" }, -#define X_EINTRCNT 8 - { "_eintrcnt" }, +#define X_SINTRCNT 8 + { "_sintrcnt" }, #define X_KMEMSTATS 9 { "_kmemstatistics" }, #define X_KMEMZONES 10 @@ -1153,10 +1153,8 @@ dointr(void) uptime = getuptime(); if (kd != NULL) { - intrcntlen = namelist[X_EINTRCNT].n_value - - namelist[X_INTRCNT].n_value; - inamlen = namelist[X_EINTRNAMES].n_value - - namelist[X_INTRNAMES].n_value; + intrcntlen = namelist[X_SINTRCNT].n_value; + inamlen = namelist[X_SINTRNAMES].n_value; if ((intrcnt = malloc(intrcntlen)) == NULL || (intrname = malloc(inamlen)) == NULL) err(1, "malloc()");