- Jul 02, 2013
-
-
Christoph Hellwig authored
-
Christoph Hellwig authored
-
Christoph Hellwig authored
We currently stub it out so it doesn't really matter, but let's stick to the code conventions.
-
Christoph Hellwig authored
We'll get this when a lookup fails.
-
Christoph Hellwig authored
That way multiple threads can use readdir at the same time safelẏ. While not required by Posix, glibc and other common implementations work this way.
-
Christoph Hellwig authored
-
Christoph Hellwig authored
readdir_r doesn't want errno set at all, and readdir does by itself already.
-
Nadav Har'El authored
__vsnprintf_chk can be used by glibc when it knows the size of a buffer, to verify that the size parameter given to vsnprintf() doesn't overflow the buffer. Unfortunately, it happens to be used in libevent.so (used by memcached).
-
Nadav Har'El authored
When msleep() is woken up by a timeout and not wakeup(), it would leave its wait record - a pointer to a structure on the stack - in _evlist. When wakeup() or wakeup_one() is next called, it can find this structure on the stack - and it now points to random garbage (or even unmapped area, if the thread exited). This bug caused an easy to reproduce crash in memcached. The fix here is to, in case of timeout, reacquire the lock and remove this thread from _evlist - if it still there (it might no longer be there, if the timeout and wakeup raced).
-
- Jul 01, 2013
-
-
Avi Kivity authored
Timer-based thread preemption.
-
Avi Kivity authored
If a thread schedules out before its time slice expires (due to blocking) and is then made runnable and scheduled back in again, the scheduler will update the preemption timer, first cancelling it (or possibly setting it for another thread), then re-setting it for the original thread. Usually the new expiration time will be later than the original. For a context switch intensive load, this causes a lot of timer re-arms, which are fairly slow. Reduce the amount of re-arms by remembering the last expiration time we set. If the new expiration time comes after that time, don't bother rearming the timer. Instead, the expiration of the already-set timer will recalculate the expiration time and set a new expiration time. This reduces timer arming greatly, and speeds up context switches back to their performance before the preemption patches.
-
Avi Kivity authored
It will be reset during a future context switch, but best to start with a clean slate.
-
Avi Kivity authored
Make sure it starts out high so we don't see needless context switches on startup.
-
Avi Kivity authored
-
Avi Kivity authored
When switching to a new thread, or when a new thread is queued, calculate the vruntime difference to set a timer for the point in time when we need to context switch again. This change makes tst-fpu.so threads run completely in parallel.
-
Nadav Har'El authored
This patch allows to use shared libraries copied from Linux, even if they already underwent "prelink" modifications. Without this patch, if the prelinked library used one of our library functions (e.g., malloc()), its address would not be correctly calculated, and the call will be made to a random address, and crash. A few details about the problem and the fix: When using a function from a shared library, calls go to a ".plt" function, which, to make a long story short, jumps to a address written in the ".plt.got" entry for this function. Normally, and this is what the existing code expected, the .plt.got entry is initialized to point to the second instruction in the .plt function (after the jump), which calls the linker to look up the function. This allows lazy symbol lookup, but after the lookup, the next calls to the PLT function will jump to the right function address immediately. But prelinking changes that - the prelinker looks up the symbols once and fills the .plt.got with the addresses it assigned to the functions in the other library. These addresses do not make any sense in the context of OSV (or any other system besides the one that the prelinker ran on), so we cannot use them, and instead need to overwrite them again with links to the .plt functions.
-
Avi Kivity authored
Change the condition for expiration to allow an exact match between the current time and the timer expiration time. This helps the scheduler keep going when the clock is still not running during system startup. Ideally we shouldn't depend on such details, but fixing this is too complicated for now.
-
Avi Kivity authored
We set the idle thread's vruntime at the maximum possible, to ensure it has the lowest priority, but this can cause an overflow when we add the idle thread's running time. Detect the overflow and prevent it.
-
Avi Kivity authored
Since vruntime needs to be advanced by (scaled) running time, when a thread starts running, we subtract the start clock value (t1), and when it stops, we add the stop clock value (t2), with the end result that we add t2-t1, or the running time. While this works, it makes the code less readable, since the meaning of _vruntime is drastically different for running threads - its the vruntime minus the reading of the clock at some point in the past. Simplify by not doing this, and instead keeping the start time in a separate field (running_since). Note _vruntime for a running thread is still subtly different from that of a stopped thread, since we need to add this delta time.
-
Avi Kivity authored
kvmclock doesn't work before the scheduler is fully initialized, so work around it.
-
Avi Kivity authored
Currently, current() is set during the thread initialization sequence, which means that preemption prior to that point will see the wrong current(). There's an irq_enable() there, but it's not very effective since interrupts are only disabled in that place during early smp bringup, and it's not trivial to disable interrupts for all new threads (we?
-
Avi Kivity authored
This is useful for setting up important thread local variables such as s_current. Since it's quite specialized it's kept private for the moment.
-
Avi Kivity authored
Currenly we initialize the idle thread in the cpu's constructor, which leads to a cycle, since a thread's initialization needs the cpu. This works out somehow now, but is fragile and will break with succeeding patches. Defer idle thread initialization to a later stage.
-
Avi Kivity authored
Such as the scheduler.
-
Avi Kivity authored
We disable interrupts in spinlocks as a way of disabling preemption, since preemption with spinlock held will lead to deadlock. However, we don't restore the interrupt flag to its previous state, so we end up inadvertantly enabling interrupts if the lock was taken with interrupts disabled in the first place. Fix by switching to preempt_disable() instead of disabling interrupts. Since spinlocks are only used by the debug code, it doesn't matter much.
-
Avi Kivity authored
Usually we don't care if threads are started with preemption enabled or disabled, since interrupts are disabled and no preemption can take place during thread startup. However during system bringup we want to avoid calls into the scheduler while it is being initialized due to stray preempt_enable() calls. Do this by initializing preempt_counter to 1, and dropping it during thread start-up.
-
Avi Kivity authored
Easier to compute deltas. Limits range to 292 years.
-
Avi Kivity authored
-
Avi Kivity authored
We want to use timers for more than just waking up threads (in this case, for the scheduler time slice), so we need to remove the internal dependencies. The timer class is split into timer_base, which does most of the work, and timer, which preserves the original timer interface. The timer-related parts of 'class thread' are split off into a new class timer_base::client, which thread inherits from.
-
Avi Kivity authored
Timers currently have two states: expired, and not expired. But how is cancel() to distinguish between an armed-but-not-expired timer, and a timer which was never armed (using set())? It can't, and will probably crash. Fix by adding a state to the timer. Now there are three distinct states: free, armed, and expired, corresponding to the timer life cycle.
-
Avi Kivity authored
This makes it easier to debug faults that happen in interrupts (e.g. in the scheduler) Note that this means we cannot schedule within an exception (e.g. a page fault) for now, since the exception stack is per-cpu while the interrupt stack is per-thread (which allow scheduling). If/when we implement scheduling within the page fault handler, we'll either need to trampoline to the interrupt stack, or have a per-thread exception stack.
-
Glauber Costa authored
Import the whole xen/interface.h directory (disk space is cheap, going through each file seeing what we need and what we don't is not)
-
- Jun 30, 2013
-
-
Dor Laor authored
The optimization improves performance by letting each side of the ring know what was the last index read by the remote party. In case were the other side has older indexes, waiting for processing we won't trigger another update (kick or irq, depending on the direction). The optimization reduces irq injection by a 7%. Along the way, collapse vring::need_event to the code and use std::atomic(s) to access any variable which is shared w/ the host
-
Guy Zana authored
-
Guy Zana authored
-
Guy Zana authored
-
Guy Zana authored
mainargs is a String[] set by Java (see RhinoCLI.java), some of the commands that access the elements of this array fail because the strings are Java strings and not Javascript strings. this patch perform a proper cast on init(), just before invoking the command. now it's also possible to start a test from the command line, like so: $ sudo ./scripts/run.py -n -e "java.so -jar /java/cli.jar test <test-name>" -c2 -m1G
-
Avi Kivity authored
Example: test foo &
-
Nadav Har'El authored
Implement getpwname(), setuid() and setgid() in the simplest way possible considering that we don't support any userid except 0: getpwname() returns user 0 for any username given to it. setuid() and setgid() does nothing for uid or gid 0, otherwise fails. Where would the caller get this !=0 id anyway? Memcached needs these calls, because it wants to be clever and warn the user against running it as root....
-
Nadav Har'El authored
Implement the signal() function. This is hardly a useful function in OSV, first because our signal support is pretty broken, and second because sigaction() is a much more portable API that should always be preferred. Nevertheless, memcached uses signal() (to catch SIGINT, which it will never get in OSV...), so let's implement it for the sake of completeness.
-