summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-01-28 10:23:35 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-01-28 10:23:35 -0500
commita1214e0740efd539abe544bad06dee44c2d467fe (patch)
tree57fd9cc54b397004f65580704e2ffc630f6a5485
parent47240d73903b0873faaa5c7d2c23f2f42798712a (diff)
parent42c7c164858e1fc177d046f9a0de94538e702c94 (diff)
Merge branch 'master' of ssh://cvs.cs.unc.edu/cvs/proj/litmus/repo/tools
-rwxr-xr-xenable-cycle-counter.district1023
-rwxr-xr-xetc_grub.d_10_linux.bonham159
-rwxr-xr-xetc_grub.d_15_litmus.bonham4
-rwxr-xr-xinstall_kernel.bonham116
4 files changed, 302 insertions, 0 deletions
diff --git a/enable-cycle-counter.district10 b/enable-cycle-counter.district10
new file mode 100755
index 0000000..11d1d7e
--- /dev/null
+++ b/enable-cycle-counter.district10
@@ -0,0 +1,23 @@
1#!/bin/bash
2
3die() {
4 echo "Error: $*"
5 exit 1
6}
7
8# if perf is not given in environment, then check path
9[ -z "$PERF" ] && PERF=`which perf 2> /dev/null`
10# otherwise, assume default location
11[ -z "$PERF" ] && PERF=~/dev/litmus2010/tools/perf/perf
12
13[ -f "$PERF" ] && [ -x "$PERF" ] || die "Could not find perf tool."
14
15# works for sparc64 and Intel x86 if all CPUs are online
16NUM_CPUS=`egrep -c '^processor|online' /proc/cpuinfo`
17
18# Keep cycle counter active for a loooong time.
19
20for x in `seq 0 $(($NUM_CPUS - 1))`
21do
22 schedtool -a $x -e "$PERF" record -o /dev/null sleep $((60 * 60 * 24 * 365)) > /dev/null &
23done
diff --git a/etc_grub.d_10_linux.bonham b/etc_grub.d_10_linux.bonham
new file mode 100755
index 0000000..89a4d1f
--- /dev/null
+++ b/etc_grub.d_10_linux.bonham
@@ -0,0 +1,159 @@
1#! /bin/sh -e
2
3# grub-mkconfig helper script.
4# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
5#
6# GRUB is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# GRUB is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18
19prefix=/usr
20exec_prefix=${prefix}
21bindir=${exec_prefix}/bin
22libdir=${exec_prefix}/lib
23. ${libdir}/grub/grub-mkconfig_lib
24
25export TEXTDOMAIN=grub
26export TEXTDOMAINDIR=@LOCALEDIR@
27
28CLASS="--class gnu-linux --class gnu --class os"
29
30if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
31 OS=GNU/Linux
32else
33 OS="${GRUB_DISTRIBUTOR}"
34 CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
35fi
36
37# loop-AES arranges things so that /dev/loop/X can be our root device, but
38# the initrds that Linux uses don't like that.
39case ${GRUB_DEVICE} in
40 /dev/loop/*|/dev/loop[0-9])
41 GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
42 # We can't cope with devices loop-mounted from files here.
43 case ${GRUB_DEVICE} in
44 /dev/*) ;;
45 *) exit 0 ;;
46 esac
47 ;;
48esac
49
50if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
51 || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
52 || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then
53 LINUX_ROOT_DEVICE=${GRUB_DEVICE}
54else
55 LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
56fi
57
58# add crashkernel option if we have the required tools
59if [ -x "/usr/bin/makedumpfile" ] && [ -x "/sbin/kexec" ]; then
60 GRUB_CMDLINE_EXTRA="$GRUB_CMDLINE_EXTRA crashkernel=384M-2G:64M,2G-:128M"
61fi
62
63linux_entry ()
64{
65 os="$1"
66 version="$2"
67 recovery="$3"
68 args="$4"
69 if ${recovery} ; then
70 title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
71 else
72 title="$(gettext_quoted "%s, with Linux %s")"
73 fi
74 printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
75 cat << EOF
76 recordfail
77EOF
78 save_default_entry | sed -e "s/^/\t/"
79
80 if [ "x$GRUB_GFXPAYLOAD_LINUX" != x ]; then
81 cat << EOF
82 set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
83EOF
84 fi
85
86 if [ -z "${prepare_boot_cache}" ]; then
87 prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
88 fi
89 printf '%s\n' "${prepare_boot_cache}"
90 if [ "x$5" != "xquiet" ]; then
91 cat << EOF
92 echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
93EOF
94 fi
95 cat << EOF
96 linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
97EOF
98 if [ "x$5" != "xquiet" ]; then
99 cat << EOF
100 echo '$(gettext_quoted "Loading initial ramdisk ...")'
101EOF
102 fi
103 if test -n "${initrd}" ; then
104 cat << EOF
105 initrd ${rel_dirname}/${initrd}
106EOF
107 fi
108 cat << EOF
109}
110EOF
111}
112
113list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
114 if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
115 done`
116
117# Filter out litmus kernels
118list=`echo $list | tr ' ' '\n' | grep -v litmus | tr '\n' ' '`
119# Filter out custom vanilla kernels
120list=`echo $list | tr ' ' '\n' | grep -v vanilla | tr '\n' ' '`
121
122prepare_boot_cache=
123
124while [ "x$list" != "x" ] ; do
125 linux=`version_find_latest $list`
126 echo "Found linux image: $linux" >&2
127 basename=`basename $linux`
128 dirname=`dirname $linux`
129 rel_dirname=`make_system_path_relative_to_its_root $dirname`
130 version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
131 alt_version=`echo $version | sed -e "s,\.old$,,g"`
132 linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
133
134 initrd=
135 for i in "initrd.img-${version}" "initrd-${version}.img" \
136 "initrd-${version}" "initrd.img-${alt_version}" \
137 "initrd-${alt_version}.img" "initrd-${alt_version}"; do
138 if test -e "${dirname}/${i}" ; then
139 initrd="$i"
140 break
141 fi
142 done
143 if test -n "${initrd}" ; then
144 echo "Found initrd image: ${dirname}/${initrd}" >&2
145 else
146 # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
147 linux_root_device_thisversion=${GRUB_DEVICE}
148 fi
149
150 linux_entry "${OS}" "${version}" false \
151 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
152 quiet
153 if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
154 linux_entry "${OS}" "${version}" true \
155 "single ${GRUB_CMDLINE_LINUX}"
156 fi
157
158 list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
159done
diff --git a/etc_grub.d_15_litmus.bonham b/etc_grub.d_15_litmus.bonham
new file mode 100755
index 0000000..108668a
--- /dev/null
+++ b/etc_grub.d_15_litmus.bonham
@@ -0,0 +1,4 @@
1#!/bin/sh
2exec tail -n +3 $0
3# Litmus Kernels. Be careful not to change the 'exec tail' line above.
4
diff --git a/install_kernel.bonham b/install_kernel.bonham
new file mode 100755
index 0000000..b7958e0
--- /dev/null
+++ b/install_kernel.bonham
@@ -0,0 +1,116 @@
1#!/bin/bash
2
3function die()
4{
5 echo " (EE) $1"
6 exit 1
7}
8
9function info()
10{
11 echo " (II) $1"
12}
13
14function silent()
15{
16 OUTPUT=`$*`
17 if [ "$?" != "0" ]; then
18 echo $OUTPUT
19 die "$* failed!"
20 fi
21}
22
23# Function to grab var from src
24function getvar() {
25 old=$(head -5 Makefile | grep "^$1")
26 echo $(echo ${old/"$1 ="/} | sed -e "s/[ ]*\(.*\)[ ]*/\1/g")
27 return 0
28}
29
30if [ ! -f "./.config" ]; then
31 CURDIR=`pwd`
32 die "No kernel .config exists in $CURDIR!"
33fi
34
35if [ ! -f "./Makefile" ]; then
36 die "No Makefile present!"
37fi
38
39VERSION=`getvar VERSION`
40PATCHLEVEL=`getvar PATCHLEVEL`
41SUBLEVEL=`getvar SUBLEVEL`
42EXTRAVERSION=`getvar EXTRAVERSION`
43
44. ./.config
45
46NAME="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION$CONFIG_LOCALVERSION"
47
48info "Detected kernel version $NAME"
49
50if [ $UID != "0" ]; then
51 die "Must be root to install kernel!"
52fi
53
54# (1) copy modules
55if [ "$1" != "-m" ]; then
56 info "Installing modules..."
57 silent make -j32 modules_install
58else
59 info "Skipping installing modules."
60fi
61
62# (2) copy kernel
63info "Installing kernel..."
64silent cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-$NAME
65silent cp -v System.map /boot/System.map-$NAME
66
67# (3) build ramdisk
68info "Building module dependencies"
69silent depmod -v $NAME
70
71if [ "$1" != "-m" ]; then
72 info "Building initial ramdisk..."
73 silent update-initramfs -c -k $NAME
74else
75 info "Skipping updating initial ramdisk..."
76fi
77
78# (4) make bootloader entry
79ALREADY_PRESENT=`grep "/vmlinuz-$NAME" /etc/grub.d/15_litmus `
80
81if [ ! -z "$ALREADY_PRESENT" ]; then
82 info "Bootloader entry appears to be already present."
83else
84 info "Creating bootloader entry..."
85
86 if [[ "$NAME" =~ "litmus" ]]; then
87 cat >> /etc/grub.d/15_litmus <<__EOE__
88
89menuentry 'Ubuntu/Litmus, with $NAME' --class ubuntu --class gnu-linux --class gnu --class os {
90 recordfail
91 insmod ext2
92 set root='(hd0,3)'
93 search --no-floppy --fs-uuid --set 08b4e70f-d536-45bc-8693-164891c8834b
94 linux /vmlinuz-$NAME root=/dev/sda5 ro quanta=aligned
95 initrd /initrd.img-$NAME
96}
97__EOE__
98 else
99 cat >> /etc/grub.d/15_litmus <<__EOE__
100
101menuentry 'Ubuntu/Custom Kernel, with $NAME' --class ubuntu --class gnu-linux --class gnu --class os {
102 recordfail
103 insmod ext2
104 set root='(hd0,3)'
105 search --no-floppy --fs-uuid --set 08b4e70f-d536-45bc-8693-164891c8834b
106 linux /vmlinuz-$NAME root=/dev/sda5 ro
107 initrd /initrd.img-$NAME
108}
109__EOE__
110 fi
111
112update-grub
113
114fi
115
116info "Kernel $NAME has been installed."