1. 16 6月, 2016 6 次提交
  2. 15 6月, 2016 2 次提交
  3. 14 6月, 2016 15 次提交
  4. 13 6月, 2016 2 次提交
    • M
      crypto: aes: always rename internal symbols · c8d70e59
      Mike Frysinger 提交于
      OpenSSL's libcrypto always defines AES symbols with the same names as
      qemu's local aes code.  This is problematic when enabling at least curl
      as that frequently also uses libcrypto.  It might not be noticed when
      running, but if you try to statically link, everything falls down.
      
      An example snippet:
        LINK  qemu-nbd
      .../libcrypto.a(aes-x86_64.o): In function 'AES_encrypt':
      (.text+0x460): multiple definition of 'AES_encrypt'
      crypto/aes.o:aes.c:(.text+0x670): first defined here
      .../libcrypto.a(aes-x86_64.o): In function 'AES_decrypt':
      (.text+0x9f0): multiple definition of 'AES_decrypt'
      crypto/aes.o:aes.c:(.text+0xb30): first defined here
      .../libcrypto.a(aes-x86_64.o): In function 'AES_cbc_encrypt':
      (.text+0xf90): multiple definition of 'AES_cbc_encrypt'
      crypto/aes.o:aes.c:(.text+0xff0): first defined here
      collect2: error: ld returned 1 exit status
      .../qemu-2.6.0/rules.mak:105: recipe for target 'qemu-nbd' failed
      make: *** [qemu-nbd] Error 1
      
      The aes.h header has redefines already for FreeBSD, but go ahead and
      enable that for everyone since there's no real good reason to not use
      a namespace all the time.
      Signed-off-by: NMike Frysinger <vapier@chromium.org>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c8d70e59
    • E
      vl: Eliminate usb_enabled() · 4bcbe0b6
      Eduardo Habkost 提交于
      This wrapper for machine_usb(current_machine) is not necessary,
      replace all usages of usb_enabled() with machine_usb().
      
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: qemu-arm@nongnu.org
      Cc: qemu-ppc@nongnu.org
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Message-id: 1465419025-21519-3-git-send-email-ehabkost@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      4bcbe0b6
  5. 12 6月, 2016 10 次提交
    • E
      tb hash: track translated blocks with qht · 909eaac9
      Emilio G. Cota 提交于
      Having a fixed-size hash table for keeping track of all translation blocks
      is suboptimal: some workloads are just too big or too small to get maximum
      performance from the hash table. The MRU promotion policy helps improve
      performance when the hash table is a little undersized, but it cannot
      make up for severely undersized hash tables.
      
      Furthermore, frequent MRU promotions result in writes that are a scalability
      bottleneck. For scalability, lookups should only perform reads, not writes.
      This is not a big deal for now, but it will become one once MTTCG matures.
      
      The appended fixes these issues by using qht as the implementation of
      the TB hash table. This solution is superior to other alternatives considered,
      namely:
      
      - master: implementation in QEMU before this patchset
      - xxhash: before this patch, i.e. fixed buckets + xxhash hashing + MRU.
      - xxhash-rcu: fixed buckets + xxhash + RCU list + MRU.
                    MRU is implemented here by adding an intermediate struct
                    that contains the u32 hash and a pointer to the TB; this
                    allows us, on an MRU promotion, to copy said struct (that is not
                    at the head), and put this new copy at the head. After a grace
                    period, the original non-head struct can be eliminated, and
                    after another grace period, freed.
      - qht-fixed-nomru: fixed buckets + xxhash + qht without auto-resize +
                         no MRU for lookups; MRU for inserts.
      The appended solution is the following:
      - qht-dyn-nomru: dynamic number of buckets + xxhash + qht w/ auto-resize +
                       no MRU for lookups; MRU for inserts.
      
      The plots below compare the considered solutions. The Y axis shows the
      boot time (in seconds) of a debian jessie image with arm-softmmu; the X axis
      sweeps the number of buckets (or initial number of buckets for qht-autoresize).
      The plots in PNG format (and with errorbars) can be seen here:
        http://imgur.com/a/Awgnq
      
      Each test runs 5 times, and the entire QEMU process is pinned to a
      single core for repeatability of results.
      
                                  Host: Intel Xeon E5-2690
      
        28 ++------------+-------------+-------------+-------------+------------++
           A*****        +             +             +             master **A*** +
        27 ++    *                                                 xxhash ##B###++
           |      A******A******                               xxhash-rcu $$C$$$ |
        26 C$$                  A******A******            qht-fixed-nomru*%%D%%%++
           D%%$$                              A******A******A*qht-dyn-mru A*E****A
        25 ++ %%$$                                          qht-dyn-nomru &&F&&&++
           B#####%                                                               |
        24 ++    #C$$$$$                                                        ++
           |      B###  $                                                        |
           |          ## C$$$$$$                                                 |
        23 ++           #       C$$$$$$                                         ++
           |             B######       C$$$$$$                                %%%D
        22 ++                  %B######       C$$$$$$C$$$$$$C$$$$$$C$$$$$$C$$$$$$C
           |                    D%%%%%%B######      @E@@@@@@    %%%D%%%@@@E@@@@@@E
        21 E@@@@@@E@@@@@@F&&&@@@E@@@&&&D%%%%%%B######B######B######B######B######B
           +             E@@@   F&&&   +      E@     +      F&&&   +             +
        20 ++------------+-------------+-------------+-------------+------------++
           14            16            18            20            22            24
                                   log2 number of buckets
      
                                       Host: Intel i7-4790K
      
        14.5 ++------------+------------+-------------+------------+------------++
             A**           +            +             +            master **A*** +
          14 ++ **                                                 xxhash ##B###++
        13.5 ++   **                                           xxhash-rcu $$C$$$++
             |                                            qht-fixed-nomru %%D%%% |
          13 ++     A******                                   qht-dyn-mru @@E@@@++
             |             A*****A******A******             qht-dyn-nomru &&F&&& |
        12.5 C$$                               A******A******A*****A******    ***A
          12 ++ $$                                                        A***  ++
             D%%% $$                                                             |
        11.5 ++  %%                                                             ++
             B###  %C$$$$$$                                                      |
          11 ++  ## D%%%%% C$$$$$                                               ++
             |     #      %      C$$$$$$                                         |
        10.5 F&&&&&&B######D%%%%%       C$$$$$$C$$$$$$C$$$$$$C$$$$$C$$$$$$    $$$C
          10 E@@@@@@E@@@@@@B#####B######B######E@@@@@@E@@@%%%D%%%%%D%%%###B######B
             +             F&&          D%%%%%%B######B######B#####B###@@@D%%%   +
         9.5 ++------------+------------+-------------+------------+------------++
             14            16           18            20           22            24
                                    log2 number of buckets
      
      Note that the original point before this patch series is X=15 for "master";
      the little sensitivity to the increased number of buckets is due to the
      poor hashing function in master.
      
      xxhash-rcu has significant overhead due to the constant churn of allocating
      and deallocating intermediate structs for implementing MRU. An alternative
      would be do consider failed lookups as "maybe not there", and then
      acquire the external lock (tb_lock in this case) to really confirm that
      there was indeed a failed lookup. This, however, would not be enough
      to implement dynamic resizing--this is more complex: see
      "Resizable, Scalable, Concurrent Hash Tables via Relativistic
      Programming" by Triplett, McKenney and Walpole. This solution was
      discarded due to the very coarse RCU read critical sections that we have
      in MTTCG; resizing requires waiting for readers after every pointer update,
      and resizes require many pointer updates, so this would quickly become
      prohibitive.
      
      qht-fixed-nomru shows that MRU promotion is advisable for undersized
      hash tables.
      
      However, qht-dyn-mru shows that MRU promotion is not important if the
      hash table is properly sized: there is virtually no difference in
      performance between qht-dyn-nomru and qht-dyn-mru.
      
      Before this patch, we're at X=15 on "xxhash"; after this patch, we're at
      X=15 @ qht-dyn-nomru. This patch thus matches the best performance that we
      can achieve with optimum sizing of the hash table, while keeping the hash
      table scalable for readers.
      
      The improvement we get before and after this patch for booting debian jessie
      with arm-softmmu is:
      
      - Intel Xeon E5-2690: 10.5% less time
      - Intel i7-4790K: 5.2% less time
      
      We could get this same improvement _for this particular workload_ by
      statically increasing the size of the hash table. But this would hurt
      workloads that do not need a large hash table. The dynamic (upward)
      resizing allows us to start small and enlarge the hash table as needed.
      
      A quick note on downsizing: the table is resized back to 2**15 buckets
      on every tb_flush; this makes sense because it is not guaranteed that the
      table will reach the same number of TBs later on (e.g. most bootup code is
      thrown away after boot); it makes sense to grow the hash table as
      more code blocks are translated. This also avoids the complication of
      having to build downsizing hysteresis logic into qht.
      Reviewed-by: NSergey Fedorov <serge.fedorov@linaro.org>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-15-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      909eaac9
    • E
      qht: QEMU's fast, resizable and scalable Hash Table · 2e11264a
      Emilio G. Cota 提交于
      This is a fast, scalable chained hash table with optional auto-resizing, allowing
      reads that are concurrent with reads, and reads/writes that are concurrent
      with writes to separate buckets.
      
      A hash table with these features will be necessary for the scalability
      of the ongoing MTTCG work; before those changes arrive we can already
      benefit from the single-threaded speedup that qht also provides.
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-11-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      2e11264a
    • E
      qdist: add module to represent frequency distributions of data · bf3afd5f
      Emilio G. Cota 提交于
      Sometimes it is useful to have a quick histogram to represent a certain
      distribution -- for example, when investigating a performance regression
      in a hash table due to inadequate hashing.
      
      The appended allows us to easily represent a distribution using Unicode
      characters. Further, the data structure keeping track of the distribution
      is so simple that obtaining its values for off-line processing is trivial.
      
      Example, taking the last 10 commits to QEMU:
      
       Characters in commit title  Count
      -----------------------------------
                               39      1
                               48      1
                               53      1
                               54      2
                               57      1
                               61      1
                               67      1
                               78      1
                               80      1
      qdist_init(&dist);
      qdist_inc(&dist, 39);
      [...]
      qdist_inc(&dist, 80);
      
      char *str = qdist_pr(&dist, 9, QDIST_PR_LABELS);
      // -> [39.0,43.6)▂▂ █▂ ▂ ▄[75.4,80.0]
      g_free(str);
      
      char *str = qdist_pr(&dist, 4, QDIST_PR_LABELS);
      // -> [39.0,49.2)▁█▁▁[69.8,80.0]
      g_free(str);
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-9-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      bf3afd5f
    • E
      tb hash: hash phys_pc, pc, and flags with xxhash · 42bd3228
      Emilio G. Cota 提交于
      For some workloads such as arm bootup, tb_phys_hash is performance-critical.
      The is due to the high frequency of accesses to the hash table, originated
      by (frequent) TLB flushes that wipe out the cpu-private tb_jmp_cache's.
      More info:
        https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg05098.html
      
      To dig further into this I modified an arm image booting debian jessie to
      immediately shut down after boot. Analysis revealed that quite a bit of time
      is unnecessarily spent in tb_phys_hash: the cause is poor hashing that
      results in very uneven loading of chains in the hash table's buckets;
      the longest observed chain had ~550 elements.
      
      The appended addresses this with two changes:
      
      1) Use xxhash as the hash table's hash function. xxhash is a fast,
         high-quality hashing function.
      
      2) Feed the hashing function with not just tb_phys, but also pc and flags.
      
      This improves performance over using just tb_phys for hashing, since that
      resulted in some hash buckets having many TB's, while others getting very few;
      with these changes, the longest observed chain on a single hash bucket is
      brought down from ~550 to ~40.
      
      Tests show that the other element checked for in tb_find_physical,
      cs_base, is always a match when tb_phys+pc+flags are a match,
      so hashing cs_base is wasteful. It could be that this is an ARM-only
      thing, though. UPDATE:
      On Tue, Apr 05, 2016 at 08:41:43 -0700, Richard Henderson wrote:
      > The cs_base field is only used by i386 (in 16-bit modes), and sparc (for a TB
      > consisting of only a delay slot).
      > It may well still turn out to be reasonable to ignore cs_base for hashing.
      
      BTW, after this change the hash table should not be called "tb_hash_phys"
      anymore; this is addressed later in this series.
      
      This change gives consistent bootup time improvements. I tested two
      host machines:
      - Intel Xeon E5-2690: 11.6% less time
      - Intel i7-4790K: 19.2% less time
      
      Increasing the number of hash buckets yields further improvements. However,
      using a larger, fixed number of buckets can degrade performance for other
      workloads that do not translate as many blocks (600K+ for debian-jessie arm
      bootup). This is dealt with later in this series.
      Reviewed-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-8-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      42bd3228
    • E
      exec: add tb_hash_func5, derived from xxhash · dc8b295d
      Emilio G. Cota 提交于
      This will be used by upcoming changes for hashing the tb hash.
      
      Add this into a separate file to include the copyright notice from
      xxhash.
      Reviewed-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-7-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      dc8b295d
    • G
      qemu-thread: add simple test-and-set spinlock · ac9a9eba
      Guillaume Delbergue 提交于
      Reviewed-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Signed-off-by: NGuillaume Delbergue <guillaume.delbergue@greensocs.com>
      [Rewritten. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      [Emilio's additions: use TAS instead of atomic_xchg; emit acquire/release
       barriers; return bool from trylock; call cpu_relax() while spinning;
       optimize for uncontended locks by acquiring the lock with TAS instead
       of TATAS; add qemu_spin_locked().]
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-6-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      ac9a9eba
    • E
      include/processor.h: define cpu_relax() · 462cda50
      Emilio G. Cota 提交于
      Taken from the linux kernel.
      Reviewed-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-5-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      462cda50
    • E
      seqlock: rename write_lock/unlock to write_begin/end · 03719e44
      Emilio G. Cota 提交于
      It is a more appropriate name, now that the mutex embedded
      in the seqlock is gone.
      Reviewed-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-4-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      03719e44
    • E
      seqlock: remove optional mutex · ccdb3c1f
      Emilio G. Cota 提交于
      This option is unused; besides, it bloats the struct when not needed.
      Let's just let writers define their own locks elsewhere.
      Reviewed-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-3-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      ccdb3c1f
    • E
      compiler.h: add QEMU_ALIGNED() to enforce struct alignment · 911a4d22
      Emilio G. Cota 提交于
      Reviewed-by: NSergey Fedorov <sergey.fedorov@linaro.org>
      Reviewed-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: NEmilio G. Cota <cota@braap.org>
      Message-Id: <1465412133-3029-2-git-send-email-cota@braap.org>
      Signed-off-by: NRichard Henderson <rth@twiddle.net>
      911a4d22
  6. 09 6月, 2016 1 次提交
  7. 08 6月, 2016 4 次提交
    • E
      block: Kill bdrv_co_write_zeroes() · c1499a5e
      Eric Blake 提交于
      Now that all drivers have been converted to a byte interface,
      we no longer need a sector interface.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c1499a5e
    • E
      block: Switch bdrv_write_zeroes() to byte interface · 74021bc4
      Eric Blake 提交于
      Rename to bdrv_pwrite_zeroes() to let the compiler ensure we
      cater to the updated semantics.  Do the same for bdrv_co_write_zeroes().
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      74021bc4
    • E
      block: Add .bdrv_co_pwrite_zeroes() · d05aa8bb
      Eric Blake 提交于
      Update bdrv_co_do_write_zeroes() to be byte-based, and select
      between the new byte-based bdrv_co_pwrite_zeroes() or the old
      bdrv_co_write_zeroes().  The next patches will convert drivers,
      then remove the old interface.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d05aa8bb
    • E
      block: Track write zero limits in bytes · cf081fca
      Eric Blake 提交于
      Another step towards removing sector-based interfaces: convert
      the maximum write and minimum alignment values from sectors to
      bytes.  Rename the variables to let the compiler check that all
      users are converted to the new semantics.
      
      The maximum remains an int as long as BDRV_REQUEST_MAX_SECTORS
      is constrained by INT_MAX (this means that we can't even
      support a 2G write_zeroes, but just under it) - changing
      operation lengths to unsigned or to 64-bits is a much bigger
      audit, and debatable if we even want to do it (since at the
      core, a 32-bit platform will still have ssize_t as its
      underlying limit on write()).
      
      Meanwhile, alignment is changed to 'uint32_t', since it makes no
      sense to have an alignment larger than the maximum write, and
      less painful to use an unsigned type with well-defined behavior
      in bit operations than to have to worry about what happens if
      a driver mistakenly supplies a negative alignment.
      
      Add an assert that no one was trying to use sectors to get a
      write zeroes larger than 2G, and therefore that a later conversion
      to bytes won't be impacted by keeping the limit at 32 bits.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      cf081fca