Commit Graph

19 Commits

Author SHA1 Message Date
Ingo Weinhold 7ab39de989 * Removed unused SMP_MSG_RESCHEDULE ICI message.
* Introduced flag "invoke_scheduler" in the per CPU structure. It is
  evaluated in hardware_interrupt() (x86 only ATM).
* Introduced SMP_MSG_RESCHEDULE_IF_IDLE message, which enters the
  scheduler when the CPU currently runs an idle thread.
* Don't do dprintf() "CPU x halted!" when handling a SMP_MSG_CPU_HALT
  ICI message. It uses nested spinlocks and could thus potentially
  deadlock itself (acquire_spinlock() processes ICI messages, so it
  could already hold one of the locks). This is a pretty likely scenario
  on machines with more than two CPUs, but is also possible when the
  panic()ing thread holds the threads spinlock. Probably fixes #2572.
* Reworked the way the kernel debugger is entered and added a "cpu"
  command that allows switching the CPU once in KDL. It is thus possible
  to get a stack trace of the thread not on the panic()ing CPU.
* When a thread is added to the run queue, we do now check, if another
  CPU is idle and ask it to reschedule, if it is. Before this change, the
  CPU was continuing to idle until the quantum of the idle thread
  expired. Speeds up the libbe.so build about 8% on my machine (haven't
  tested the full Haiku image build yet).
* When spinlock debugging is enabled (DEBUG_SPINLOCKS) we also record
  the spinlock acquirer on non-smp machines. Added "spinlock" debugger
  command to get the info.
* Added debugger commands "ici" and "ici_message", printing info on
  pending ICI message respectively on a given one.
* Process not only a single ICI message in acquire_spinlock() and other
  places, but all pending ones.
* Also process ICI messages when waiting for a free one -- avoids a
  potential deadlock.
* Mask out non-existing CPUs in send_multicast_ici(). panic() instead of
  just returning when there's no target CPU left.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28223 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-10-17 18:14:08 +00:00
Ingo Weinhold 78c90d44ca Moved definition of the PAUSE macro to <cpu.h>, respectively
<arch/cpu.h>.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28221 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-10-17 16:53:31 +00:00
Travis Geiselbrecht badc7b674e yet another fix for #1018, which has at this point blossomed into a reorg of how AP cpus are initialized.
the new cpuid stuff was apparently exacerbating an existing problem where various bits of low level
cpu code (specifically get_current_cpu) weren't really initialized before being used. Changed the
order to set up a fake set of threads to point each cpu at really early in boot to make sure that at
all points in code it can get the current 'thread' and thus the current cpu.
A probably better solution would be to have dr3 point to the current cpu which would then point to the 
current thread, but that has a race condition that would require an int disable, etc.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20160 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 00:11:24 +00:00
Travis Geiselbrecht dcdc4f4b43 pulled over some stuff from newos:
at boot, per cpu, detect the cpu, pull down all the relevant cpuid bits and
save them into the per-cpu structure. Changed most of the code scattered here
and there that reads the cpuid to use a new api, x86_check_feature, which looks
at the saved bits.
Also changed the system_info stuff to read from these bits.
While i was at it, refreshed all the bits to be current.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20072 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-05 01:46:28 +00:00
Michael Lotz 17fee3eab7 Removed the extra info struct in the cpu_ent union and made said union a struct instead. Same as r1137 in NewOS.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17273 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-29 22:38:19 +00:00
Michael Lotz 2a03240eb1 Reverted my last change as it turned out that the lazy FPU state handling was not SMP safe afterall and the performance gain is questionable. Maybe it'll be implemented correctly in the future. Sorry for any inconvenience this may have cost.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17272 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-29 22:10:04 +00:00
Michael Lotz 7eee76e65a Implemented lazy FPU state save/restore. In the end mostly ported from NewOS. SMP safe.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17251 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-27 22:02:48 +00:00
Axel Dörfler d14aab0dca Changed the way how CPU activity is monitored: instead of taking the active
time of the idle thread as a measure, we now compute the CPU activity on
each thread switch - the time the CPU worked is the total of user and kernel
time a thread spent during its quantum.
Unlike before, this mechanism works correctly on SMP machines. I hope this
works as expected :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16193 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-02-01 20:03:55 +00:00
Axel Dörfler df213cedbc * CPUs can now be disabled - that is, they will keep idling.
* Added syscalls _kern_set_cpu_enabled() and _kern_cpu_enabled().
* scheduler.c::sRunQueue::tail was not maintained at all; changed sRunQueue to
  be a simple thread pointer instead of a struct thread_queue.
* Turns out we're monitoring CPU activity incorrectly when we've got more
  than one CPU.
* Renamed the global CPU array from "cpu" to gCPU.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16186 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-02-01 16:09:05 +00:00
Axel Dörfler 51a3c450be The short story: we now have MTRR support on Intel and AMD CPUs (the latter
has not yet been tested, though - I'll do this after this commit):
* Removed the arch_memory_type stuff from vm_area; since there are only 8 memory
  ranges on x86, it's simply overkill. The MTRR code now remembers the area ID
  and finds the MTRR that way (it could also iterate over the existing MTRRs).
* Introduced some post_modules() init functions.
* If the other x86 CPUs out there don't differ a lot, MTRR functionality might
  be put back into the kernel.
* x86_write_msr() was broken, it wrote the 64 bit number with the 32 bit words
  switched - it took me some time (and lots of #GPs) to figure that one out.
* Removed the macro read_ebp() and introduced a function x86_read_ebp()
  (it's not really a time critical call).
* Followed the Intel docs on how to change MTRRs (symmetrically on all CPUs
  with caches turned off).
* Asking for memory types will automatically change the requested length to
  a power of two - note that BeOS seems to behave in the same, although that's
  not really very clean.
* fixed MTRRs are ignored for now - we should make sure at least, though,
  that they are identical on all CPUs (or turn them off, even though I'd
  prefer the BIOS stuff to be uncacheable, which we don't enforce yet, though).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-13 16:34:29 +00:00
Axel Dörfler 7c0a93573b Preparation for MTRR support, code is completely untested, though.
The CPU specific MTRR code will be in modules.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15520 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-12 17:04:36 +00:00
Axel Dörfler 6cd505cee7 Changed the boot procedure a bit.
Extracted scheduler_init() from start_scheduler() (which is now called scheduler_start()).
Moved scheduler related function prototypes from thread.h to the new scheduler.h.
Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14518 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-25 16:59:12 +00:00
Axel Dörfler a36a94da37 Added the missing clear_caches() function and syscall. Does not yet do anything (which
is perfectly okay on x86 anyway, but should be moved into the arch stuff).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11869 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-03-17 17:06:56 +00:00
Axel Dörfler b0d8e689ac Renamed some more init2 routines to init_post_vm() to make it clearer when
and why they are called.
Introduced a cpu_init_post_vm() that will now call arch_init_post_vm() instead
of letting main() doing it.
Fixed some return types (mostly from int to status_t).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9438 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-10-21 01:41:29 +00:00
Axel Dörfler 35c681e031 Ah, that looks better (and actually works...).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7791 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-06-07 02:06:04 +00:00
Axel Dörfler 67efc07974 MAX_BOOT_CPUS is defined in kernel_args.h so we better include it.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7790 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-06-07 02:03:29 +00:00
Axel Dörfler 564cba312e Some header work: removed unnecessary dependencies to stage2.h, fixed
some broken C++ export definitions, added missing licenses etc.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3152 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-05-03 16:03:26 +00:00
lillo 2880b9ff65 beos compatible timer routines and style cleanups in timer and sem code; also doxygened timer.h
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@354 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-07-20 22:53:23 +00:00
ejakowatz 52a3801208 It is accomplished ...
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-07-09 12:24:59 +00:00