Skip to content
Snippets Groups Projects
  1. Jun 10, 2013
  2. Jun 09, 2013
    • Nadav Har'El's avatar
      lazy_indirect: typos in comment · 3302a1aa
      Nadav Har'El authored
      3302a1aa
    • Nadav Har'El's avatar
      Add, and use, new abort(msg) function · e6208f1e
      Nadav Har'El authored
      Recently Guy fixed abort() so it will *really* not infinitely recurse trying
      to print a message, using a lock, causing a new abort, ad infinitum.
      
      Unfortunately, that didn't fix one remaining case: DUMMY_HANDLER (see
      exceptions.cc) used the idiom
      
              debug(....); abort();
      
      which can again cause infinite recursion - a #GP calls debug() which causes a
      new #GP, which again calls debug, etc.
      
      Instead of the above broken idiom, created a new function abort(msg), which is
      just like the familiar abort(), just changes the "Aborted" message to some
      other message (a constant string). Like abort(), the new variant abort(msg) will
      only print the message once even if called recursively - and uses a lockless
      version of debug().
      
      Note that the new abort(msg) is a C++-only API. C will only see the abort(void)
      which is extern "C". At first I wanted to call the new function panic(msg) and
      export it to C, but gave when I saw the name panic() was already in use in a
      bunch of BSD code.
      e6208f1e
    • Nadav Har'El's avatar
      Add a simpler tracepoint syntax · 3cd499af
      Nadav Har'El authored
      Before this patch tracepoints required manual tracepoint numbers:
      
          tracepoint<17, unsigned int> trace_event1("event1", "%d");
          tracepoint<18> trace_event2("event2", "");
      
      While the numbers only had to be unique in the file, so it wasn't hard to
      achieve, this was still tedious and verbose.
      
      This patch adds an additional, shorter, tracepoint syntax, not requiring
      those numbers and in general less repetitive and clearer:
      
          TRACEPOINT(trace_event1, "%d", unsigned int);
          TRACEPOINT(trace_event2, "");
      
      The first parameter is the name of the generated tracepoint function -
      it's convenient to see it so that grep can find it, for example.
      The name of the tracepoint itself (shown in "osv trace") is this string
      without the prefix trace_ (if the name of the tracepoint function, for some
      reason, doesn't start with trace_, the full function name is used as the
      tracepoint name).
      3cd499af
    • Guy Zana's avatar
      callouts: perform wake() outside of lock. · fb97aadf
      Guy Zana authored
      given the scheduler state, wake() sometimes rescheduled the dispatcher thread
      immidiately, and then it blocked on the mutex that is still held by the caller
      of _callout_stop_safe_locked().
      
      this patch does wake() outside of the lock to eliminated these spurious context
      switches.
      fb97aadf
    • Guy Zana's avatar
      41360613
    • Guy Zana's avatar
      tst-sockets: return an error if poll fails · 5a298ef9
      Guy Zana authored
      5a298ef9
    • Guy Zana's avatar
      logger: remove not very useful logger tags · f806a014
      Guy Zana authored
      controlling the logger output in tests is simplistic, it is enough to
      change the severity level to logger_error and all logging messages
      will appear.
      f806a014
    • Guy Zana's avatar
      virtio: remove some extra verbose debug messages · f928d509
      Guy Zana authored
      next patch is changing the debug function to tprintf_d, which may be
      implemented as do{}while(0) in case conf-logger_debug=0, in this case
      compilation breaks complaining about unused variables.
      
      these debug prints are not very useful today, so I remove them. Instead,
      they may be implemented as tracepoints.
      f928d509
    • Guy Zana's avatar
      make: added conf-logger_debug option which is on when mode=debug · 9da6f1bc
      Guy Zana authored
      the conf-logger_debug option control whether tprintf_d (verbose debug
      logging) is enabled at all, if it is set to 0 then tprintf_d is
      implemented as do{}while(0)
      9da6f1bc
    • Guy Zana's avatar
      bf7fe5e7
    • Avi Kivity's avatar
      trace: record time for a tracepoint · 82491864
      Avi Kivity authored
      82491864
    • Avi Kivity's avatar
      clock: don't instrument · c19dfddc
      Avi Kivity authored
      We want to use the clock in tracepoints.
      c19dfddc
    • Avi Kivity's avatar
      sched: add tracepoint for preemption events · 76dae193
      Avi Kivity authored
      76dae193
    • Nadav Har'El's avatar
      lock-free mutex: add C API for lockfree::mutex methods · d3c156d8
      Nadav Har'El authored
      Add some extern "C" versions of the lockfree::mutex methods. They will be
      necessary for providing the lockfree::mutex type to C code - as you'll see
      in later patches, C code will see an opaque type, a byte array, and will
      call these functions to operate on it.
      d3c156d8
    • Nadav Har'El's avatar
      lock-free mutex: Avoid including <sched.hh> in <lockfree/mutex.hh> · 874b10ee
      Nadav Har'El authored
      Do not include <sched.hh> in <lockfree/mutex.hh>.
      
      Including <sched.hh> creates annoying dependency loops when we (in a
      later patch) replace <osv/mutex.h> by <lockfree/mutex.hh>, and some header
      files included by <sched.hh> themselves use mutexes, so they include
      <osv/mutex.h>. This last include does nothing (because of the include guard)
      but the compiler never finished reading osv/mutex.h (it was only in its
      beginning, when it included sched.hh) so the inner-included code lacks the
      definitions it assumes after including mutex.h.
      874b10ee
    • Nadav Har'El's avatar
      lockfree mutex: add owned() and getdepth() methods · 1ed9c982
      Nadav Har'El authored
      Add to lockfree::mutex the simple owned() and getdepth() methods which
      existed in ::mutex and were used in a few places - so we need these
      methods to switch from ::mutex to lockfree::mutex.
      1ed9c982
    • Nadav Har'El's avatar
      lockfree mutex: fix wait/wake bug · 9bcf790a
      Nadav Har'El authored
      When I developed lockfree mutex, the scheduler, preemption, and related code
      still had a bunch of bugs, so I resorted to some workarounds that in hindsite
      look unnecessary, and even wrong.
      
      When it seemed that I can only wake() a thread in wait state, I made an
      effort to enter the waiting state (with "wait_guard") before adding the
      thread to the to-awake queue, and then slept with schedule(). The biggest
      problem with this approach was that a spurious wake(), for any reason, of
      this thread, would cause us to end the lock() - and fail on an assert that
      we're the owners of the lock - instead of repeating the wait. When switching
      to lockfree mutex, the sunflow benchmark (for example) would die on this
      assertion failure.
      
      So now I replaced this ugliness with our familiar idiom, wait_until().
      The thread is in running state for some time after entering queue, so
      it might be woken when not yet sleeping and the wake() will be ignored -
      but this is fine because part of our protocol is that the wake() before
      waking also sets "owner" to the to-be-woken thread, and before sleeping
      we check if owner isn't already us.
      
      Also changed the comment on "owner" to say that it is not *just* for
      implementing a recursive mutex, but also nessary for the wakeup protocol.
      9bcf790a
    • Nadav Har'El's avatar
      Implement shutdown() on unix domain sockets · 30f6e9dd
      Nadav Har'El authored
      The existing shutdown() code only worked with AF_INET sockets, and returned
      ENOTSOCK for AT_LOCAL sockets, because we implemented the latter sockets in
      completely different code (in af_local.cc).
      
      So in uipc_syscalls_wrap.c, the same place we call a the special af-local
      socketpair(), we also need to call the special af-local shutdown().
      
      The way we do it is a bit ugly, but effective: shutdown() first calls
      shutdown_af_local(), and if that returns ENOTSOCK (so it's not an af_local
      socket), we continue trying the regular socket shutdown code.
      
      A better way would have been to add shutdown() to the fileops table -
      either the generic one (why not?), or invent a new mechanism whereby
      certain file types (in this case, "sockets" of all types) can have additional
      ops tables including in this case a shutdown() operation. Linux has
      something of this sort for implementing shutdown().
      30f6e9dd
  3. Jun 06, 2013
  4. Jun 05, 2013
    • Avi Kivity's avatar
      trace: improve fast path · b03979d9
      Avi Kivity authored
      When a tracepoint is disabled, we want it to have no impact on running code.
      
      This patch changes the fast path to be a single 5-byte nop instruction.  When
      a tracepoint is enabled, the nop is patched to a jump instruction to the
      out-of-line slow path.
      b03979d9
    • Avi Kivity's avatar
      trace: add unique ID for tracepoints · 0102df29
      Avi Kivity authored
      In order to optimize the fast path of tracepoints, we need to patch
      the call sites to skip calling the slow path code completely.  In turn,
      that requires that each call site be unique -- a separate function.
      
      In the current implementations, tracepoints with the same signature map
      to the same type.  It would have been great to use the name as a discriminant
      (tracepoint<"sched_queue", thread*> trace_sched_queue(...);), but C++ does
      not support string literals as template arguments.
      
      We could do
      
        const char* trace_sched_queue_name = "sched_queue";
        tracepoint<trace_sched_queue_name, thread*> trace_sched_queue(...);
      
      but that doubles the code for declaring a tracepoint.  Add a unique ID instead
      (and code to verify it is unique).
      0102df29
    • Nadav Har'El's avatar
      lockfree::mutex functions should not be inline · cb41801a
      Nadav Har'El authored
      Until now, lockfree::mutex functions were entirely inline, which won't
      fly if we want to make it our default mutex. Change them to be out-of-line,
      implemented in a new source file core/lfmutex.cc.
      
      This has a slight performance impact - uncontended lock/unlock pair used
      to be 17ns, and is now 22ns.
      
      In the future we can get this performance back by making these functions
      partially inline (the uncontended case inline, the waiting case in a
      separate function), although we'll need to consider the speed/code-size
      tradeoff.
      cb41801a
    • Nadav Har'El's avatar
      Loader: show demangled symbol name on lookup failure · b39289cf
      Nadav Har'El authored
      When abort()ing on failed symbol lookup, if this is a C++ symbol, also
      show its demangled form, which in many case can be more helpful.
      Here is an example lookup failure now:
      
      failed looking up symbol _ZN8lockfree5mutex4lockEv (lockfree::mutex::lock())
      Aborted
      b39289cf
    • Nadav Har'El's avatar
      Speed up lockfree::mutex uncontended case · 423f109b
      Nadav Har'El authored
      Significantly speed up lockfree::mutex's uncontended case, by avoiding
      sequential memory ordering in atomic operations. I *think* I did this
      correctly, but can't be really sure ;-) Moreover, I didn't change the
      memory ordering on the rarer cases, and these should also be reduced in
      the future.
      
      Uncontended lock&unlock of lockfree::mutex is now 17ns. This is faster
      than the previous mutex (24ns) but slower than spinlock (10ns).
      423f109b
  5. Jun 04, 2013
    • Nadav Har'El's avatar
      Fix argv handling in RunJava · b4d67a4a
      Nadav Har'El authored
      The recent change, to add the program name as argv[0] for C code's
      main(), make sense for C code, but less for Java code, where main()
      normally expects args[0] to be the first argument, not the program name.
      
      So the change to RunJava.java was un-Java-like; It also broke the "java"
      CLI command which didn't put "java" in argv[0] for the arguments to
      RunJava.main(), so the "java" command no longer worked after the previous
      patch.
      
      Instead, we change java.cc (which compiles to java.so). This is what
      calls RunJava.class, and it should remove the new argv[0] before calling its
      main() - instead of expecting that RunJava.class to do this.
      b4d67a4a
    • Guy Zana's avatar
      32f99535
    • Guy Zana's avatar
      fix logging in select · b87d2d26
      Guy Zana authored
      b87d2d26
    • Guy Zana's avatar
      loader: don't consume one element of argv before running main() · 1e7452c8
      Guy Zana authored
      the convention in linux is that argv[0] holds the program executable.
      I had an attempt to run netserver not from the CLI and it didn't work because
      its argument parsing got broken.
      1e7452c8
    • Nadav Har'El's avatar
      CLI: Allow running a single command non-interactively · 496d27f8
      Nadav Har'El authored
      Added the possibility to pass to cli.jar a command, which it runs instead
      of taking commands interactively. Note that the initialization script is
      run before the given command.
      
      After this patch,
      
              scripts/run.py -e "java.so -jar /java/cli.jar"
      
      Continues to run the interactive command line editor loop, as before.
      But additionally, one can do:
      
              scripts/run.py -e "java.so -jar /java/cli.jar ls"
      
      To run just the command "ls" and exit - exactly as if the user would type
      this command on the command line and exit the VM.
      
      The given command can be, of course, much longer. For example to run Jetty
      after the CLI's normal initialization script, the following monster can
      be used:
      
      scripts/run.py -n -e "java.so -jar /java/cli.jar java -classpath /jetty/* org.eclipse.jetty.xml.XmlConfiguration /jetty/jetty.xml"
      
      (Funny how a single command should say "java" 3 times and "jetty" 4 times :-))
      496d27f8
    • Nadav Har'El's avatar
      CLI: Add "java" command · 01cb7973
      Nadav Har'El authored
      Add a "java" command to the CLI, using the same syntax of java.so and
      attempting to emulate as closely as possible the "java" command on Linux.
      So for example one can run
      
              java Hello
      
      to run /java/Hello.class (/java is on the classpath by default), or
      
              java -jar /java/bench.jar
      
      to run the main class of this jar, or a more sophisticated
      command lines, such as the following which runs Jetty (if the
      appropriate files are in your image):
      
              java -classpath /jetty/* org.eclipse.jetty.xml.XmlConfiguration /jetty/jetty.xml
      
      Note that like java.so, the new "java" command basically runs the RunJava
      class (/java/RunJava.class). Remember that java.so adds /java to the parent
      class loader, so we can always find the RunJava class even though it's not
      in cli.jar or cloudius.jar).
      01cb7973
    • Nadav Har'El's avatar
      Nonblocking pipes · 1fa558ef
      Nadav Har'El authored
      This patch adds support for O_NONBLOCK on pipes and unix domain sockets.
      
      Java's EPollSelectorImpl uses a pipe to interrupt a sleeping poll, and it,
      quite understandably, sets them to non-blocking (if you only write a
      single byte to a pipe, you don't expect any blocking anyway).
      So we can't croak if this option is used, and better just implement it
      correctly.
      1fa558ef
Loading