24 Jan, 2014

1 commit

  • This patch changes percpu_ida_alloc() + callers to accept task state
    bitmask for prepare_to_wait() for code like target/iscsi that needs
    it for interruptible sleep, that is provided in a subsequent patch.

    It now expects TASK_UNINTERRUPTIBLE when the caller is able to sleep
    waiting for a new tag, or TASK_RUNNING when the caller cannot sleep,
    and is forced to return a negative value when no tags are available.

    v2 changes:
    - Include blk-mq + tcm_fc + vhost/scsi + target/iscsi changes
    - Drop signal_pending_state() call
    v3 changes:
    - Only call prepare_to_wait() + finish_wait() when != TASK_RUNNING
    (PeterZ)

    Reported-by: Linus Torvalds
    Cc: Linus Torvalds
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Jens Axboe
    Signed-off-by: Kent Overstreet
    Cc: #3.12+
    Signed-off-by: Nicholas Bellinger

    Kent Overstreet
     

25 Oct, 2013

3 commits

  • Add an API to return free tags, blk-mq-tag will use it.

    Note, this just returns a snapshot of free tags number. blk-mq-tag has
    two usages of it. One is for info output for diagnosis. The other is to
    quickly check if there are free tags for request dispatch checking.
    Neither requires very precise.

    Cc: Andrew Morton
    Signed-off-by: Shaohua Li
    Signed-off-by: Jens Axboe

    Shaohua Li
     
  • Add a new API to iterate free ids. blk-mq-tag will use it.

    Note, this doesn't guarantee to iterate all free ids restrictly. Caller
    should be aware of this. blk-mq uses it to do sanity check for request
    timedout, so can tolerate the limitation.

    Cc: Andrew Morton
    Signed-off-by: Shaohua Li
    Signed-off-by: Jens Axboe

    Shaohua Li
     
  • Make percpu_ida percpu size/batch configurable. The block-mq-tag will
    use it.

    After block-mq uses percpu_ida to manage tags, performance is improved.
    My test is done in a 2 sockets machine, 12 process cross the 2 sockets.
    So if there is lock contention or ipi, should be stressed heavily.
    Testing is done for null-blk.

    hw_queue_depth nopatch iops patch iops
    64 ~800k/s ~1470k/s
    2048 ~4470k/s ~4340k/s

    Cc: Andrew Morton
    Signed-off-by: Shaohua Li
    Signed-off-by: Jens Axboe

    Shaohua Li
     

10 Sep, 2013

1 commit

  • Percpu frontend for allocating ids. With percpu allocation (that works),
    it's impossible to guarantee it will always be possible to allocate all
    nr_tags - typically, some will be stuck on a remote percpu freelist
    where the current job can't get to them.

    We do guarantee that it will always be possible to allocate at least
    (nr_tags / 2) tags - this is done by keeping track of which and how many
    cpus have tags on their percpu freelists. On allocation failure if
    enough cpus have tags that there could potentially be (nr_tags / 2) tags
    stuck on remote percpu freelists, we then pick a remote cpu at random to
    steal from.

    Note that there's no cpu hotplug notifier - we don't care, because
    steal_tags() will eventually get the down cpu's tags. We _could_ satisfy
    more allocations if we had a notifier - but we'll still meet our
    guarantees and it's absolutely not a correctness issue, so I don't think
    it's worth the extra code.

    From akpm:

    "It looks OK to me (that's as close as I get to an ack :))

    v6 changes:
    - Add #include to include/linux/percpu_ida.h to
    make alpha/arc builds happy (Fengguang)
    - Move second (cpu >= nr_cpu_ids) check inside of first check scope
    in steal_tags() (akpm + nab)

    v5 changes:
    - Change percpu_ida->cpus_have_tags to cpumask_t (kmo + akpm)
    - Add comment for percpu_ida_cpu->lock + ->nr_free (kmo + akpm)
    - Convert steal_tags() to use cpumask_weight() + cpumask_next() +
    cpumask_first() + cpumask_clear_cpu() (kmo + akpm)
    - Add comment for alloc_global_tags() (kmo + akpm)
    - Convert percpu_ida_alloc() to use cpumask_set_cpu() (kmo + akpm)
    - Convert percpu_ida_free() to use cpumask_set_cpu() (kmo + akpm)
    - Drop percpu_ida->cpus_have_tags allocation in percpu_ida_init()
    (kmo + akpm)
    - Drop percpu_ida->cpus_have_tags kfree in percpu_ida_destroy()
    (kmo + akpm)
    - Add comment for percpu_ida_alloc @ gfp (kmo + akpm)
    - Move to percpu_ida.c + percpu_ida.h (kmo + akpm + nab)

    v4 changes:

    - Fix tags.c reference in percpu_ida_init (akpm)

    Signed-off-by: Kent Overstreet
    Cc: Tejun Heo
    Cc: Oleg Nesterov
    Cc: Christoph Lameter
    Cc: Ingo Molnar
    Cc: Andi Kleen
    Cc: Jens Axboe
    Cc: "Nicholas A. Bellinger"
    Signed-off-by: Nicholas Bellinger

    Kent Overstreet