shrink check_nmi_watchdog stack frame

shrink check_nmi_watchdog stack frame

Post by Mikael Pettersso » Sat, 27 Jul 2002 01:10:10



This patch for 2.5.28 reduces the stack frame size of
arch/i386/kernel/nmi.c:check_nmi_watchdog() from 4096 bytes
in the worst case to 128 bytes. Linus, please apply.

The problem with the current code is that it copies the entire
irq_stat[] array, when only a single field (__nmi_count) is of
interest. The irq_stat_t element type is only 28 bytes, but it
is also ____cacheline_aligned, and that blows the array up to
4096 bytes on SMP P4 Xeons, 2048 bytes on SMP K7s, and 1024 bytes
on SMP P5/P6s. The patch reduces this to NR_CPUS*4==128 bytes.

/Mikael

diff -ruN linux-2.5.28/arch/i386/kernel/nmi.c linux-2.5.28.check-nmi/arch/i386/kernel/nmi.c
--- linux-2.5.28/arch/i386/kernel/nmi.c Thu Jul 25 01:27:29 2002

 int __init check_nmi_watchdog (void)
 {
-       irq_cpustat_t tmp[NR_CPUS];
+       unsigned int prev_nmi_count[NR_CPUS];
        int cpu;

        printk(KERN_INFO "testing NMI watchdog ... ");

-       memcpy(tmp, irq_stat, sizeof(tmp));
+       for (cpu = 0; cpu < NR_CPUS; cpu++)
+               prev_nmi_count[cpu] = irq_stat[cpu].__nmi_count;
        local_irq_enable();
        mdelay((10*1000)/nmi_hz); // wait 10 ticks

        for (cpu = 0; cpu < NR_CPUS; cpu++) {
                if (!cpu_online(cpu))
                        continue;
-               if (nmi_count(cpu) - tmp[cpu].__nmi_count <= 5) {
+               if (nmi_count(cpu) - prev_nmi_count[cpu] <= 5) {
                        printk("CPU#%d: NMI appears to be stuck!\n", cpu);
                        return -1;
                }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. shrink check_nmi_watchdog stack frame

This patch for 2.5.21 reduces the stack frame size of
arch/i386/kernel/nmi.c:check_nmi_watchdog() from 4096 bytes
in the worst case to 128 bytes. Linus, please apply.

The problem with the current code is that it copies the entire
irq_stat[] array, when only a single field (__nmi_count) is of
interest. The irq_stat_t element type is only 28 bytes, but it
is also ____cacheline_aligned, and that blows the array up to
4096 bytes on SMP P4 Xeons, 2048 bytes on SMP K7s, and 1024 bytes
on SMP P5/P6s. The patch reduces this to NR_CPUS*4==128 bytes.

If you approve this patch I'll also send one to Marcelo for 2.4.

/Mikael

diff -ruN linux-2.5.21/arch/i386/kernel/nmi.c linux-2.5.21.check-nmi/arch/i386/kernel/nmi.c
--- linux-2.5.21/arch/i386/kernel/nmi.c Mon Apr 15 00:32:51 2002

 int __init check_nmi_watchdog (void)
 {
-       irq_cpustat_t tmp[NR_CPUS];
+       unsigned int prev_nmi_count[NR_CPUS];
        int j, cpu;

        printk(KERN_INFO "testing NMI watchdog ... ");

-       memcpy(tmp, irq_stat, sizeof(tmp));
+       for(j = 0; j < NR_CPUS; ++j)
+               prev_nmi_count[j] = irq_stat[j].__nmi_count;
        sti();
        mdelay((10*1000)/nmi_hz); // wait 10 ticks

        for (j = 0; j < smp_num_cpus; j++) {
                cpu = cpu_logical_map(j);
-               if (nmi_count(cpu) - tmp[cpu].__nmi_count <= 5) {
+               if (nmi_count(cpu) - prev_nmi_count[cpu] <= 5) {
                        printk("CPU#%d: NMI appears to be stuck!\n", cpu);
                        return -1;
                }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Apache 1.3.0: 403 - Forbidden when errno=ETIMEDOUT

3. gdb: missing frames in frame stack or function name garbled

4. Compile Satan on RedHat 4.1

5. kernel feature: shrink stack

6. Need help with dump/restore on Linux - Getting broken pipe.

7. what causes 0x0 in stack frame?

8. troubles with isdnd

9. gcc stack frame layout for linux?

10. Bogus end() stack frames under Linux

11. a RS6000 stack frame

12. Frame Relay stack on Linux

13. request for info on stack and frame pointers on sparc