(patch) updated alpha fixes

Jeff Garzik (jgarzik@dog.normnet.org)
Fri, 4 Sep 1998 16:31:38 -0400 (EDT)


This is an updated version of the SMP Alpha fixes patch sent recently to
Linus and the lists, against 2.1.120-pre3. The only real change between
the previous patch and this one is that the klock_* references are
removed, since Joe Martin's comments indicated that locking style isn't
used at all any more (didn't think so, but he confirmed it).

The new changes are in Alpha's smp.c and smp.h.

Summary of changes (read previous patch for detail on previous changes):
Makefile - compress more
core_apecs.c - sched.h needed
proto.h - corrects smp_info prototype
smplock.h - sched.h needed
interrupt.h - ptrace.h needed
softirq.h - stddef.h needed
smp.h - need to declare smp_message_pass() here
removed unused klock_* data types and constants
smp.c - removed unused klock_* references, and debug_kernel_lock()
function which was tied to the non-existent klock_*
implementation

Jeff

P.S. If noone else objects, hopefully these patches can be integrated
into 2.1.x/2.2.x. Linux/Alpha is awful when SMP=1 ;) Is anyone
actively maintaining the Alpha stuff?

diff -r -c -b linux-2.1.119/arch/alpha/boot/Makefile linux/arch/alpha/boot/Makefile
*** linux-2.1.119/arch/alpha/boot/Makefile Mon Jan 12 17:51:14 1998
--- linux/arch/alpha/boot/Makefile Fri Sep 4 12:25:09 1998
***************
*** 56,62 ****
@test "$(BOOTDEV)" != "" || (echo You must specify BOOTDEV ; exit -1)

vmlinux.gz: vmlinux
! gzip -fv vmlinux

#
# A raw binary without header. Used by raw boot.
--- 56,62 ----
@test "$(BOOTDEV)" != "" || (echo You must specify BOOTDEV ; exit -1)

vmlinux.gz: vmlinux
! gzip -fv9 vmlinux

#
# A raw binary without header. Used by raw boot.
diff -r -c -b linux-2.1.119/arch/alpha/kernel/core_apecs.c linux/arch/alpha/kernel/core_apecs.c
*** linux-2.1.119/arch/alpha/kernel/core_apecs.c Sun Aug 9 15:09:05 1998
--- linux/arch/alpha/kernel/core_apecs.c Fri Sep 4 12:25:09 1998
***************
*** 14,19 ****
--- 14,20 ----
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/init.h>
+ #include <linux/sched.h>

#include <asm/system.h>
#include <asm/ptrace.h>
diff -r -c -b linux-2.1.119/arch/alpha/kernel/proto.h linux/arch/alpha/kernel/proto.h
*** linux-2.1.119/arch/alpha/kernel/proto.h Sun Aug 9 15:09:05 1998
--- linux/arch/alpha/kernel/proto.h Fri Sep 4 12:25:09 1998
***************
*** 92,98 ****

/* smp.c */
extern void setup_smp(void);
! extern char *smp_info(void);
extern void handle_ipi(struct pt_regs *);

/* bios32.c */
--- 92,98 ----

/* smp.c */
extern void setup_smp(void);
! extern int smp_info(char *buffer);
extern void handle_ipi(struct pt_regs *);

/* bios32.c */
diff -r -c -b linux-2.1.119/arch/alpha/kernel/smp.c linux/arch/alpha/kernel/smp.c
*** linux-2.1.119/arch/alpha/kernel/smp.c Sun Aug 9 15:09:05 1998
--- linux/arch/alpha/kernel/smp.c Fri Sep 4 13:01:03 1998
***************
*** 30,39 ****

struct cpuinfo_alpha cpu_data[NR_CPUS];

- /* Processor holding kernel spinlock */
- klock_info_t klock_info = { KLOCK_CLEAR, 0 };
-
spinlock_t ticker_lock = SPIN_LOCK_UNLOCKED;

unsigned int boot_cpu_id = 0;
static int smp_activated = 0;
--- 30,37 ----

struct cpuinfo_alpha cpu_data[NR_CPUS];

spinlock_t ticker_lock = SPIN_LOCK_UNLOCKED;
+ spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED;

unsigned int boot_cpu_id = 0;
static int smp_activated = 0;
***************
*** 198,204 ****
cpu_number_map[boot_cpu_id] = 0;
cpu_logical_map[0] = boot_cpu_id;
current->processor = boot_cpu_id; /* ??? */
- klock_info.akp = boot_cpu_id;

smp_store_cpu_info(boot_cpu_id);
#ifdef NOT_YET
--- 196,201 ----
***************
*** 739,747 ****

int smp_info(char *buffer)
{
! return sprintf(buffer, "CPUs probed %d active %d map 0x%x AKP %d\n",
! smp_num_probed, smp_num_cpus, cpu_present_map,
! klock_info.akp);
}

/* wrapper for call from panic() */
--- 736,743 ----

int smp_info(char *buffer)
{
! return sprintf(buffer, "CPUs probed %d active %d map 0x%x\n",
! smp_num_probed, smp_num_cpus, cpu_present_map);
}

/* wrapper for call from panic() */
***************
*** 766,777 ****
unsigned int to_whom = cpu_present_map ^ (1 << smp_processor_id());
int timeout = 10000;

- #if 1
- if (!kernel_lock_held()) {
- printk("flush_tlb_all: kernel_flag %d (cpu %d akp %d)!\n",
- klock_info.kernel_flag, smp_processor_id(), klock_info.akp);
- }
- #endif
ipi_msg_flush_tb.flush_tb_mask = to_whom;
send_ipi_message(to_whom, TLB_ALL);
tbia();
--- 762,767 ----
***************
*** 794,805 ****
unsigned int to_whom = cpu_present_map ^ (1 << smp_processor_id());
int timeout = 10000;

- #if 1
- if (!kernel_lock_held()) {
- printk("flush_tlb_mm: kernel_flag %d (cpu %d akp %d)!\n",
- klock_info.kernel_flag, smp_processor_id(), klock_info.akp);
- }
- #endif
ipi_msg_flush_tb.p.flush_mm = mm;
ipi_msg_flush_tb.flush_tb_mask = to_whom;
send_ipi_message(to_whom, TLB_MM);
--- 784,789 ----
***************
*** 829,840 ****
struct mm_struct * mm = vma->vm_mm;
int timeout = 10000;

- #if 1
- if (!kernel_lock_held()) {
- printk("flush_tlb_page: kernel_flag %d (cpu %d akp %d)!\n",
- klock_info.kernel_flag, cpu, klock_info.akp);
- }
- #endif
ipi_msg_flush_tb.p.flush_vma = vma;
ipi_msg_flush_tb.flush_addr = addr;
ipi_msg_flush_tb.flush_tb_mask = to_whom;
--- 813,818 ----
***************
*** 847,855 ****

while (ipi_msg_flush_tb.flush_tb_mask) {
if (--timeout < 0) {
! printk("flush_tlb_page: STUCK on CPU %d [0x%x,0x%lx,%d,%d]\n",
cpu, ipi_msg_flush_tb.flush_tb_mask, addr,
! klock_info.akp, global_irq_holder);
ipi_msg_flush_tb.flush_tb_mask = 0;
break;
}
--- 825,833 ----

while (ipi_msg_flush_tb.flush_tb_mask) {
if (--timeout < 0) {
! printk("flush_tlb_page: STUCK on CPU %d [0x%x,0x%lx,%d]\n",
cpu, ipi_msg_flush_tb.flush_tb_mask, addr,
! global_irq_holder);
ipi_msg_flush_tb.flush_tb_mask = 0;
break;
}
***************
*** 873,885 ****
timeout = 10000;
to_whom = cpu_present_map ^ (1 << smp_processor_id());

- #if 1
- if (!kernel_lock_held()) {
- printk("flush_tlb_range: kernel_flag %d (cpu %d akp %d) @ 0x%lx\n",
- klock_info.kernel_flag, smp_processor_id(), klock_info.akp,
- where);
- }
- #endif
ipi_msg_flush_tb.p.flush_mm = mm;
ipi_msg_flush_tb.flush_tb_mask = to_whom;
send_ipi_message(to_whom, TLB_MM);
--- 851,856 ----
***************
*** 902,954 ****
#endif
}

- #ifdef DEBUG_KERNEL_LOCK
- void ___lock_kernel(klock_info_t *klip, int cpu, long ipl)
- {
- long regx;
- int stuck_lock;
- unsigned long inline_pc;
-
- __asm__("mov $26, %0" : "=r" (inline_pc));
-
- try_again:
-
- stuck_lock = 1<<26;
-
- __asm__ __volatile__(
- "1: ldl_l %1,%0;"
- " blbs %1,6f;"
- " or %1,1,%1;"
- " stl_c %1,%0;"
- " beq %1,6f;"
- "4: mb\n"
- ".section .text2,\"ax\"\n"
- "6: mov %5,$16;"
- " call_pal %4;"
- "7: ldl %1,%0;"
- " blt %2,4b # debug\n"
- " subl %2,1,%2 # debug\n"
- " blbs %1,7b;"
- " bis $31,7,$16;"
- " call_pal %4;"
- " br 1b\n"
- ".previous"
- : "=m,=m" (__dummy_lock(klip)), "=&r,=&r" (regx),
- "=&r,=&r" (stuck_lock)
- : "0,0" (__dummy_lock(klip)), "i,i" (PAL_swpipl),
- "i,r" (ipl), "2,2" (stuck_lock)
- : "$0", "$1", "$16", "$22", "$23", "$24", "$25", "memory");
-
- if (stuck_lock < 0) {
- printk("___kernel_lock stuck at %lx(%d) held %lx(%d)\n",
- inline_pc, cpu, klip->pc, klip->cpu);
- goto try_again;
- } else {
- klip->pc = inline_pc;
- klip->cpu = cpu;
- }
- }
- #endif

#ifdef DEBUG_SPINLOCK
void spin_lock(spinlock_t * lock)
--- 873,878 ----
diff -r -c -b linux-2.1.119/include/asm-alpha/smp.h linux/include/asm-alpha/smp.h
*** linux-2.1.119/include/asm-alpha/smp.h Thu Aug 6 15:02:49 1998
--- linux/include/asm-alpha/smp.h Fri Sep 4 12:58:52 1998
***************
*** 15,32 ****

extern struct cpuinfo_alpha cpu_data[NR_CPUS];

- typedef volatile struct {
- unsigned int kernel_flag; /* 4 bytes, please */
- unsigned int akp; /* 4 bytes, please */
- unsigned long pc;
- unsigned int cpu;
- } klock_info_t;
-
- extern klock_info_t klock_info;
-
- #define KLOCK_HELD 0xff
- #define KLOCK_CLEAR 0x00
-
extern int task_lock_depth;

#define PROC_CHANGE_PENALTY 20
--- 15,20 ----
***************
*** 47,52 ****
--- 35,43 ----

#define smp_processor_id() hard_smp_processor_id()
#define cpu_logical_map(cpu) (cpu)
+
+ /* smp.c */
+ extern void smp_message_pass(int target, int msg, unsigned long data, int wait);

#endif /* __SMP__ */

diff -r -c -b linux-2.1.119/include/asm-alpha/smplock.h linux/include/asm-alpha/smplock.h
*** linux-2.1.119/include/asm-alpha/smplock.h Mon Aug 3 15:28:20 1998
--- linux/include/asm-alpha/smplock.h Fri Sep 4 14:30:52 1998
***************
*** 4,9 ****
--- 4,10 ----
* Default SMP lock implementation
*/
#include <linux/interrupt.h>
+ #include <linux/sched.h>
#include <asm/spinlock.h>

extern spinlock_t kernel_flag;
diff -r -c -b linux-2.1.119/include/asm-alpha/softirq.h linux/include/asm-alpha/softirq.h
*** linux-2.1.119/include/asm-alpha/softirq.h Mon Mar 30 03:21:41 1998
--- linux/include/asm-alpha/softirq.h Fri Sep 4 13:01:51 1998
***************
*** 1,6 ****
--- 1,7 ----
#ifndef _ALPHA_SOFTIRQ_H
#define _ALPHA_SOFTIRQ_H

+ #include <linux/stddef.h>
#include <asm/atomic.h>
#include <asm/hardirq.h>

diff -r -c -b linux-2.1.119/include/linux/interrupt.h linux/include/linux/interrupt.h
*** linux-2.1.119/include/linux/interrupt.h Wed Aug 26 18:00:39 1998
--- linux/include/linux/interrupt.h Fri Sep 4 13:01:51 1998
***************
*** 3,8 ****
--- 3,9 ----
#define _LINUX_INTERRUPT_H

#include <linux/kernel.h>
+ #include <linux/ptrace.h>
#include <asm/bitops.h>
#include <asm/atomic.h>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/faq.html