[PATCH] profiler fix for non-SMP linuk-2.4.6-rc4-mm1

Santiago Gala
2004-10-11T22:33:47Z

[-- Attachment #1.1: Type: text/plain, Size: 1921 bytes --]

I need the patches shown here, from J.A. Magallón, to have 2.6.9-rc4-mm1
running on my TiBook (but they are slightly wrong).
http://lkml.org/lkml/2004/10/11/111

Without this patches, I'm having one error like:

Oct 11 21:35:12 marlow Oops: kernel access of bad area, sig: 11 [#148]
Oct 11 21:35:12 marlow NIP: C001AA98 LR: C0016CBC SP: D7E97F10 REGS:
d7e97e60 TRAP: 0300 Not tainted
Oct 11 21:35:12 marlow MSR: 00001032 EE: 0 PR: 0 FP: 0 ME: 1 IR/DR: 11
Oct 11 21:35:12 marlow DAR: 00015380, DSISR: 40000000
Oct 11 21:35:12 marlow TASK = dfece610[8077] 'apache2' THREAD:
d7e96000Last syscall: 156
Oct 11 21:35:12 marlow GPR00: 00015380 D7E97F10 DFECE610 00000002
000054E0 00000004 D7E97F18 0F8E0F7C
Oct 11 21:35:12 marlow GPR08: 00000000 00015380 000054E0 C0310000
82004422 1006B304 0FA29334 101A27A0
Oct 11 21:35:12 marlow GPR16: 0FA293B8 3003DDA0 101A2700 0FA293BC
FFFFF000 1016E178 0FA29328 0FA2B8BC
Oct 11 21:35:12 marlow GPR24: 101A2DC0 C00054E0 00000000 DFECE610
FFFFFFEA 101A2DC0 C03205B8 D7E97F10
Oct 11 21:35:12 marlow NIP [c001aa98] profile_hit+0x40/0x54
Oct 11 21:35:12 marlow LR [c0016cbc] setscheduler+0xf4/0x2b0
Oct 11 21:35:12 marlow Call trace:
Oct 11 21:35:12 marlow [c00054e0] ret_from_syscall+0x0/0x44

three times per second or so, though the kernel works enough to have me
shutting it down orderly. When I logged into gnome, the Oops was not
always in apache, but sometimes in nautilus or other apps.

The patch he sent does not work for non SMP configs (cut&paste error?)
The one I attach works for my laptop, while not changing the SMP part,
AFAIK.

This mm kernel is looking very stable, and I'll give it a try not
rebooting it till tomorrow or till I see some problems with my firewire
device (still giving problems for time to time here).

The patch is against rc4-mm1.

Regards
--
Santiago Gala <sgala@hisitech.com>
High Sierra Technology, SLU

[-- Attachment #1.2: profiler.patch --]
[-- Type: text/x-patch, Size: 3293 bytes --]

--- linux-2.6.9-rc4-mm1/include/linux/profile.h 2004-10-11 19:52:04.000000000 +0200
+++ linux-2.6.9-rc4-mm1-mine/include/linux/profile.h 2004-10-11 23:17:01.000000000 +0200
@@ -8,6 +8,7 @@
#include <linux/init.h>
#include <linux/cpumask.h>
#include <asm/errno.h>
+#include <asm/atomic.h>

#define CPU_PROFILING 1
#define SCHED_PROFILING 2
@@ -17,8 +18,8 @@

/* init basic kernel profiler */
void __init profile_init(void);
-void profile_tick(int, struct pt_regs *);
-void profile_hit(int, void *);
+void FASTCALL(__profile_hit(void *));
+
#ifdef CONFIG_PROC_FS
void create_prof_cpu_mask(struct proc_dir_entry *);
#else
@@ -101,6 +102,26 @@

#endif /* CONFIG_PROFILING */

+static inline void profile_hit(int type, void *pc)
+{
+ extern int prof_on;
+ extern atomic_t *prof_buffer;
+
+ if (prof_on == type && prof_buffer)
+ __profile_hit(pc);
+}
+
+static inline void profile_tick(int type, struct pt_regs *regs)
+{
+ extern cpumask_t prof_cpu_mask;
+
+ if (type != CPU_PROFILING)
+ return;
+ profile_hook(regs);
+ if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask))
+ profile_hit(type, (void *)profile_pc(regs));
+}
+
#endif /* __KERNEL__ */

#endif /* _LINUX_PROFILE_H */
--- linux-2.6.9-rc4-mm1/kernel/profile.c 2004-10-11 19:54:35.000000000 +0200
+++ linux-2.6.9-rc4-mm1-mine/kernel/profile.c 2004-10-11 23:34:19.000000000 +0200
@@ -34,10 +34,10 @@
#define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
#define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)

-static atomic_t *prof_buffer;
+atomic_t *prof_buffer;
static unsigned long prof_len, prof_shift;
-static int prof_on;
-static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
+int prof_on;
+cpumask_t prof_cpu_mask = CPU_MASK_ALL;
#ifdef CONFIG_SMP
static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
static DEFINE_PER_CPU(int, cpu_profile_flip);
@@ -284,14 +284,12 @@
up(&profile_flip_mutex);
}

-void profile_hit(int type, void *__pc)
+void fastcall __profile_hit(void *__pc)
{
unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
int i, j, cpu;
struct profile_hit *hits;

- if (prof_on != type || !prof_buffer)
- return;
pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
@@ -380,26 +378,15 @@
#else /* !CONFIG_SMP */
#define profile_flip_buffers() do { } while (0)
#define profile_discard_flip_buffers() do { } while (0)
-
-inline void profile_hit(int type, void *__pc)
-{
- unsigned long pc;
-
+void __profile_hit(void *__pc)
+ {
+ unsigned long pc;
+
pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
atomic_inc(&prof_buffer[min(pc, prof_len - 1)]);
-}
+ }
#endif /* !CONFIG_SMP */

-void profile_tick(int type, struct pt_regs *regs)
-{
- if (type == CPU_PROFILING)
- profile_hook(regs);
- if (prof_on != type || !prof_buffer)
- return;
- if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask))
- profile_hit(type, (void *)profile_pc(regs));
-}
-
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
#include <asm/uaccess.h>

[-- Attachment #2: Esta parte del mensaje está firmada digitalmente --]
[-- Type: application/pgp-signature, Size: 189 bytes --]