Skip to content
Snippets Groups Projects
  1. Jan 27, 2014
  2. Jan 22, 2014
  3. Jan 20, 2014
  4. Jan 19, 2014
  5. Jan 17, 2014
  6. Jan 16, 2014
    • Nadav Har'El's avatar
      Fix regression in early output to stdout · 5d9e5e7c
      Nadav Har'El authored
      
      Output to stdout normally goes to file descriptor 1. However, during
      early boot, before the console is opened on file descriptor 1, we also
      want printf() to work. So this case is specially treated in
      libc/stdio/__stdout_write.cc, where in this early case, we used debug_write
      directly, instead of write to the file descriptor.
      
      However, recent patches changed debug_write to write to a memory buffer,
      instead of to screen (unless "--verbose" option is given to the loader).
      This made early printf() break too.
      
      This patch changes __stdout_write to use console::write(), not
      debug_write(). To use console::write(), I had to convert that source
      file to C++.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      5d9e5e7c
  7. Jan 15, 2014
  8. Jan 13, 2014
  9. Jan 10, 2014
    • Glauber Costa's avatar
      libc: support more time modes · bcc2fbb8
      Glauber Costa authored
      
      We are currently only answering requests for CLOCK_REALTIME, but we could
      easily handle:
      
          * CLOCK_REALTIME_COARSE, which is effective the same as CLOCK_REALTIME
            but faster. In our case, all time sources are equally fast
          * CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, since we can
            easily get runtimes for our threads and publish that.
      
      Signed-off-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      bcc2fbb8
    • Nadav Har'El's avatar
      clock: add monotonic uptime clock · 8dffa912
      Nadav Har'El authored
      
      This patch starts to solve both issue #142 ("Support MONOTONIC_CLOCK")
      and issue #81 (use <chrono> for time).
      
      First, it adds an uptime() function to the "clock" interface, and
      implements it for kvm/xen/hpet by returning the system time from which
      we subtract the system time at boot (but not adding any correction
      for wallclock).
      
      Second, it adds a new std::chrono-based interface to this clock, in
      a new header file <osv/clock.hh>. Instead of the old-style
      clock::get()->uptime(), one should prefer osv::clock::uptime::now().
      This returns a std::chrono::time_point which is type-safe, in the
      sense that: 1. It knows what its epoch is (i.e., that it belongs to
      osv::clock::uptime), and 2. It knows what its units are (nanoseconds).
      This allows the compiler to prevent a user from confusing measurements
      from this clock with those from other clocks, or making mistakes in
      its units.
      
      Third, this patch implements clock_gettime(MONOTONIC_CLOCK), using
      the new osv::clock::uptime::now().
      
      Note that though the new osv::clock::uptime is almost identical to
      std::chrono::steady_clock, they should not be confused. The former is
      actually OSv's implementation of the latter: steady_clock is implemented
      by the C++11 standard library using the Posix clock_gettime, and that
      is implemented (in this patch) using osv::clock::uptime.
      
      With this patch, we're *not* done with either issues #142 or #81.
      For issue #142, i.e., for supporting MONOTONIC_CLOCK in timerfd, we
      need OSv's timers to work on uptime(), not on clock::get()->time().
      For issue #81, we should add a osv::clock::wall type too (similar to
      what clock::get()->time() does today, but more correctly), and use either
      osv::clock::wall or osv::clock::uptime everywhere that
      clock::get()->time() is currently used in the code.
      clock::get()->time() should be removed.
      
      Reviewed-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      8dffa912
  10. Jan 08, 2014
    • Glauber Costa's avatar
      string: implement memmove using memcpy · 856bb361
      Glauber Costa authored
      
      The current implementation of memmove is a PITA (I mean the bread, of course)
      to decode if a fault happens. We have very little control of where exactly in
      the code the fault happens, therefore it is difficult to reason about it. This
      patch implements memmove in terms of memcpy + memcpy_backwards.
      
      For those, we can have specific fixups in the possible fault sites, that will
      allow us to decode the faults with ease.
      
      Note that originally, the only reason why the first branch was not a memcpy is
      that we would like to handle alignment. Since our implementation of memcpy is
      fast enough, we can just ignore that and we will end up being even faster.
      
      Signed-off-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      856bb361
    • Nadav Har'El's avatar
      Refactor timerfd.cc · cb19cf98
      Nadav Har'El authored
      
      In his review of timerfd.cc, Avi asked that I simplify the implementation
      by having a single "timerfd" object (instead of two I had - timerfd_file
      and timerfd_object), and by using a single mutex instead of the complex
      combination of mutexes and atomic variable.
      
      This new version indeed does this. It should be easier to understand this
      code, and it is 30 lines shorter.
      
      The performance of this code is slightly inferior to the previous one -
      in particular poll() now locks and unlocks a mutex - but this should be
      negligible in practice.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      cb19cf98
  11. Jan 07, 2014
  12. Jan 03, 2014
  13. Jan 01, 2014
    • Nadav Har'El's avatar
      file: reduce boiler-plate code in special files · 9478a14d
      Nadav Har'El authored
      
      Each implementation of "struct file" needs to implement 8 different file
      operations. Most special file implementations, such as pipe, socketpair,
      epoll and timerfd, don't support many of these operations. We had in
      unsupported.h functions that can be reused for the unsupported operation,
      but this resulted in a lot of ugly boiler-plate code.
      
      Instead, this patch switches to a cleaner, more C++-like, method:
      It defines a new "file" subclass, called "special_file", which implements
      all file operations except close(), with a default implementation identical
      to the old unsupported.h implementations.
      
      The files of pipe(), socketpair(), timerfd() and epoll_create() now inherit
      from special_file, and only override the file operations they really want
      to implement.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      9478a14d
  14. Dec 31, 2013
  15. Dec 30, 2013
  16. Dec 24, 2013
    • Nadav Har'El's avatar
      sched: Overhaul sched::thread::attr construction · eb48b150
      Nadav Har'El authored
      
      We use sched::thread::attr to pass parameters to sched::thread creation,
      i.e., create a thread with non-default stack parameters, pinned to a
      particular CPU, or a detached thread.
      
      Previously we had constructors taking many combinations of stack size
      (integer), pinned cpu (cpu*) and detached (boolean), and doing "the
      right thing". However, this makes the code hard to read (what does
      attr(4096) specify?) and the constructors hard to expand with new
      parameters.
      
      Replace the attr() constructors with the so-called "named parameter"
      idiom: attr now only has a null constructor attr(), and one modifies
      it with calls to pin(cpu*), detach(), or stack(size).
      
      For example,
          attr()                                  // default attributes
          attr().pin(sched::cpus[0])              // pin to cpu 0
          attr().stack(4096).pin(sched::cpus[0])  // pin and non-default stack
          and so on.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      eb48b150
  17. Dec 20, 2013
    • Nadav Har'El's avatar
      Add timerfd_*() system calls · 46e73b66
      Nadav Har'El authored
      
      This patch implements the Linux's timerfd_*() system calls, declared in
      <sys/timerfd.h>. These define a file descriptor, usable for read() or
      poll() and friends, which becomes readable when a timer expires.
      
      This aspires to be a full implementation of timerfd, with all the intricate
      details explained in timerfd_create(2).
      
      timerfd was added to Linux five years ago (Linux 2.6.25). Boost's asio,
      in particular, uses this feature if it thinks it is available.
      
      Fixes #129.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      46e73b66
  18. Dec 19, 2013
  19. Dec 18, 2013
  20. Dec 15, 2013
Loading