2006-10-30 16:53:38 +01:00
|
|
|
/*
|
|
|
|
* This file contains several functions and variables used for system
|
|
|
|
* profiling.
|
|
|
|
*
|
|
|
|
* Statistical Profiling:
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
* The interrupt handler for profiling clock.
|
2006-10-30 16:53:38 +01:00
|
|
|
*
|
|
|
|
* Call Profiling:
|
|
|
|
* The table used for profiling data and a function to get its size.
|
|
|
|
*
|
|
|
|
* The function used by kernelspace processes to register the locations
|
|
|
|
* of their control struct and profiling table.
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
* 14 Aug, 2006 Created, (Rogier Meurs)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <minix/config.h>
|
|
|
|
|
|
|
|
#include <minix/profile.h>
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
#include <minix/portio.h>
|
2006-10-30 16:53:38 +01:00
|
|
|
#include "kernel.h"
|
|
|
|
#include "profile.h"
|
|
|
|
#include "proc.h"
|
|
|
|
|
|
|
|
#if SPROFILE
|
|
|
|
|
|
|
|
#include <string.h>
|
2010-09-23 12:49:45 +02:00
|
|
|
#include "watchdog.h"
|
2006-10-30 16:53:38 +01:00
|
|
|
|
2010-12-17 14:47:11 +01:00
|
|
|
char sprof_sample_buffer[SAMPLE_BUFFER_SIZE];
|
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
/* Function prototype for the profiling clock handler. */
|
|
|
|
FORWARD _PROTOTYPE( int profile_clock_handler, (irq_hook_t *hook) );
|
2006-10-30 16:53:38 +01:00
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
/* A hook for the profiling clock interrupt handler. */
|
|
|
|
PRIVATE irq_hook_t profile_clock_hook;
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
/*===========================================================================*
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
* init_profile_clock *
|
2006-10-30 16:53:38 +01:00
|
|
|
*===========================================================================*/
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
PUBLIC void init_profile_clock(u32_t freq)
|
2006-10-30 16:53:38 +01:00
|
|
|
{
|
2010-01-22 23:01:08 +01:00
|
|
|
int irq;
|
2006-10-30 16:53:38 +01:00
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
if((irq = arch_init_profile_clock(freq)) >= 0) {
|
|
|
|
/* Register interrupt handler for statistical system profiling. */
|
|
|
|
profile_clock_hook.proc_nr_e = CLOCK;
|
|
|
|
put_irq_handler(&profile_clock_hook, irq, profile_clock_handler);
|
|
|
|
enable_irq(&profile_clock_hook);
|
|
|
|
}
|
2006-10-30 16:53:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
* profile_clock_stop *
|
2006-10-30 16:53:38 +01:00
|
|
|
*===========================================================================*/
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
PUBLIC void stop_profile_clock()
|
2006-10-30 16:53:38 +01:00
|
|
|
{
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
arch_stop_profile_clock();
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
/* Unregister interrupt handler. */
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
disable_irq(&profile_clock_hook);
|
|
|
|
rm_irq_handler(&profile_clock_hook);
|
2006-10-30 16:53:38 +01:00
|
|
|
}
|
|
|
|
|
2010-09-23 12:49:50 +02:00
|
|
|
PRIVATE sprof_save_sample(struct proc * p, void * pc)
|
2010-09-23 12:49:39 +02:00
|
|
|
{
|
2010-09-23 12:49:48 +02:00
|
|
|
struct sprof_sample *s;
|
2010-09-23 12:49:39 +02:00
|
|
|
|
2010-09-23 12:49:48 +02:00
|
|
|
s = (struct sprof_sample *) (sprof_sample_buffer + sprof_info.mem_used);
|
2010-09-23 12:49:39 +02:00
|
|
|
|
2010-09-23 12:49:48 +02:00
|
|
|
s->proc = p->p_endpoint;
|
2010-09-23 12:49:50 +02:00
|
|
|
s->pc = pc;
|
2010-09-23 12:49:39 +02:00
|
|
|
|
2010-09-23 12:49:48 +02:00
|
|
|
sprof_info.mem_used += sizeof(struct sprof_sample);
|
2010-09-23 12:49:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE sprof_save_proc(struct proc * p)
|
|
|
|
{
|
2010-09-23 12:49:48 +02:00
|
|
|
struct sprof_proc * s;
|
2010-09-23 12:49:39 +02:00
|
|
|
|
2010-09-23 12:49:48 +02:00
|
|
|
s = (struct sprof_proc *) (sprof_sample_buffer + sprof_info.mem_used);
|
2010-09-23 12:49:39 +02:00
|
|
|
|
2010-09-23 12:49:48 +02:00
|
|
|
s->proc = p->p_endpoint;
|
|
|
|
memcpy(&s->name, p->p_name, P_NAME_LEN);
|
2010-09-23 12:49:39 +02:00
|
|
|
|
2010-09-23 12:49:48 +02:00
|
|
|
sprof_info.mem_used += sizeof(struct sprof_proc);
|
2010-09-23 12:49:39 +02:00
|
|
|
}
|
|
|
|
|
2010-09-23 12:49:50 +02:00
|
|
|
PRIVATE void profile_sample(struct proc * p, void * pc)
|
2006-10-30 16:53:38 +01:00
|
|
|
{
|
|
|
|
/* This executes on every tick of the CMOS timer. */
|
|
|
|
|
|
|
|
/* Are we profiling, and profiling memory not full? */
|
2010-09-23 12:49:45 +02:00
|
|
|
if (!sprofiling || sprof_info.mem_used == -1)
|
|
|
|
return;
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
/* Check if enough memory available before writing sample. */
|
2010-09-23 12:49:48 +02:00
|
|
|
if (sprof_info.mem_used + sizeof(sprof_info) +
|
|
|
|
2*sizeof(struct sprof_sample) +
|
|
|
|
2*sizeof(struct sprof_sample) > sprof_mem_size) {
|
2006-10-30 16:53:38 +01:00
|
|
|
sprof_info.mem_used = -1;
|
2010-09-23 12:49:45 +02:00
|
|
|
return;
|
2006-10-30 16:53:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Runnable system process? */
|
2010-09-23 12:49:39 +02:00
|
|
|
if (p->p_endpoint == IDLE)
|
2010-12-16 10:46:26 +01:00
|
|
|
sprof_info.idle_samples++;
|
2010-09-23 12:49:50 +02:00
|
|
|
else if (p->p_endpoint == KERNEL ||
|
2010-12-16 10:46:26 +01:00
|
|
|
(priv(p)->s_flags & SYS_PROC && proc_is_runnable(p))) {
|
|
|
|
|
|
|
|
if (!(p->p_misc_flags & MF_SPROF_SEEN)) {
|
|
|
|
p->p_misc_flags |= MF_SPROF_SEEN;
|
|
|
|
sprof_save_proc(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprof_save_sample(p, pc);
|
|
|
|
sprof_info.system_samples++;
|
2006-10-30 16:53:38 +01:00
|
|
|
} else {
|
|
|
|
/* User process. */
|
|
|
|
sprof_info.user_samples++;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprof_info.total_samples++;
|
2010-09-23 12:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* profile_clock_handler *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE int profile_clock_handler(irq_hook_t *hook)
|
|
|
|
{
|
|
|
|
struct proc * p;
|
|
|
|
p = get_cpulocal_var(proc_ptr);
|
|
|
|
|
2010-09-23 12:49:50 +02:00
|
|
|
profile_sample(p, (void *) p->p_reg.pc);
|
2006-10-30 16:53:38 +01:00
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
/* Acknowledge interrupt if necessary. */
|
|
|
|
arch_ack_profile_clock();
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
return(1); /* reenable interrupts */
|
|
|
|
}
|
|
|
|
|
2010-09-23 12:49:45 +02:00
|
|
|
PUBLIC void nmi_sprofile_handler(struct nmi_frame * frame)
|
|
|
|
{
|
2010-09-23 12:49:50 +02:00
|
|
|
struct proc * p = get_cpulocal_var(proc_ptr);
|
2010-09-23 12:49:45 +02:00
|
|
|
/*
|
|
|
|
* test if the kernel was interrupted. If so, save first a sample fo
|
|
|
|
* kernel and than for the current process, otherwise save just the
|
|
|
|
* process
|
|
|
|
*/
|
|
|
|
if (nmi_in_kernel(frame)) {
|
|
|
|
struct proc *kern;
|
|
|
|
|
2010-09-23 12:49:50 +02:00
|
|
|
/*
|
|
|
|
* if we sample kernel, check if IDLE is scheduled. If so,
|
|
|
|
* account for idle time rather than taking kernel sample
|
|
|
|
*/
|
|
|
|
if (p->p_endpoint == IDLE) {
|
|
|
|
sprof_info.idle_samples++;
|
|
|
|
sprof_info.total_samples++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-23 12:49:45 +02:00
|
|
|
kern = proc_addr(KERNEL);
|
|
|
|
|
2010-09-23 12:49:50 +02:00
|
|
|
profile_sample(kern, (void *) frame->pc);
|
2010-09-23 12:49:45 +02:00
|
|
|
}
|
2010-09-23 12:49:50 +02:00
|
|
|
else
|
|
|
|
profile_sample(p, (void *) frame->pc);
|
2010-09-23 12:49:45 +02:00
|
|
|
}
|
|
|
|
|
2006-10-30 16:53:38 +01:00
|
|
|
#endif /* SPROFILE */
|
|
|
|
|
2009-02-06 17:31:28 +01:00
|
|
|
#if CPROFILE
|
2006-10-30 16:53:38 +01:00
|
|
|
/*
|
|
|
|
* The following variables and functions are used by the procentry/
|
|
|
|
* procentry syslib functions when linked with kernelspace processes.
|
|
|
|
* For userspace processes, the same variables and function are defined
|
|
|
|
* elsewhere. This enables different functionality and variable sizes,
|
|
|
|
* which is needed is a few cases.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* A small table is declared for the kernelspace processes. */
|
|
|
|
struct cprof_tbl_s cprof_tbl[CPROF_TABLE_SIZE_KERNEL];
|
|
|
|
|
|
|
|
/* Function that returns table size. */
|
|
|
|
PUBLIC int profile_get_tbl_size(void)
|
|
|
|
{
|
|
|
|
return CPROF_TABLE_SIZE_KERNEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Function that returns on which execution of procentry to announce. */
|
|
|
|
PUBLIC int profile_get_announce(void)
|
|
|
|
{
|
|
|
|
return CPROF_ACCOUNCE_KERNEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The kernel "announces" its control struct and table locations
|
|
|
|
* to itself through this function.
|
|
|
|
*/
|
|
|
|
PUBLIC void profile_register(ctl_ptr, tbl_ptr)
|
|
|
|
void *ctl_ptr;
|
|
|
|
void *tbl_ptr;
|
|
|
|
{
|
2008-11-19 13:26:10 +01:00
|
|
|
int proc_nr;
|
2006-10-30 16:53:38 +01:00
|
|
|
vir_bytes vir_dst;
|
|
|
|
struct proc *rp;
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
if(cprof_procs_no >= NR_SYS_PROCS)
|
|
|
|
return;
|
|
|
|
|
2006-10-30 16:53:38 +01:00
|
|
|
/* Store process name, control struct, table locations. */
|
2008-11-19 13:26:10 +01:00
|
|
|
rp = proc_addr(SYSTEM);
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
cprof_proc_info[cprof_procs_no].endpt = rp->p_endpoint;
|
|
|
|
cprof_proc_info[cprof_procs_no].name = rp->p_name;
|
2008-11-19 13:26:10 +01:00
|
|
|
cprof_proc_info[cprof_procs_no].ctl_v = (vir_bytes) ctl_ptr;
|
|
|
|
cprof_proc_info[cprof_procs_no].buf_v = (vir_bytes) tbl_ptr;
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
cprof_procs_no++;
|
|
|
|
}
|
|
|
|
|
2009-02-06 17:31:28 +01:00
|
|
|
#endif
|