patch to make the profiler working again

Andrea Arcangeli (arcangeli@mbox.queen.it)
Sun, 14 Jun 1998 17:29:47 +0200 (CEST)


This patch allow to use the profiler if compiled in the kernel without had
to specify `profile=2' at lilo prompt. I don' t know if it' s possible to
write something lighter of profile_init().

The patch mask out some code not needed if CONFIG_PROFILE is not set, but
I am really not sure about the smp.c and time.c part of the patch so
please take a look at it if you are applying it (if unsure remove the
smp.c and time.c patch).

The patch is against 105 but apply pretty clean also against 106.

--- /usr/src/linux/fs/proc/root.c Thu May 21 12:53:17 1998
+++ linux/fs/proc/root.c Mon Jun 8 15:57:53 1998
@@ -603,11 +603,13 @@
S_IFREG | S_IRUGO, 1, 0, 0,
0, &proc_array_inode_operations
};
+#ifdef CONFIG_PROFILE
static struct proc_dir_entry proc_root_profile = {
PROC_PROFILE, 7, "profile",
S_IFREG | S_IRUGO | S_IWUSR, 1, 0, 0,
0, &proc_profile_inode_operations
};
+#endif
static struct proc_dir_entry proc_root_slab = {
PROC_SLABINFO, 8, "slabinfo",
S_IFREG | S_IRUGO, 1, 0, 0,
@@ -682,10 +684,12 @@
#endif
proc_register(&proc_root, &proc_root_slab);

+#ifdef CONFIG_PROFILE
if (prof_shift) {
proc_register(&proc_root, &proc_root_profile);
proc_root_profile.size = (1+prof_len) * sizeof(unsigned int);
}
+#endif

proc_tty_init();
#ifdef __powerpc__
--- /usr/src/linux/fs/proc/array.c Mon Jun 8 13:31:06 1998
+++ linux/fs/proc/array.c Mon Jun 8 15:59:18 1998
@@ -136,6 +136,7 @@
&proc_kcore_operations,
};

+#ifdef CONFIG_PROFILE
/*
* This function accesses profiling information. The returned data is
* binary: the sampling step and the actual contents of the profile
@@ -203,6 +204,7 @@
struct inode_operations proc_profile_inode_operations = {
&proc_profile_operations,
};
+#endif


static int get_loadavg(char * buffer)
--- /usr/src/linux/init/main.c Mon Jun 8 13:31:06 1998
+++ linux/init/main.c Mon Jun 8 16:47:08 1998
@@ -345,16 +345,18 @@
{
if (ints[0] > 0)
prof_shift = (unsigned long) ints[1];
- else
+}
+
+static void profile_init(void)
+{
#ifdef CONFIG_PROFILE_SHIFT
- prof_shift = CONFIG_PROFILE_SHIFT;
+ prof_shift = CONFIG_PROFILE_SHIFT;
#else
- prof_shift = 2;
+ prof_shift = 2;
#endif
}
#endif

-
static struct dev_name_struct {
const char *name;
const int num;
@@ -1029,6 +1031,9 @@
init_IRQ();
sched_init();
time_init();
+#ifdef CONFIG_PROFILE
+ profile_init();
+#endif
parse_options(command_line);

/*
--- /usr/src/linux/arch/i386/kernel/time.c Sat Jun 6 12:24:31 1998
+++ linux/arch/i386/kernel/time.c Sat Jun 13 19:00:50 1998
@@ -379,6 +379,8 @@
static inline void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
do_timer(regs);
+
+#ifdef CONFIG_PROFILE
/*
* In the SMP case we use the local APIC timer interrupt to do the
* profiling, except when we simulate SMP mode on a uniprocessor
@@ -390,6 +392,7 @@
#else
if (!smp_found_config)
smp_local_timer_interrupt(regs);
+#endif
#endif

/*
--- /usr/src/linux/arch/i386/kernel/smp.c Sat Jun 6 12:24:31 1998
+++ linux/arch/i386/kernel/smp.c Sat Jun 13 19:09:24 1998
@@ -1755,6 +1755,7 @@
restore_flags(flags);
}

+#ifdef CONFIG_PROFILE
/*
* the frequency of the profiling timer can be changed
* by writing a multiplier value into /proc/profile.
@@ -1782,5 +1783,6 @@

return 0;
}
+#endif

#undef APIC_DIVISOR

Andrea[s] Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu