Skip to content
Snippets Groups Projects
  1. Jun 12, 2019
    • Markus Armbruster's avatar
      Include qemu-common.h exactly where needed · a8d25326
      Markus Armbruster authored
      
      No header includes qemu-common.h after this commit, as prescribed by
      qemu-common.h's file comment.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-5-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
      block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
      target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
      target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
      target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
      target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
      net/tap-bsd.c fixed up]
      a8d25326
  2. Mar 12, 2018
    • Paolo Bonzini's avatar
      membarrier: introduce qemu/sys_membarrier.h · c8d3877e
      Paolo Bonzini authored
      
      This new header file provides heavy-weight "global" memory barriers that
      enforce memory ordering on each running thread belonging to the current
      process.  For now, use a dummy implementation that issues memory barriers
      on both sides (matching what QEMU has been doing so far).
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c8d3877e
    • Paolo Bonzini's avatar
      rcu: make memory barriers more explicit · 77a8b846
      Paolo Bonzini authored
      
      Prepare for introducing smp_mb_placeholder() and smp_mb_global().
      The new smp_mb() in synchronize_rcu() is not strictly necessary, since
      the first atomic_mb_set for rcu_gp_ctr provides the required ordering.
      However, synchronize_rcu is not performance critical, and it *will* be
      necessary to introduce a smp_mb_global before calling wait_for_readers().
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      77a8b846
  3. Dec 21, 2017
    • Yang Zhong's avatar
      rcu: reduce more than 7MB heap memory by malloc_trim() · 5a22ab71
      Yang Zhong authored
      
      Since there are some issues in memory alloc/free machenism
      in glibc for little chunk memory, if Qemu frequently
      alloc/free little chunk memory, the glibc doesn't alloc
      little chunk memory from free list of glibc and still
      allocate from OS, which make the heap size bigger and bigger.
      
      This patch introduce malloc_trim(), which will free heap
      memory when there is no rcu call during rcu thread loop.
      malloc_trim() can be enabled/disabled by --enable-malloc-trim/
      --disable-malloc-trim in the Qemu configure command. The
      default malloc_trim() is enabled for libc.
      
      Below are test results from smaps file.
      (1)without patch
      55f0783e1000-55f07992a000 rw-p 00000000 00:00 0  [heap]
      Size:              21796 kB
      Rss:               14260 kB
      Pss:               14260 kB
      
      (2)with patch
      55cc5fadf000-55cc61008000 rw-p 00000000 00:00 0  [heap]
      Size:              21668 kB
      Rss:                6940 kB
      Pss:                6940 kB
      
      Signed-off-by: default avatarYang Zhong <yang.zhong@intel.com>
      Message-Id: <1513775806-19779-1-git-send-email-yang.zhong@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      5a22ab71
  4. Aug 08, 2017
  5. Oct 24, 2016
  6. Feb 04, 2016
  7. Sep 16, 2015
  8. Sep 09, 2015
  9. Aug 14, 2015
    • Wen Congyang's avatar
      rcu: Allow calling rcu_(un)register_thread() during synchronize_rcu() · c097a60b
      Wen Congyang authored
      
      If rcu_(un)register_thread() is called together with synchronize_rcu(),
      it will wait for the synchronize_rcu() to finish. But when synchronize_rcu()
      waits for some events, we can modify the list registry.
      We also use the lock rcu_gp_lock to assume that synchronize_rcu() isn't
      executed in more than one thread at the same time. Add a new mutex lock
      rcu_sync_lock to assume it and rename rcu_gp_lock to rcu_registry_lock.
      Release rcu_registry_lock when synchronize_rcu() waits for some events.
      
      Signed-off-by: default avatarWen Congyang <wency@cn.fujitsu.com>
      Message-Id: <55B59652.4090503@cn.fujitsu.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c097a60b
  10. Jul 24, 2015
  11. Apr 01, 2015
    • Paolo Bonzini's avatar
      rcu: do not create thread in pthread_atfork callback · a59629fc
      Paolo Bonzini authored
      
      If QEMU forks after the CPU threads have been created, qemu_mutex_lock_iothread
      will not be able to do qemu_cpu_kick_thread.  There is no solution other than
      assuming that forks after the CPU threads have been created will end up in an
      exec.  Forks before the CPU threads have been created (such as -daemonize)
      have to call rcu_after_fork manually.
      
      Notably, the oxygen theme for GTK+ forks and shows a "No such process" error
      without this patch.
      
      This patch can be reverted once the iothread loses the "kick the TCG thread"
      magic.
      
      User-mode emulation does not use the iothread, so it can also call
      rcu_after_fork.
      
      Reported by: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Tested by: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a59629fc
  12. Mar 10, 2015
    • Paolo Bonzini's avatar
      rcu: handle forks safely · 21b7cf9e
      Paolo Bonzini authored
      
      After forking, only the calling thread is duplicated in the child process.
      The call_rcu thread has to be recreated in the child.  Exploit the fact
      that only one thread exists (same as when constructors run), and just redo
      the entire initialization to ensure the threads are in the proper state.
      
      The only additional things to do are emptying the list of threads
      registered with RCU, and unlocking the lock that was taken in the prepare
      callback (implementations are allowed to fail pthread_mutex_init()
      if the mutex is still locked).
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      21b7cf9e
  13. Feb 11, 2015
  14. Feb 02, 2015
    • Paolo Bonzini's avatar
      rcu: add call_rcu · 26387f86
      Paolo Bonzini authored
      
      Asynchronous callbacks provided by call_rcu are particularly important
      for QEMU, because the BQL makes it hard to use synchronize_rcu.
      
      In addition, the current RCU implementation is not particularly friendly
      to multiple concurrent synchronize_rcu callers, making call_rcu even
      more important.
      
      Reviewed-by: default avatarFam Zheng <famz@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      26387f86
    • Paolo Bonzini's avatar
      rcu: add rcu library · 7911747b
      Paolo Bonzini authored
      
      This includes a (mangled) copy of the liburcu code.  The main changes
      are: 1) removing dependencies on many other header files in liburcu; 2)
      removing for simplicity the tentative busy waiting in synchronize_rcu,
      which has limited performance effects; 3) replacing futexes in
      synchronize_rcu with QemuEvents for Win32 portability.  The API is
      the same as liburcu, so it should be possible in the future to require
      liburcu on POSIX systems for example and use our copy only on Windows.
      
      Among the various versions available I chose urcu-mb, which is the
      least invasive implementation even though it does not have the
      fastest rcu_read_{lock,unlock} implementation.  The urcu flavor can
      be changed later, after benchmarking.
      
      Reviewed-by: default avatarFam Zheng <famz@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7911747b
Loading