[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#589579: debian-installer: i386 kernel flavour selection is poor



Package: debian-installer
Tags: squeeze patch

There are several problems with the current selection:
1. 686-bigmem is not preferred when there is RAM above 4GB
2. 686-bigmem is not always offered where it is usable, and amd64 is
never offered
3. The 686 flavour is considered unsuitable for some AMD K7 processors

Problem 3 appears to be due to a workaround for an incorrect kernel
configuration.  The comment on this exclusion is 'May not have SSE
support', but this has never been a requirement for the 686 flavour.
(The Pentium Pro and Pentium II don't have SSE either.)

This patch rewrites the flavour selection so that:
1. 686-bigmem is preferred when there is RAM above 4GB, otherwise 686 is
preferred
2. All usable flavours are offered
3. The 686 flavour is considered suitable for all K7 processors

It updates the tests accordingly, adding amd64 to the usable/unusable
flavours lists and adding a test case for RAM above 4GB.

Ben.

Index: packages/base-installer/kernel/i386.sh
===================================================================
--- packages/base-installer/kernel/i386.sh	(revision 63990)
+++ packages/base-installer/kernel/i386.sh	(working copy)
@@ -1,45 +1,94 @@
 arch_get_kernel_flavour () {
-	VENDOR=`grep '^vendor_id' "$CPUINFO" | head -n1 | cut -d: -f2`
-	FAMILY=`grep '^cpu family' "$CPUINFO" | head -n1 | cut -d: -f2`
-	MODEL=`grep '^model[[:space:]]*:' "$CPUINFO" | head -n1 | cut -d: -f2`
+	# Should we offer an amd64 kernel?
+	local HAVE_LM
+	if grep -q '^flags.*\blm\b' "$CPUINFO"; then
+		HAVE_LM=y
+	else
+		HAVE_LM=n
+	fi
 
-	# Only offer bigmem if the system supports PAE and the
-	# installer itself is already using a bigmem kernel.
-	if grep '^flags' "$CPUINFO" | grep -q pae ; then
-	    case "$KERNEL_FLAVOUR" in
-		686-bigmem*) BIGMEM="-bigmem" ;;
-		*) ;;
-	    esac
+	# Should we offer a bigmem kernel?
+	local HAVE_PAE
+	if grep -q '^flags.*\bpae\b' "$CPUINFO"; then
+		HAVE_PAE=y
+	else
+		HAVE_PAE=n
 	fi
 
+	# Should we prefer a bigmem/amd64 kernel - is there RAM above 4GB?
+	local WANT_PAE
+	if [ -z "$RAM_END" ]; then
+		local MAP MAP_END
+		RAM_END=0
+		for MAP in /sys/firmware/memmap/* ; do
+			if [ "$(cat $MAP/type)" = "System RAM" ]; then
+				MAP_END="$(cat $MAP/end)"
+				if [ $(($MAP_END > $RAM_END)) = 1 ]; then
+					RAM_END=$MAP_END
+				fi
+			fi
+		done
+	fi
+	if [ $(($RAM_END > 0x100000000)) = 1 ]; then
+		WANT_PAE=y
+	else
+		WANT_PAE=n
+	fi
+	# or is the installer running a 686-bigmem kernel?
+	case "$KERNEL_FLAVOUR" in
+	    686-bigmem*)
+		WANT_PAE=y
+		;;
+	esac
+
+	case "$HAVE_LM$HAVE_PAE$WANT_PAE" in
+	    yyy)
+		echo 686-bigmem amd64 686 486
+		return 0
+		;;
+	    yyn)
+		echo 686 686-bigmem amd64 486
+		return 0
+		;;
+	    yn?)
+		warning "Processor with LM but no PAE???"
+		;;
+	    nyy)
+		echo 686-bigmem 686 486
+		return 0
+		;;
+	    nyn)
+		echo 686 686-bigmem 486
+		return 0
+		;;
+	    nn?)
+		# Need to check whether 686 is suitable
+		;;
+	esac
+
+	local VENDOR FAMILY MODEL
+	VENDOR=$(sed -n 's/^vendor_id\s*: //; T; p; q' "$CPUINFO")
+	FAMILY=$(sed -n 's/^cpu family\s*: //; T; p; q' "$CPUINFO")
+	MODEL=$(sed -n 's/^model\s*: //; T; p; q' "$CPUINFO")
+
 	case "$VENDOR" in
-	    " AuthenticAMD"*)
+	    AuthenticAMD*)
 		case "$FAMILY" in
-		    " 15"|" 16"|" 17")			# k8
-			echo 686$BIGMEM
-			;;
-		    " 6")				# k7
-			case "$MODEL" in
-			    " 0"|" 1"|" 2"|" 3"|" 4"|" 5")
-				# May not have SSE support
-				echo 486 ;;
-			    *)	echo 686$BIGMEM ;;
-			esac
-			;;
+		    6|15|16|17)	echo 686 486 ;;
 		    *)		echo 486 ;;
 		esac
 		;;
-	    " GenuineIntel")
+	    GenuineIntel)
 		case "$FAMILY" in
-		    " 6"|" 15")	echo 686$BIGMEM ;;
+		    6|15)	echo 686 486 ;;
 		    *)		echo 486 ;;
 		esac
 		;;
-	    " CentaurHauls")
+	    CentaurHauls)
 		case "$FAMILY" in
-		    " 6")
+		    6)
 			case "$MODEL" in
-			    " 9"|" 10")	echo 686$BIGMEM ;;
+			    9|10)	echo 686 486 ;;
 			    *)		echo 486 ;;
 			esac
 			;;
@@ -53,30 +102,34 @@
 	return 0
 }
 
-# Note: the -k7 flavor has been dropped with linux-2.6 (2.6.23-1)
-
 arch_check_usable_kernel () {
-	if echo "$1" | grep -Eq -- "-486(-.*)?$"; then return 0; fi
-	if [ "$2" = 486 ]; then return 1; fi
-	if echo "$1" | grep -Eq -- "-686(-.*)?$"; then return 0; fi
-	if [ "$2" = 686 ] || [ "$2" = 686-bigmem ]; then return 1; fi
+	local NAME="$1"
 
-	# default to usable in case of strangeness
-	warning "Unknown kernel usability: $1 / $2"
-	return 0
+	set -- $2
+	while [ $# -ge 1 ]; do
+		case "$NAME" in
+		    *-"$1")
+			return 0;
+			;;
+		    *-"$1"-bigmem*)
+			# Don't allow -bigmem suffix
+			;;
+		    *-"$1"-*)
+			# Do allow any other hyphenated suffix
+			return 0
+			;;
+		esac
+		shift
+	done
+	return 1
 }
 
 arch_get_kernel () {
-	imgbase=linux-image
+	imgbase="linux-image-$KERNEL_MAJOR"
 
-	# See older versions of script for more flexible code structure
-	# that allows multiple levels of fallbacks
-	if [ "$1" = 686-bigmem ]; then
-		echo "$imgbase-$KERNEL_MAJOR-686-bigmem"
-		set 686
-	fi
-	if [ "$1" = 686 ]; then
-		echo "$imgbase-$KERNEL_MAJOR-686"
-	fi
-	echo "$imgbase-$KERNEL_MAJOR-486"
+	set -- $1
+	while [ $# -ge 1 ]; do
+		echo "$imgbase-$1"
+		shift
+	done
 }
Index: packages/base-installer/kernel/tests/i386/cittagazze.test
===================================================================
--- packages/base-installer/kernel/tests/i386/cittagazze.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/cittagazze.test	(working copy)
@@ -1,8 +1,9 @@
 cpuinfo cittagazze.cpuinfo
 majors 2.6
-flavour 686
+flavour 686 686-bigmem 486
 kernel-2.6 \
   linux-image-2.6-686 \
+  linux-image-2.6-686-bigmem \
   linux-image-2.6-486
 usable \
   linux-image-2.6-486 \
@@ -11,4 +12,8 @@
   linux-image-2.6.25-1-486 \
   linux-image-2.6.25-1-686 \
   linux-image-2.6.25-1-686-bigmem
+unusable \
+  linux-image-2.6-amd64 \
+  linux-image-2.6.25-1-amd64
 env KERNEL_FLAVOUR 486
+env RAM_END 0x10000000
Index: packages/base-installer/kernel/tests/i386/via-c7-Samuel.test
===================================================================
--- packages/base-installer/kernel/tests/i386/via-c7-Samuel.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/via-c7-Samuel.test	(working copy)
@@ -11,7 +11,10 @@
   linux-image-2.6-686-bigmem \
   linux-image-2.6-686 \
   linux-image-2.6-k7 \
+  linux-image-2.6-686-amd64 \
   linux-image-2.6.18-1-686-bigmem \
   linux-image-2.6.18-1-686 \
-  linux-image-2.6.18-1-k7
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6-18-1-amd64
 env KERNEL_FLAVOUR 486
+env RAM_END 0x4000000
Index: packages/base-installer/kernel/tests/i386/via-c7-Esther.test
===================================================================
--- packages/base-installer/kernel/tests/i386/via-c7-Esther.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/via-c7-Esther.test	(working copy)
@@ -1,9 +1,10 @@
 cpuinfo via-c7-Esther.cpuinfo
 machine i686
 majors 2.6
-flavour 686
+flavour 686 686-bigmem 486
 kernel-2.6 \
   linux-image-2.6-686 \
+  linux-image-2.6-686-bigmem \
   linux-image-2.6-486
 usable \
   linux-image-2.6-486 \
@@ -14,4 +15,7 @@
   linux-image-2.6.18-1-686
 unusable \
   linux-image-2.6-k7 \
-  linux-image-2.6.18-1-k7
+  linux-image-2.6-amd64 \
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6.18-1-amd64
+env RAM_END 0x4000000
Index: packages/base-installer/kernel/tests/i386/oqo1.test
===================================================================
--- packages/base-installer/kernel/tests/i386/oqo1.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/oqo1.test	(working copy)
@@ -10,7 +10,10 @@
   linux-image-2.6-686-bigmem \
   linux-image-2.6-686 \
   linux-image-2.6-k7 \
+  linux-image-2.6-amd64 \
   linux-image-2.6.18-1-686-bigmem \
   linux-image-2.6.18-1-686 \
-  linux-image-2.6.18-1-k7
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6.18-1-amd64
 env KERNEL_FLAVOUR 486
+env RAM_END 0x4000000
Index: packages/base-installer/kernel/tests/i386/pentium-3.test
===================================================================
--- packages/base-installer/kernel/tests/i386/pentium-3.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/pentium-3.test	(working copy)
@@ -1,8 +1,9 @@
 cpuinfo pentium-3.cpuinfo
 majors 2.6
-flavour 686
+flavour 686 686-bigmem 486
 kernel-2.6 \
   linux-image-2.6-686 \
+  linux-image-2.6-686-bigmem \
   linux-image-2.6-486
 usable \
   linux-image-2.6-486 \
@@ -13,5 +14,8 @@
   linux-image-2.6.18-1-686
 unusable \
   linux-image-2.6-k7 \
-  linux-image-2.6.18-1-k7
+  linux-image-2.6-amd64 \
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6.18-1-amd64
 env KERNEL_FLAVOUR 486
+env RAM_END 0x10000000
Index: packages/base-installer/kernel/tests/i386/pentium-d-2p.test
===================================================================
--- packages/base-installer/kernel/tests/i386/pentium-d-2p.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/pentium-d-2p.test	(working copy)
@@ -1,17 +1,22 @@
 cpuinfo pentium-d-2p.cpuinfo
 majors 2.6
-flavour 686
+flavour 686 686-bigmem amd64 486
 kernel-2.6 \
   linux-image-2.6-686 \
+  linux-image-2.6-686-bigmem \
+  linux-image-2.6-amd64 \
   linux-image-2.6-486
 usable \
   linux-image-2.6-486 \
   linux-image-2.6-686-bigmem \
+  linux-image-2.6-amd64 \
   linux-image-2.6-686 \
   linux-image-2.6.18-1-486 \
   linux-image-2.6.18-1-686-bigmem \
+  linux-image-2.6.18-1-amd64 \
   linux-image-2.6.18-1-686
 unusable \
   linux-image-2.6-k7 \
   linux-image-2.6.18-1-k7
 env KERNEL_FLAVOUR 486
+env RAM_END 0x10000000
Index: packages/base-installer/kernel/tests/i386/pentium.test
===================================================================
--- packages/base-installer/kernel/tests/i386/pentium.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/pentium.test	(working copy)
@@ -11,7 +11,10 @@
   linux-image-2.6-686-bigmem \
   linux-image-2.6-686 \
   linux-image-2.6-k7 \
+  linux-image-2.6-amd64 \
   linux-image-2.6.18-1-686-bigmem \
   linux-image-2.6.18-1-686 \
-  linux-image-2.6.18-1-k7
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6.18-1-amd64
 env KERNEL_FLAVOUR 486
+env RAM_END 0x4000000
Index: packages/base-installer/kernel/tests/i386/amd-k7-old.test
===================================================================
--- packages/base-installer/kernel/tests/i386/amd-k7-old.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/amd-k7-old.test	(working copy)
@@ -1,13 +1,18 @@
 cpuinfo amd-k7-old.cpuinfo
 majors 2.6
-flavour 486
+flavour 686 686-bigmem 486
 kernel-2.6 \
+  linux-image-2.6-686 \
+  linux-image-2.6-686-bigmem \
   linux-image-2.6-486
 usable \
   linux-image-2.6-486 \
-  linux-image-2.6.25-1-486
-unusable \
   linux-image-2.6-686 \
   linux-image-2.6-686-bigmem \
+  linux-image-2.6.25-1-486 \
   linux-image-2.6.25-1-686 \
   linux-image-2.6.25-1-686-bigmem
+unusable \
+  linux-image-2.6-amd64 \
+  linux-image-2.6.25-1-amd64
+env RAM_END 0x10000000
Index: packages/base-installer/kernel/tests/i386/pentium-4M-bigmem-2.test
===================================================================
--- packages/base-installer/kernel/tests/i386/pentium-4M-bigmem-2.test	(revision 0)
+++ packages/base-installer/kernel/tests/i386/pentium-4M-bigmem-2.test	(revision 0)
@@ -0,0 +1,22 @@
+cpuinfo pentium-4M.cpuinfo
+machine i686
+majors 2.6
+flavour 686-bigmem 686 486
+kernel-2.6 \
+  linux-image-2.6-686-bigmem \
+  linux-image-2.6-686 \
+  linux-image-2.6-486
+usable \
+  linux-image-2.6-486 \
+  linux-image-2.6-686 \
+  linux-image-2.6-686-bigmem \
+  linux-image-2.6.18-1-486 \
+  linux-image-2.6.18-1-686 \
+  linux-image-2.6.18-1-686-bigmem
+unusable \
+  linux-image-2.6-k7 \
+  linux-image-2.6-amd64 \
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6.18-1-amd64
+env KERNEL_FLAVOUR 486
+env RAM_END 0x140000000
Index: packages/base-installer/kernel/tests/i386/pentium-4M-bigmem.test
===================================================================
--- packages/base-installer/kernel/tests/i386/pentium-4M-bigmem.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/pentium-4M-bigmem.test	(working copy)
@@ -1,7 +1,7 @@
 cpuinfo pentium-4M.cpuinfo
 machine i686
 majors 2.6
-flavour 686-bigmem
+flavour 686-bigmem 686 486
 kernel-2.6 \
   linux-image-2.6-686-bigmem \
   linux-image-2.6-686 \
@@ -15,5 +15,8 @@
   linux-image-2.6.18-1-686-bigmem
 unusable \
   linux-image-2.6-k7 \
-  linux-image-2.6.18-1-k7
+  linux-image-2.6-amd64 \
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6.18-1-amd64
 env KERNEL_FLAVOUR 686-bigmem
+env RAM_END 0x10000000
Index: packages/base-installer/kernel/tests/i386/pentium-4M.test
===================================================================
--- packages/base-installer/kernel/tests/i386/pentium-4M.test	(revision 63990)
+++ packages/base-installer/kernel/tests/i386/pentium-4M.test	(working copy)
@@ -1,9 +1,10 @@
 cpuinfo pentium-4M.cpuinfo
 machine i686
 majors 2.6
-flavour 686
+flavour 686 686-bigmem 486
 kernel-2.6 \
   linux-image-2.6-686 \
+  linux-image-2.6-686-bigmem \
   linux-image-2.6-486
 usable \
   linux-image-2.6-486 \
@@ -14,5 +15,8 @@
   linux-image-2.6.18-1-686-bigmem
 unusable \
   linux-image-2.6-k7 \
-  linux-image-2.6.18-1-k7
+  linux-image-2.6-amd64 \
+  linux-image-2.6.18-1-k7 \
+  linux-image-2.6.18-1-amd64
 env KERNEL_FLAVOUR 486
+env RAM_END 0x10000000
Index: packages/base-installer/debian/changelog
===================================================================
--- packages/base-installer/debian/changelog	(revision 63990)
+++ packages/base-installer/debian/changelog	(working copy)
@@ -1,3 +1,13 @@
+base-installer (1.109) UNRELEASED; urgency=low
+
+  [ Ben Hutchings ]
+  * Improve i386 kernel flavour selection:
+    - Prefer 686-bigmem flavour if it is needed to access all RAM
+    - Prefer 686 or 686-bigmem flavour for all AMD K7 processors
+    - Offer 686-bigmem and amd64 flavours for processors that support them
+
+ -- Ben Hutchings <ben@decadent.org.uk>  Sun, 18 Jul 2010 18:16:13 +0100
+
 base-installer (1.108) unstable; urgency=low
 
   [ Martin Michlmayr ]
--- END ---

-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: