30 May, 2011

1 commit

  • The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST
    feature bit. Whenever the bit is set, the guest kernel must
    always tell the host before we free pages back to the allocator.
    Without this feature, we might free a page (and have another
    user touch it) while the hypervisor is unprepared for it.

    But, if the bit is _not_ set, we are under no obligation to
    reverse the order; we're under no obligation to do _anything_.
    As of now, qemu-kvm defines the bit, but doesn't set it.

    This patch makes the "tell host first" logic the only case. This
    should make everybody happy, and reduce the amount of untested or
    untestable code in the kernel.

    This _also_ means that we don't have to preserve a pfn list
    after the pages are freed, which should let us get rid of some
    temporary storage (vb->pfns) eventually.

    Signed-off-by: Dave Hansen
    Signed-off-by: Rusty Russell

    Dave Hansen
     

19 May, 2010

1 commit


22 Apr, 2010

1 commit

  • The virtio balloon driver can dig into the reservation pools of the OS
    to satisfy a balloon request. This is not advisable and other balloon
    drivers (drivers/xen/balloon.c) avoid this as well.

    The patch also adds changes to avoid printing a warning if allocation
    fails, since we retry after sometime anyway.

    Signed-off-by: Balbir Singh
    Signed-off-by: Rusty Russell
    Cc: kvm
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    Balbir Singh
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

24 Feb, 2010

3 commits

  • When running under qemu-kvm-0.11.0:

    BUG: unable to handle kernel paging request at 56e58955
    ...
    Process vballoon (pid: 1297, ti=c7976000 task=c70a6ca0 task.ti=c7
    ...
    Call Trace:
    [] ? balloon+0x1b3/0x440 [virtio_balloon]
    [] ? schedule+0x327/0x9d0
    [] ? balloon+0x0/0x440 [virtio_balloon]
    [] ? kthread+0x74/0x80
    [] ? kthread+0x0/0x80
    [] ? kernel_thread_helper+0x6/0x30

    need_stats_update should be zero-initialized.

    Signed-off-by: Rusty Russell
    Acked-by: Adam Litke

    Rusty Russell
     
  • This is a fix for my earlier patch: "virtio: Add memory statistics reporting to
    the balloon driver (V4)".

    I discovered that all_vm_events() can sleep and therefore stats collection
    cannot be done in interrupt context. One solution is to handle the interrupt
    by noting that stats need to be collected and waking the existing vballoon
    kthread which will complete the work via stats_handle_request(). Rusty, is
    this a saner way of doing business?

    There is one issue that I would like a broader opinion on. In stats_request, I
    update vb->need_stats_update and then wake up the kthread. The kthread uses
    vb->need_stats_update as a condition variable. Do I need a memory barrier
    between the update and wake_up to ensure that my kthread sees the correct
    value? My testing suggests that it is not needed but I would like some
    confirmation from the experts.

    Signed-off-by: Adam Litke
    To: Rusty Russell
    Cc: Anthony Liguori
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Rusty Russell

    Adam Litke
     
  • Changes since V3:
    - Do not do endian conversions as they will be done in the host
    - Report stats that reference a quantity of memory in bytes
    - Minor coding style updates

    Changes since V2:
    - Increase stat field size to 64 bits
    - Report all sizes in kb (not pages)
    - Drop anon_pages stat and fix endianness conversion

    Changes since V1:
    - Use a virtqueue instead of the device config space

    When using ballooning to manage overcommitted memory on a host, a system for
    guests to communicate their memory usage to the host can provide information
    that will minimize the impact of ballooning on the guests. The current method
    employs a daemon running in each guest that communicates memory statistics to a
    host daemon at a specified time interval. The host daemon aggregates this
    information and inflates and/or deflates balloons according to the level of
    host memory pressure. This approach is effective but overly complex since a
    daemon must be installed inside each guest and coordinated to communicate with
    the host. A simpler approach is to collect memory statistics in the virtio
    balloon driver and communicate them directly to the hypervisor.

    This patch enables the guest-side support by adding stats collection and
    reporting to the virtio balloon driver.

    Signed-off-by: Adam Litke
    Cc: Anthony Liguori
    Cc: virtualization@lists.linux-foundation.org
    Signed-off-by: Rusty Russell (minor fixes)

    Adam Litke
     

17 Jan, 2010

1 commit

  • Fix fixes the following warnings by renaming the driver structures to be
    suffixed with _driver.

    WARNING: drivers/virtio/virtio_balloon.o(.data+0x88): Section mismatch in reference from the variable virtio_balloon to the function .devexit.text:virtballoon_remove()

    WARNING: drivers/char/hw_random/virtio-rng.o(.data+0x88): Section mismatch in reference from the variable virtio_rng to the function .devexit.text:virtrng_remove()

    Signed-off-by: Jeff Mahoney
    Acked-by: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jeff Mahoney
     

22 Oct, 2009

2 commits

  • The function virtballoon_remove is used only wrapped by __devexit_p so
    define it using __devexit.

    Signed-off-by: Uwe Kleine-König
    Acked-by: Sam Ravnborg
    Acked-by: Michael S. Tsirkin
    Signed-off-by: Rusty Russell

    Uwe Kleine-König
     
  • Rusty,

    commit 3ca4f5ca73057a617f9444a91022d7127041970a
    virtio: add virtio IDs file
    moved all device IDs into a single file. While the change itself is
    a very good one, it can break userspace applications. For example
    if a userspace tool wanted to get the ID of virtio_net it used to
    include virtio_net.h. This does no longer work, since virtio_net.h
    does not include virtio_ids.h.
    This patch moves all "#include " from the C
    files into the header files, making the header files compatible with
    the old ones.

    In addition, this patch exports virtio_ids.h to userspace.

    CC: Fernando Luis Vazquez Cao
    Signed-off-by: Christian Borntraeger
    Signed-off-by: Rusty Russell

    Christian Borntraeger
     

23 Sep, 2009

2 commits


12 Jun, 2009

2 commits


19 Apr, 2009

1 commit


30 Dec, 2008

1 commit


25 Aug, 2008

1 commit

  • Both v and vb->num_pages are u32 and unsigned int respectively. If v is less
    than vb->num_pages (and it is, when deflating the balloon), the result is a
    very large 32-bit number. Since we're returning a s64, instead of getting the
    same negative number we desire, we get a very large positive number.

    This handles the case where v < vb->num_pages and ensures we get a small,
    negative, s64 as the result.

    Rusty: please push this for 2.6.27-rc4. It's probably appropriate for the
    stable tree too as it will cause an unexpected OOM when ballooning.

    Signed-off-by: Anthony Liguori
    Signed-off-by: Rusty Russell (simplified)

    Anthony Liguori
     

02 May, 2008

2 commits

  • A recent proposed feature addition to the virtio block driver revealed
    some flaws in the API: in particular, we assume that feature
    negotiation is complete once a driver's probe function returns.

    There is nothing in the API to require this, however, and even I
    didn't notice when it was violated.

    So instead, we require the driver to specify what features it supports
    in a table, we can then move the feature negotiation into the virtio
    core. The intersection of device and driver features are presented in
    a new 'features' bitmap in the struct virtio_device.

    Note that this highlights the difference between Linux unsigned-long
    bitmaps where each unsigned long is in native endian, and a
    straight-forward little-endian array of bytes.

    Drivers can still remove feature bits in their probe routine if they
    really have to.

    API changes:
    - dev->config->feature() no longer gets and acks a feature.
    - drivers should advertise their features in the 'feature_table' field
    - use virtio_has_feature() for extra sanity when checking feature bits

    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • A recent proposed feature addition to the virtio block driver revealed
    some flaws in the API, in particular how easy it is to break big
    endian machines.

    The virtio config space was originally chosen to be little-endian,
    because we thought the config might be part of the PCI config space
    for virtio_pci. It's actually a separate mmio region, so that
    argument holds little water; as only x86 is currently using the virtio
    mechanism, we can change this (but must do so now, before the
    impending s390 merge).

    API changes:
    - __virtio_config_val() just becomes a striaght vdev->config_get() call.

    Signed-off-by: Rusty Russell

    Rusty Russell
     

17 Mar, 2008

1 commit


07 Feb, 2008

1 commit

  • Include linux/delay.h to fix compiler error:

    drivers/virtio/virtio_balloon.c: In function 'fill_balloon':
    drivers/virtio/virtio_balloon.c:98: error: implicit declaration of function 'msleep'

    Signed-off-by: Johann Felix Soden
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johann Felix Soden
     

04 Feb, 2008

1 commit

  • After discussions with Anthony Liguori, it seems that the virtio
    balloon can be made even simpler. Here's my attempt.

    The device configuration tells the driver how much memory it should
    take from the guest (ie. balloon size). The guest feeds the page
    numbers it has taken via one virtqueue.

    A second virtqueue feeds the page numbers the driver wants back: if
    the device has the VIRTIO_BALLOON_F_MUST_TELL_HOST bit, then this
    queue is compulsory, otherwise it's advisory (and the guest can simply
    fault the pages back in).

    This driver can be enhanced later to deflate the balloon via a
    shrinker, oom callback or we could even go for a complete set of
    in-guest regulators.

    Signed-off-by: Rusty Russell

    Rusty Russell