21 Mar, 2014

1 commit


07 Dec, 2013

1 commit

  • All objects, which are allocated in blk_mq_register_disk, must be
    released in blk_mq_unregister_disk.

    I use a KVM virtual machine and virtio disk to reproduce this issue.

    kmemleak: 18 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
    $ cat /sys/kernel/debug/kmemleak | head -n 30
    unreferenced object 0xffff8800b6636150 (size 8):
    comm "kworker/0:2", pid 65, jiffies 4294809903 (age 86.358s)
    hex dump (first 8 bytes):
    76 69 72 74 69 6f 34 00 virtio4.
    backtrace:
    [] kmemleak_alloc+0x4e/0xb0
    [] __kmalloc_track_caller+0xf5/0x260
    [] kstrdup+0x31/0x60
    [] sysfs_new_dirent+0x2e/0x140
    [] create_dir+0x38/0xe0
    [] sysfs_create_dir_ns+0x73/0xc0
    [] kobject_add_internal+0xc9/0x340
    [] kobject_add+0x65/0xb0
    [] device_add+0x128/0x660
    [] device_register+0x1a/0x20
    [] register_virtio_device+0x98/0xe0
    [] virtio_pci_probe+0x12e/0x1c0
    [] local_pci_probe+0x45/0xa0
    [] pci_device_probe+0x121/0x130
    [] driver_probe_device+0x87/0x390
    [] __device_attach+0x3b/0x40
    unreferenced object 0xffff8800b65aa1d8 (size 144):

    Fixes: 320ae51feed5 (blk-mq: new multi-queue block IO queueing mechanism)
    Cc: Jens Axboe
    Signed-off-by: Andrey Vagin
    Signed-off-by: Jens Axboe

    Andrey Vagin
     

25 Oct, 2013

1 commit

  • Linux currently has two models for block devices:

    - The classic request_fn based approach, where drivers use struct
    request units for IO. The block layer provides various helper
    functionalities to let drivers share code, things like tag
    management, timeout handling, queueing, etc.

    - The "stacked" approach, where a driver squeezes in between the
    block layer and IO submitter. Since this bypasses the IO stack,
    driver generally have to manage everything themselves.

    With drivers being written for new high IOPS devices, the classic
    request_fn based driver doesn't work well enough. The design dates
    back to when both SMP and high IOPS was rare. It has problems with
    scaling to bigger machines, and runs into scaling issues even on
    smaller machines when you have IOPS in the hundreds of thousands
    per device.

    The stacked approach is then most often selected as the model
    for the driver. But this means that everybody has to re-invent
    everything, and along with that we get all the problems again
    that the shared approach solved.

    This commit introduces blk-mq, block multi queue support. The
    design is centered around per-cpu queues for queueing IO, which
    then funnel down into x number of hardware submission queues.
    We might have a 1:1 mapping between the two, or it might be
    an N:M mapping. That all depends on what the hardware supports.

    blk-mq provides various helper functions, which include:

    - Scalable support for request tagging. Most devices need to
    be able to uniquely identify a request both in the driver and
    to the hardware. The tagging uses per-cpu caches for freed
    tags, to enable cache hot reuse.

    - Timeout handling without tracking request on a per-device
    basis. Basically the driver should be able to get a notification,
    if a request happens to fail.

    - Optional support for non 1:1 mappings between issue and
    submission queues. blk-mq can redirect IO completions to the
    desired location.

    - Support for per-request payloads. Drivers almost always need
    to associate a request structure with some driver private
    command structure. Drivers can tell blk-mq this at init time,
    and then any request handed to the driver will have the
    required size of memory associated with it.

    - Support for merging of IO, and plugging. The stacked model
    gets neither of these. Even for high IOPS devices, merging
    sequential IO reduces per-command overhead and thus
    increases bandwidth.

    For now, this is provided as a potential 3rd queueing model, with
    the hope being that, as it matures, it can replace both the classic
    and stacked model. That would get us back to having just 1 real
    model for block devices, leaving the stacked approach to dm/md
    devices (as it was originally intended).

    Contributions in this patch from the following people:

    Shaohua Li
    Alexander Gordeev
    Christoph Hellwig
    Mike Christie
    Matias Bjorling
    Jeff Moyer

    Acked-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Jens Axboe