Re: [PATCH] Re: New interrupt code in 2.1.80 breaks HiSax

MOLNAR Ingo (mingo@chiara.csoma.elte.hu)
Wed, 21 Jan 1998 22:13:14 +0100 (CET)


On Wed, 21 Jan 1998 ak@muc.de wrote:

> This seems to miss a file in the diff. kstat.irqs is never defined, neither
> kstat_irqs(). Also it doesn't compile because asm-386/smp.h is includes
> from an assembly file but is missing a #ifdef __ASSEMBLY__ around the
> inline function in the UP branch.

yes, heres that patch again, both problems fixed and tested.

-- mingo

--- linux/fs/proc/.array.c.orig Tue Jan 27 06:38:26 1998
+++ linux/fs/proc/array.c Tue Jan 27 07:02:34 1998
@@ -221,20 +221,14 @@

static int get_kstat(char * buffer)
{
- int i, j, len;
+ int i, len;
unsigned sum = 0;
extern unsigned long total_forks;
unsigned long ticks;

ticks = jiffies * smp_num_cpus;
-#ifndef __SMP__
for (i = 0 ; i < NR_IRQS ; i++)
- sum += kstat.interrupts[0][i];
-#else
- for (j = 0 ; j < smp_num_cpus ; j++)
- for (i = 0 ; i < NR_IRQS ; i++)
- sum += kstat.interrupts[cpu_logical_map[j]][i];
-#endif
+ sum += kstat_irqs(i);

#ifdef __SMP__
len = sprintf(buffer,
@@ -246,12 +240,12 @@
for (i = 0 ; i < smp_num_cpus; i++)
len += sprintf(buffer + len, "cpu%d %u %u %u %lu\n",
i,
- kstat.per_cpu_user[cpu_logical_map[i]],
- kstat.per_cpu_nice[cpu_logical_map[i]],
- kstat.per_cpu_system[cpu_logical_map[i]],
- jiffies - ( kstat.per_cpu_user[cpu_logical_map[i]] \
- + kstat.per_cpu_nice[cpu_logical_map[i]] \
- + kstat.per_cpu_system[cpu_logical_map[i]]));
+ kstat.per_cpu_user[cpu_logical_map(i)],
+ kstat.per_cpu_nice[cpu_logical_map(i)],
+ kstat.per_cpu_system[cpu_logical_map(i)],
+ jiffies - ( kstat.per_cpu_user[cpu_logical_map(i)] \
+ + kstat.per_cpu_nice[cpu_logical_map(i)] \
+ + kstat.per_cpu_system[cpu_logical_map(i)]));
len += sprintf(buffer + len,
"disk %u %u %u %u\n"
"disk_rio %u %u %u %u\n"
@@ -292,17 +286,8 @@
kstat.pswpin,
kstat.pswpout,
sum);
- for (i = 0 ; i < NR_IRQS ; i++) {
-#ifndef __SMP__
- len += sprintf(buffer + len, " %u", kstat.interrupts[0][i]);
-#else
- int sum=0;
-
- for (j = 0 ; j < smp_num_cpus ; j++)
- sum += kstat.interrupts[cpu_logical_map[j]][i];
- len += sprintf(buffer + len, " %u", sum);
-#endif
- }
+ for (i = 0 ; i < NR_IRQS ; i++)
+ len += sprintf(buffer + len, " %u", kstat_irqs(i));
len += sprintf(buffer + len,
"\nctxt %u\n"
"btime %lu\n"
@@ -1147,8 +1132,8 @@
for (i = 0 ; i < smp_num_cpus; i++)
len += sprintf(buffer + len, "cpu%d %lu %lu\n",
i,
- tsk->per_cpu_utime[cpu_logical_map[i]],
- tsk->per_cpu_stime[cpu_logical_map[i]]);
+ tsk->per_cpu_utime[cpu_logical_map(i)],
+ tsk->per_cpu_stime[cpu_logical_map(i)]);

return len;
}
--- linux/include/linux/.kernel_stat.h.orig Tue Jan 27 06:39:14 1998
+++ linux/include/linux/kernel_stat.h Tue Jan 27 08:12:31 1998
@@ -2,6 +2,7 @@
#define _LINUX_KERNEL_STAT_H

#include <asm/irq.h>
+#include <asm/smp.h>
#include <linux/smp.h>
#include <linux/tasks.h>

@@ -25,7 +26,7 @@
unsigned int dk_drive_wblk[DK_NDRIVE];
unsigned int pgpgin, pgpgout;
unsigned int pswpin, pswpout;
- unsigned int interrupts[NR_CPUS][NR_IRQS];
+ unsigned int irqs[NR_CPUS][NR_IRQS];
unsigned int ipackets, opackets;
unsigned int ierrors, oerrors;
unsigned int collisions;
@@ -33,5 +34,18 @@
};

extern struct kernel_stat kstat;
+
+/*
+ * Number of interrupts per specific IRQ source, since bootup
+ */
+extern inline int kstat_irqs (int irq)
+{
+ int i, sum=0;
+
+ for (i = 0 ; i < smp_num_cpus ; i++)
+ sum += kstat.irqs[cpu_logical_map(i)][irq];
+
+ return sum;
+}

#endif /* _LINUX_KERNEL_STAT_H */
--- linux/include/asm-i386/.smp.h.orig Tue Jan 27 06:44:23 1998
+++ linux/include/asm-i386/smp.h Tue Jan 27 08:12:25 1998
@@ -159,7 +159,6 @@
extern unsigned char boot_cpu_id;
extern unsigned long cpu_present_map;
extern volatile int cpu_number_map[NR_CPUS];
-extern volatile int cpu_logical_map[NR_CPUS];
extern volatile unsigned long smp_invalidate_needed;
extern void smp_flush_tlb(void);
extern volatile unsigned long kernel_flag, kernel_counter;
@@ -171,6 +170,11 @@
extern void smp_invalidate_rcv(void); /* Process an NMI */
extern void smp_local_timer_interrupt(struct pt_regs * regs);
extern void setup_APIC_clock (void);
+extern volatile int __cpu_logical_map[NR_CPUS];
+extern inline int cpu_logical_map(int cpu)
+{
+ return __cpu_logical_map[cpu];
+}


/*
@@ -235,5 +239,12 @@
#define SMP_FROM_INT 1
#define SMP_FROM_SYSCALL 2

+#else
+#ifndef ASSEMBLY
+extern inline int cpu_logical_map(int cpu)
+{
+ return cpu;
+}
+#endif
#endif
#endif
--- linux/drivers/scsi/.BusLogic.c.orig Tue Jan 27 07:15:31 1998
+++ linux/drivers/scsi/BusLogic.c Tue Jan 27 07:16:29 1998
@@ -2338,15 +2338,11 @@
Issue the Test Command Complete Interrupt commands.
*/

- InitialInterruptCount = 0;
- for (i=0; i<NR_CPUS; i++)
- InitialInterruptCount += kstat.interrupts[i][HostAdapter->IRQ_Channel];
+ InitialInterruptCount = kstat_irqs(HostAdapter->IRQ_Channel);
for (i = 0; i < TestCount; i++)
BusLogic_Command(HostAdapter, BusLogic_TestCommandCompleteInterrupt,
NULL, 0, NULL, 0);
- FinalInterruptCount = 0;
- for (i=0; i<NR_CPUS; i++)
- FinalInterruptCount += kstat.interrupts[i][HostAdapter->IRQ_Channel];
+ FinalInterruptCount = kstat_irqs(HostAdapter->IRQ_Channel);
/*
Verify that BusLogic_InterruptHandler was called at least TestCount
times. Shared IRQ Channels could cause more than TestCount interrupts to
--- linux/arch/i386/kernel/.smp.c.orig Tue Jan 27 04:51:48 1998
+++ linux/arch/i386/kernel/smp.c Tue Jan 27 06:51:01 1998
@@ -115,7 +115,7 @@
int smp_num_cpus = 1; /* Total count of live CPU's */
int smp_threads_ready=0; /* Set when the idlers are all forked */
volatile int cpu_number_map[NR_CPUS]; /* which CPU maps to which logical number */
-volatile int cpu_logical_map[NR_CPUS]; /* which logical number maps to which CPU */
+volatile int __cpu_logical_map[NR_CPUS]; /* which logical number maps to which CPU */
volatile unsigned long cpu_callin_map[NR_CPUS] = {0,}; /* We always use 0 the rest is ready for parallel delivery */
volatile unsigned long smp_invalidate_needed; /* Used for the invalidate map that's also checked in the spinlock */
volatile unsigned long kstack_ptr; /* Stack vector for booting CPU's */
@@ -526,7 +526,7 @@
* set some other information about it.
*/
nlong = boot_cpu_id<<24; /* Dummy 'self' for bootup */
- cpu_logical_map[0] = boot_cpu_id;
+ __cpu_logical_map[0] = boot_cpu_id;
global_irq_holder = boot_cpu_id;
current->processor = boot_cpu_id;

@@ -717,7 +717,7 @@
panic("No idle process for CPU %d", i);

idle->processor = i;
- cpu_logical_map[cpucount] = i;
+ __cpu_logical_map[cpucount] = i;
cpu_number_map[i] = cpucount;

/* start_eip had better be page-aligned! */
@@ -861,7 +861,7 @@
/* number CPUs logically, starting from 1 (BSP is 0) */
#if 0
cpu_number_map[i] = cpucount;
- cpu_logical_map[cpucount] = i;
+ __cpu_logical_map[cpucount] = i;
#endif
printk("OK.\n");
printk("CPU%d: ", i);
--- linux/arch/i386/kernel/.irq.c.orig Tue Jan 27 04:53:16 1998
+++ linux/arch/i386/kernel/irq.c Tue Jan 27 08:42:29 1998
@@ -356,12 +358,13 @@
continue;
p += sprintf(p, "%3d: ",i);
#ifndef __SMP__
- p += sprintf(p, "%10u ", kstat.interrupts[0][i]);
+ p += sprintf(p, "%10u ", kstat_irqs(i));
#else
for (j=0; j<smp_num_cpus; j++)
p += sprintf(p, "%10u ",
- kstat.interrupts[cpu_logical_map[j]][i]);
+ kstat.irqs[cpu_logical_map(j)][i]);
#endif
+
if (IO_APIC_IRQ(i))
p += sprintf(p, " IO-APIC ");
else
@@ -596,7 +599,7 @@
while (test_bit(0,&global_irq_lock)) mb();
#endif

- kstat.interrupts[cpu][irq]++;
+ kstat.irqs[cpu][irq]++;
status = 0;
action = *(irq + irq_action);

@@ -897,7 +900,7 @@
/*
* save current irq counts
*/
- memcpy(probe_irqs,kstat.interrupts,NR_CPUS*NR_IRQS*sizeof(int));
+ memcpy(probe_irqs,kstat.irqs,NR_CPUS*NR_IRQS*sizeof(int));

/*
* first, enable any unassigned irqs
@@ -922,7 +925,7 @@
*/
for (i=0; i<NR_IRQS; i++)
for (j=0; j<NR_CPUS; j++)
- if (kstat.interrupts[j][i] != probe_irqs[j][i])
+ if (kstat.irqs[j][i] != probe_irqs[j][i])
irqs &= ~(i<<1);

return irqs;
@@ -935,7 +938,7 @@
for (i=0; i<NR_IRQS; i++) {
int sum = 0;
for (j=0; j<NR_CPUS; j++) {
- sum += kstat.interrupts[j][i];
+ sum += kstat.irqs[j][i];
sum -= probe_irqs[j][i];
}
if (sum && (irqs & (i<<1))) {