Skip to contentSkip to conversation

x86: unify genapic code, unify subarchitectures, remove old subarchitecture code

DISCUSSION James Bottomley 3 participants 5 messages Feb 8, 2009 – Feb 22, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 6 lines

I ported the NUMAQ / Summit / bigsmp and ES7000 subarchitectures to the new setup. They build and boot on regular hardware but are otherwise untested. The x86/Voyager subarch is not fully ported yet (i cleaned up its Kconfig impact) and hence disabled it for the time being. It ought to be relatively straightforward to port it to the new code.

OK, so I analysed the voyager requirements.

The first simple one is that safe_smp_processor_id() and hard_smp_processor_id() need to be abstracted, probably through smp_ops. This one is probably trivial since 99% of the price of doing this has already been paid in the smp ops.

The other big problem is mm/tlb.c. This directly uses genapic with 8 vectors which is impossible for voyager: the QIC only has 8 separate IPI vectors for everything. The two alternatives which spring to mind are either to rebase mm/tlb.c on top of smp_call_function. This would add a small amount to the critical path, but would also allow vector scaling beyond the current 8 IPI vectors to a per processor number (i.e. might scale better beyond 8 cores). Or to keep voyager separate and move pieces of paravirt ops (or rather a separated piece of pv_ops) into smp_ops to effect the separation. Instinct says to try the former first.

James

#1 lore raw
Quoted 7 lines · James Bottomley

The other big problem is mm/tlb.c. This directly uses genapic with 8 vectors which is impossible for voyager: the QIC only has 8 separate IPI vectors for everything. The two alternatives which spring to mind are either to rebase mm/tlb.c on top of smp_call_function. This would add a small amount to the critical path, but would also allow vector scaling beyond the current 8 IPI vectors to a per processor number (i.e. might scale better beyond 8 cores).

I floated an experimental patch to do just that last year. There were concerns because it had a pretty significantly hit on the performance of tlb-heavy benchmarks; and since then a multicast smp_call_function ends up kmallocing, which probably won't help matters. I got called away to other things before really exploring all the options here, so it may well be worth reviving that work.

Quoted 3 lines

Or to keep voyager separate and move
pieces of paravirt ops (or rather a separated piece of pv_ops) into smp_ops to effect the separation.

This should be easy since you can can hook all the tlb operations via pv_mmu_ops. And to avoid duplicating a lot of similar-looking code, you could just do a generic smp_call_function-based version.

J

#2 lore raw
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 7 lines · James Bottomley

The other big problem is mm/tlb.c. This directly uses genapic with 8 vectors which is impossible for voyager: the QIC only has 8 separate IPI vectors for everything. The two alternatives which spring to mind are either to rebase mm/tlb.c on top of smp_call_function. This would add a small amount to the critical path, but would also allow vector scaling beyond the current 8 IPI vectors to a per processor number (i.e. might scale better beyond 8 cores).

Quoted 4 lines

I floated an experimental patch to do just that last year. There were concerns because it had a pretty significantly hit on the performance of tlb-heavy benchmarks; and since then a multicast smp_call_function ends up kmallocing, which probably won't help matters.

Agree this is a nasty problem. However, I can't see any reason why
smp_call_function_many() needs to allocate in the wait case ... and the tlb flushing code would be using the wait case. What about this fix to the generic SMP code (cc'd Jens) that would allow us to take on stack data and the fast path all the time?

By the way, I can see us building up stack runoff danger for the large CPU machines, so the on stack piece could be limited to a maximal CPU cap beyond which it has to kmalloc ... the large CPU machines would still probably pick up scaling benefits in that case ... thoughts?

Quoted 11 lines

I got called away to
other things before really exploring all the options here, so it may well be worth reviving that work.

Quoted 3 lines

Or to keep voyager separate and move
pieces of paravirt ops (or rather a separated piece of pv_ops) into smp_ops to effect the separation.

This should be easy since you can can hook all the tlb operations via pv_mmu_ops. And to avoid duplicating a lot of similar-looking code, you could just do a generic smp_call_function-based version.

Yes ... will do. If we can't make the unified non-IPI version work fast enough, then both of us can share the call function version.

James

---

kernel/smp.c +8 -1
index 5cfa0e5..ca58ca3 100644
@@ -294,6 +294,10 @@ void smp_call_function_many(const struct cpumask *mask,
 	struct call_function_data *data;
 	unsigned long flags;
 	int cpu, next_cpu;
+	struct {
+		struct call_function_data d;
+		unsigned long c[BITS_TO_LONGS(NR_CPUS)];
+	} stack_data;
 
 	/* Can deadlock when called with interrupts disabled */
 	WARN_ON(irqs_disabled());
@@ -317,7 +321,10 @@ void smp_call_function_many(const struct cpumask *mask,
 		return;
 	}
 
-	data = kmalloc(sizeof(*data) + cpumask_size(), GFP_ATOMIC);
+	if (wait)
+		data = &stack_data.d;
+	else
+		data = kmalloc(sizeof(*data) + cpumask_size(), GFP_ATOMIC);
 	if (unlikely(!data)) {
 		/* Slow path. */
 		for_each_online_cpu(cpu) {
#3 lore raw
Quoted 6 lines · James Bottomley

Agree this is a nasty problem. However, I can't see any reason why
smp_call_function_many() needs to allocate in the wait case ... and the tlb flushing code would be using the wait case. What about this fix to the generic SMP code (cc'd Jens) that would allow us to take on stack data and the fast path all the time?

That's how it used to be, but there's a subtle race. When using allocated list elements, the lifetime of the allocated blocks is managed via rcu. When an element is deleted with list_del_rcu(), another cpu can still be using its ->next pointer, and so the memory for that list entry can't be freed early. If it is stack-allocated, then the memory will get re-allocated when the calling function returns, which will trash the ->next pointer that another cpu is still relying on.

Quoted 5 lines

By the way, I can see us building up stack runoff danger for the large CPU machines, so the on stack piece could be limited to a maximal CPU cap beyond which it has to kmalloc ... the large CPU machines would still probably pick up scaling benefits in that case ... thoughts?

It looks like Peter Z just posted some patches to remove kmalloc from this path ("generic smp helpers vs kmalloc"). Ah, he's addressed the point above:

Also, since we cannot simply remove an item from the global queue (another
cpu might be observing it), a quiesence of sorts needs to be observed. The
current code uses regular RCU for that purpose.

However, since we'll be wanting to quickly reuse an item, we need something
with a much faster turn-around. We do this by simply observing the global
queue quiesence. Since there are a limited number of elements, it will auto
force a quiecent state if we wait for it.

(Haven't read the patches in detail yet.)

Quoted 3 lines

Yes ... will do. If we can't make the unified non-IPI version work fast enough, then both of us can share the call function version.

Xen does cross-cpu tlb flush via hypercall, because Xen knows which real CPUs (if any) have stale vcpu tlb state (there's no point scheduling a non-running vcpu just to flush its tlb).

J

kernel/smp.c void smp_call_function_many(const struct cpumask *mask, · line 327

Quoted 6 lines
kernel/smp.c +4 -1
-	data = kmalloc(sizeof(*data) + cpumask_size(), GFP_ATOMIC);
+	if (wait)
+		data = &stack_data.d;
+	else
+		data = kmalloc(sizeof(*data) + cpumask_size(), GFP_ATOMIC);

You're still leaving CSD_FLAG_ALLOC set?

Quoted 5 lines
kernel/smp.c +0 -0
 	if (unlikely(!data)) {
 		/* Slow path. */
 		for_each_online_cpu(cpu) {
#4 lore raw
In reply to James Bottomley
Quoted 14 lines · James Bottomley
Quoted 6 lines

I ported the NUMAQ / Summit / bigsmp and ES7000 subarchitectures to the new setup. They build and boot on regular hardware but are otherwise untested. The x86/Voyager subarch is not fully ported yet (i cleaned up its Kconfig impact) and hence disabled it for the time being. It ought to be relatively straightforward to port it to the new code.

OK, so I analysed the voyager requirements.

The first simple one is that safe_smp_processor_id() and hard_smp_processor_id() need to be abstracted, probably through smp_ops. This one is probably trivial since 99% of the price of doing this has already been paid in the smp ops.

Quoted 11 lines

The other big problem is mm/tlb.c. This directly uses genapic with 8 vectors which is impossible for voyager: the QIC only has 8 separate IPI vectors for everything. The two alternatives which spring to mind are either to rebase mm/tlb.c on top of smp_call_function. This would add a small amount to the critical path, but would also allow vector scaling beyond the current 8 IPI vectors to a per processor number (i.e. might scale better beyond 8 cores). Or to keep voyager separate and move pieces of paravirt ops (or rather a separated piece of pv_ops) into smp_ops to effect the separation. Instinct says to try the former first.

Ping - it's been two weeks now and i havent gotten any patches from you and Voyager is still broken in the latest x86 development tree.

So we've queued up the patch below for now which removes the Voyager subarch code. Let us know if you have any patches to look at.

Thanks,

Ingo

-------------->

Quoted 1 line

From 965c7ecaf2e2b083d711a01ab33735a4bdeee1a4 Mon Sep 17 00:00:00 2001

From: Ingo Molnar <[email protected]>
Date: Sun, 22 Feb 2009 23:19:12 +0100
Subject: [PATCH] x86: remove the Voyager 32-bit subarch

Impact: remove unused/broken code

The Voyager subarch last built successfully on the v2.6.26 kernel and has been stale since then and does not build on the v2.6.27, v2.6.28 and v2.6.29-rc5 kernels.

No actual users beyond the maintainer reported this breakage. Patches were sent and most of the fixes were accepted but the discussion around how to do a few remaining issues cleanly fizzled out with no resolution and the code remained broken.

In the v2.6.30 x86 tree development cycle 32-bit subarch support has been reworked and removed - and the Voyager code, beyond the build problems already known, needs serious and significant changes and probably a rewrite to support it.

CONFIG_X86_VOYAGER has been marked BROKEN then. The maintainer has been notified but no patches have been sent so far to fix it.

While all other subarchs have been converted to the new scheme, voyager is still broken. We'd prefer to receive patches which clean up the current situation in a constructive way, but even in case of removal there is no obstacle to add that support back after the issues have been sorted out in a mutually acceptable fashion.

So remove this inactive code for now.

---
 arch/x86/Kconfig                               |   14 -
 arch/x86/boot/Makefile                         |    1 -
 arch/x86/boot/a20.c                            |    6 -
 arch/x86/boot/boot.h                           |    3 -
 arch/x86/boot/main.c                           |    5 -
 arch/x86/boot/voyager.c                        |   40 -
 arch/x86/configs/i386_defconfig                |    1 -
 arch/x86/configs/x86_64_defconfig              |    1 -
 arch/x86/include/asm/mach-voyager/do_timer.h   |   17 -
 arch/x86/include/asm/mach-voyager/entry_arch.h |   26 -
 arch/x86/include/asm/mach-voyager/setup_arch.h |   12 -
 arch/x86/include/asm/vic.h                     |   61 -
 arch/x86/include/asm/voyager.h                 |  571 --------
 arch/x86/lguest/Kconfig                        |    1 -
 arch/x86/mach-voyager/Makefile                 |    8 -
 arch/x86/mach-voyager/setup.c                  |  119 --
 arch/x86/mach-voyager/voyager_basic.c          |  317 -----
 arch/x86/mach-voyager/voyager_cat.c            | 1197 ----------------
 arch/x86/mach-voyager/voyager_smp.c            | 1805 ------------------------
 arch/x86/mach-voyager/voyager_thread.c         |  128 --
 arch/x86/xen/Kconfig                           |    2 +-
 drivers/lguest/Kconfig                         |    2 +-
 22 files changed, 2 insertions(+), 4335 deletions(-)
arch/x86/Kconfig +0 -14
index 35efba5..5e2919c 100644
@@ -302,7 +302,6 @@ config X86_EXTENDED_PLATFORM
 		SGI 320/540 (Visual Workstation)
 		Summit/EXA (IBM x440)
 		Unisys ES7000 IA32 series
-		Voyager (NCR)
 
 	  If you have one of these systems, or if you want to build a
 	  generic distribution kernel, say Y here - otherwise say N.
@@ -423,19 +422,6 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
-config X86_VOYAGER
-	bool "Voyager (NCR)"
-	depends on SMP && !PCI && BROKEN
-	depends on X86_32_NON_STANDARD
-	---help---
-	  Voyager is an MCA-based 32-way capable SMP architecture proprietary
-	  to NCR Corp.  Machine classes 345x/35xx/4100/51xx are Voyager-based.
-
-	  *** WARNING ***
-
-	  If you do not specifically know you have a Voyager based machine,
-	  say N here, otherwise the kernel you build will not be bootable.
-
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
arch/x86/boot/Makefile +0 -1
index cd48c72..c70eff6 100644
@@ -32,7 +32,6 @@ setup-y		+= a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o
 setup-y		+= header.o main.o mca.o memory.o pm.o pmjump.o
 setup-y		+= printf.o string.o tty.o video.o video-mode.o version.o
 setup-$(CONFIG_X86_APM_BOOT) += apm.o
-setup-$(CONFIG_X86_VOYAGER) += voyager.o
 
 # The link order of the video-*.o modules can matter.  In particular,
 # video-vga.o *must* be listed first, followed by video-vesa.o.
arch/x86/boot/a20.c +0 -6
index fba8e9c..7c19ce8 100644
@@ -126,11 +126,6 @@ static void enable_a20_fast(void)
 
 int enable_a20(void)
 {
-#ifdef CONFIG_X86_VOYAGER
-	/* On Voyager, a20_test() is unsafe? */
-	enable_a20_kbc();
-	return 0;
-#else
        int loops = A20_ENABLE_LOOPS;
        int kbc_err;
 
@@ -164,5 +159,4 @@ int enable_a20(void)
        }
        
        return -1;
-#endif
 }
arch/x86/boot/boot.h +0 -3
index cc0ef13..7b2692e 100644
@@ -302,9 +302,6 @@ void probe_cards(int unsafe);
 /* video-vesa.c */
 void vesa_store_edid(void);
 
-/* voyager.c */
-int query_voyager(void);
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* BOOT_BOOT_H */
arch/x86/boot/main.c +0 -5
index 197421d..58f0415 100644
@@ -149,11 +149,6 @@ void main(void)
 	/* Query MCA information */
 	query_mca();
 
-	/* Voyager */
-#ifdef CONFIG_X86_VOYAGER
-	query_voyager();
-#endif
-
 	/* Query Intel SpeedStep (IST) information */
 	query_ist();
 
arch/x86/boot/voyager.c deleted +0 -40
deleted file mode 100644
index 433909d..0000000
@@ -1,40 +0,0 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
- *
- *   Copyright (C) 1991, 1992 Linus Torvalds
- *   Copyright 2007 rPath, Inc. - All Rights Reserved
- *
- *   This file is part of the Linux kernel, and is made available under
- *   the terms of the GNU General Public License version 2.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * Get the Voyager config information
- */
-
-#include "boot.h"
-
-int query_voyager(void)
-{
-	u8 err;
-	u16 es, di;
-	/* Abuse the apm_bios_info area for this */
-	u8 *data_ptr = (u8 *)&boot_params.apm_bios_info;
-
-	data_ptr[0] = 0xff;	/* Flag on config not found(?) */
-
-	asm("pushw %%es ; "
-	    "int $0x15 ; "
-	    "setc %0 ; "
-	    "movw %%es, %1 ; "
-	    "popw %%es"
-	    : "=q" (err), "=r" (es), "=D" (di)
-	    : "a" (0xffc0));
-
-	if (err)
-		return -1;	/* Not Voyager */
-
-	set_fs(es);
-	copy_from_fs(data_ptr, di, 7);	/* Table is 7 bytes apparently */
-	return 0;
-}
arch/x86/configs/i386_defconfig +0 -1
index 096dd53..5c023f6 100644
@@ -197,7 +197,6 @@ CONFIG_SPARSE_IRQ=y
 CONFIG_X86_FIND_SMP_CONFIG=y
 CONFIG_X86_MPPARSE=y
 # CONFIG_X86_ELAN is not set
-# CONFIG_X86_VOYAGER is not set
 # CONFIG_X86_GENERICARCH is not set
 # CONFIG_X86_VSMP is not set
 # CONFIG_X86_RDC321X is not set
arch/x86/configs/x86_64_defconfig +0 -1
index 2efb5d5..4157cc4 100644
@@ -199,7 +199,6 @@ CONFIG_SPARSE_IRQ=y
 CONFIG_X86_FIND_SMP_CONFIG=y
 CONFIG_X86_MPPARSE=y
 # CONFIG_X86_ELAN is not set
-# CONFIG_X86_VOYAGER is not set
 # CONFIG_X86_GENERICARCH is not set
 # CONFIG_X86_VSMP is not set
 CONFIG_SCHED_OMIT_FRAME_POINTER=y
arch/x86/include/asm/mach-voyager/do_timer.h deleted +0 -17
deleted file mode 100644
index 9e5a459..0000000
@@ -1,17 +0,0 @@
-/* defines for inline arch setup functions */
-#include <linux/clockchips.h>
-
-#include <asm/voyager.h>
-#include <asm/i8253.h>
-
-/**
- * do_timer_interrupt_hook - hook into timer tick
- *
- * Call the pit clock event handler. see asm/i8253.h
- **/
-static inline void do_timer_interrupt_hook(void)
-{
-	global_clock_event->event_handler(global_clock_event);
-	voyager_timer_interrupt();
-}
-
arch/x86/include/asm/mach-voyager/entry_arch.h deleted +0 -26
deleted file mode 100644
index ae52624..0000000
@@ -1,26 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8 -*- */
-
-/* Copyright (C) 2002
- *
- * Author: [email protected]
- *
- * linux/arch/i386/voyager/entry_arch.h
- *
- * This file builds the VIC and QIC CPI gates
- */
-
-/* initialise the voyager interrupt gates 
- *
- * This uses the macros in irq.h to set up assembly jump gates.  The
- * calls are then redirected to the same routine with smp_ prefixed */
-BUILD_INTERRUPT(vic_sys_interrupt, VIC_SYS_INT)
-BUILD_INTERRUPT(vic_cmn_interrupt, VIC_CMN_INT)
-BUILD_INTERRUPT(vic_cpi_interrupt, VIC_CPI_LEVEL0);
-
-/* do all the QIC interrupts */
-BUILD_INTERRUPT(qic_timer_interrupt, QIC_TIMER_CPI);
-BUILD_INTERRUPT(qic_invalidate_interrupt, QIC_INVALIDATE_CPI);
-BUILD_INTERRUPT(qic_reschedule_interrupt, QIC_RESCHEDULE_CPI);
-BUILD_INTERRUPT(qic_enable_irq_interrupt, QIC_ENABLE_IRQ_CPI);
-BUILD_INTERRUPT(qic_call_function_interrupt, QIC_CALL_FUNCTION_CPI);
-BUILD_INTERRUPT(qic_call_function_single_interrupt, QIC_CALL_FUNCTION_SINGLE_CPI);
arch/x86/include/asm/mach-voyager/setup_arch.h deleted +0 -12
deleted file mode 100644
index 71729ca..0000000
@@ -1,12 +0,0 @@
-#include <asm/voyager.h>
-#include <asm/setup.h>
-#define VOYAGER_BIOS_INFO ((struct voyager_bios_info *) \
-			(&boot_params.apm_bios_info))
-
-/* Hook to call BIOS initialisation function */
-
-/* for voyager, pass the voyager BIOS/SUS info area to the detection
- * routines */
-
-#define ARCH_SETUP	voyager_detect(VOYAGER_BIOS_INFO);
-
arch/x86/include/asm/vic.h deleted +0 -61

61 lines not on this page · raw message

arch/x86/include/asm/voyager.h deleted +0 -571

571 lines not on this page · raw message

arch/x86/lguest/Kconfig +0 -1
index c70e12b..8dab8f7 100644
@@ -3,7 +3,6 @@ config LGUEST_GUEST
 	select PARAVIRT
 	depends on X86_32
 	depends on !X86_PAE
-	depends on !X86_VOYAGER
 	select VIRTIO
 	select VIRTIO_RING
 	select VIRTIO_CONSOLE
arch/x86/mach-voyager/Makefile deleted +0 -8
deleted file mode 100644
index 15c250b..0000000
@@ -1,8 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-EXTRA_CFLAGS	:= -Iarch/x86/kernel
-obj-y			:= setup.o voyager_basic.o voyager_thread.o
-
-obj-$(CONFIG_SMP)	+= voyager_smp.o voyager_cat.o
arch/x86/mach-voyager/setup.c deleted +0 -119

119 lines not on this page · raw message

arch/x86/mach-voyager/voyager_basic.c deleted +0 -317

317 lines not on this page · raw message

arch/x86/mach-voyager/voyager_cat.c deleted +0 -1197

1,197 lines not on this page · raw message

arch/x86/mach-voyager/voyager_smp.c deleted +0 -1805

542 lines not on this page · raw message

arch/x86/mach-voyager/voyager_thread.c deleted +0 -128

128 lines not on this page · raw message

arch/x86/xen/Kconfig +1 -1
index 87b9ab1..b83e119 100644

Lines of this file are not shown. View the raw message.

drivers/lguest/Kconfig +1 -1
index 76f2b36..a3d3cba 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.