1. 02 7月, 2014 16 次提交
    • M
      block: virtio-blk: support multi virt queues per virtio-blk device · 6a27b656
      Ming Lei 提交于
      Firstly this patch supports more than one virtual queues for virtio-blk
      device.
      
      Secondly this patch maps the virtual queue to blk-mq's hardware queue.
      
      With this approach, both scalability and performance can be improved.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      6a27b656
    • M
      include/uapi/linux/virtio_blk.h: introduce feature of VIRTIO_BLK_F_MQ · cb553215
      Ming Lei 提交于
      Current virtio-blk spec only supports one virtual queue for transfering
      data between VM and host, and inside VM all kinds of operations on
      the virtual queue needs to hold one lock, so cause below problems:
      
      	- bad scalability
      	- bad throughput
      
      This patch requests to introduce feature of VIRTIO_BLK_F_MQ
      so that more than one virtual queues can be used to virtio-blk
      device, then above problems can be solved or eased.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      cb553215
    • D
      block SG_IO: add SG_FLAG_Q_AT_HEAD flag · d1515613
      Douglas Gilbert 提交于
      After the SG_IO ioctl was copied into the block layer and
      later into the bsg driver, subtle differences emerged.
      
      One difference is the way injected commands are queued through
      the block layer (i.e. this is not SCSI device queueing nor SATA
      NCQ). Summarizing:
        - SG_IO on block layer device: blk_exec*(at_head=false)
        - sg device SG_IO: at_head=true
        - bsg device SG_IO: at_head=true
      
      Some time ago Boaz Harrosh introduced a sg v4 flag called
      BSG_FLAG_Q_AT_TAIL to override the bsg driver default. A
      recent patch titled: "sg: add SG_FLAG_Q_AT_TAIL flag"
      allowed the sg driver default to be overridden. This patch
      allows a SG_IO ioctl sent to a block layer device to have
      its default overridden.
      
      ChangeLog:
          - introduce SG_FLAG_Q_AT_HEAD flag in sg.h to cause
            commands that are injected via a block layer
            device SG_IO ioctl to set at_head=true
          - make comments clearer about queueing in sg.h since the
            header is used both by the sg device and block layer
            device implementations of the SG_IO ioctl.
          - introduce BSG_FLAG_Q_AT_HEAD in bsg.h for compatibility
            (it does nothing) and update comments.
      Signed-off-by: NDouglas Gilbert <dgilbert@interlog.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NMike Christie <michaelc@cs.wisc.edu>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      d1515613
    • A
      block: fix SG_[GS]ET_RESERVED_SIZE ioctl when max_sectors is huge · 9b4231bf
      Akinobu Mita 提交于
      SG_GET_RESERVED_SIZE and SG_SET_RESERVED_SIZE ioctls access a reserved
      buffer in bytes as int type.  The value needs to be capped at the request
      queue's max_sectors.  But integer overflow is not correctly handled in
      the calculation when converting max_sectors from sectors to bytes.
      Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: linux-scsi@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      9b4231bf
    • A
      block: fix BLKSECTGET ioctl when max_sectors is greater than USHRT_MAX · 63f26496
      Akinobu Mita 提交于
      BLKSECTGET ioctl loads the request queue's max_sectors as unsigned
      short value to the argument pointer.  So if the max_sector is greater
      than USHRT_MAX, the upper 16 bits of that is just discarded.
      
      In such case, USHRT_MAX is more preferable than the lower 16 bits of
      max_sectors.
      Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: linux-scsi@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      63f26496
    • F
      block/partitions/efi.c: kerneldoc fixing · 16e15565
      Fabian Frederick 提交于
      Adding function documentation and fixing kerneldoc warnings
      ('field: description' uniformization).
      
      Cc: Davidlohr Bueso <davidlohr@hp.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: NFabian Frederick <fabf@skynet.be>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      16e15565
    • F
      block/partitions/msdos.c: code clean-up · dce14c23
      Fabian Frederick 提交于
      checkpatch fixing:
      WARNING: Missing a blank line after declarations
      WARNING: space prohibited between function name and open parenthesis '('
      ERROR: spaces required around that '<' (ctx:VxV)
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NFabian Frederick <fabf@skynet.be>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      dce14c23
    • F
      block/partitions/amiga.c: replace nolevel printk by pr_err · 600ffc5e
      Fabian Frederick 提交于
      Also add no prefix pr_fmt to avoid any future default format update
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NFabian Frederick <fabf@skynet.be>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      600ffc5e
    • F
      block/partitions/aix.c: replace count*size kzalloc by kcalloc · 472d5e2a
      Fabian Frederick 提交于
      kcalloc manages count*sizeof overflow.
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NFabian Frederick <fabf@skynet.be>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      472d5e2a
    • G
      bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload · cbcd1054
      Gu Zheng 提交于
      Commit 08778795 ("block: Fix nr_vecs for inline integrity vectors") from
      Martin introduces the function bip_integrity_vecs(get the useful vectors)
      to fix the issue about nr_vecs for inline integrity vectors that reported
      by David Milburn.
      
      But it seems that bip_integrity_vecs() will return the wrong number if the
      bio is not based on any bio_set for some reason(bio->bi_pool == NULL),
      because in that case, the bip_inline_vecs[0] is malloced directly.  So
      here we add the bip_max_vcnt to record the count of vector slots, and
      cleanup the function bip_integrity_vecs().
      Signed-off-by: NGu Zheng <guz.fnst@cn.fujitsu.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      cbcd1054
    • T
      blk-mq: use percpu_ref for mq usage count · add703fd
      Tejun Heo 提交于
      Currently, blk-mq uses a percpu_counter to keep track of how many
      usages are in flight.  The percpu_counter is drained while freezing to
      ensure that no usage is left in-flight after freezing is complete.
      blk_mq_queue_enter/exit() and blk_mq_[un]freeze_queue() implement this
      per-cpu gating mechanism.
      
      This type of code has relatively high chance of subtle bugs which are
      extremely difficult to trigger and it's way too hairy to be open coded
      in blk-mq.  percpu_ref can serve the same purpose after the recent
      changes.  This patch replaces the open-coded per-cpu usage counting
      and draining mechanism with percpu_ref.
      
      blk_mq_queue_enter() performs tryget_live on the ref and exit()
      performs put.  blk_mq_freeze_queue() kills the ref and waits until the
      reference count reaches zero.  blk_mq_unfreeze_queue() revives the ref
      and wakes up the waiters.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      add703fd
    • T
      blk-mq: collapse __blk_mq_drain_queue() into blk_mq_freeze_queue() · 72d6f02a
      Tejun Heo 提交于
      Keeping __blk_mq_drain_queue() as a separate function doesn't buy us
      anything and it's gonna be further simplified.  Let's flatten it into
      its caller.
      
      This patch doesn't make any functional change.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      72d6f02a
    • T
      blk-mq: decouble blk-mq freezing from generic bypassing · 780db207
      Tejun Heo 提交于
      blk_mq freezing is entangled with generic bypassing which bypasses
      blkcg and io scheduler and lets IO requests fall through the block
      layer to the drivers in FIFO order.  This allows forward progress on
      IOs with the advanced features disabled so that those features can be
      configured or altered without worrying about stalling IO which may
      lead to deadlock through memory allocation.
      
      However, generic bypassing doesn't quite fit blk-mq.  blk-mq currently
      doesn't make use of blkcg or ioscheds and it maps bypssing to
      freezing, which blocks request processing and drains all the in-flight
      ones.  This causes problems as bypassing assumes that request
      processing is online.  blk-mq works around this by conditionally
      allowing request processing for the problem case - during queue
      initialization.
      
      Another weirdity is that except for during queue cleanup, bypassing
      started on the generic side prevents blk-mq from processing new
      requests but doesn't drain the in-flight ones.  This shouldn't break
      anything but again highlights that something isn't quite right here.
      
      The root cause is conflating blk-mq freezing and generic bypassing
      which are two different mechanisms.  The only intersecting purpose
      that they serve is during queue cleanup.  Let's properly separate
      blk-mq freezing from generic bypassing and simply use it where
      necessary.
      
      * request_queue->mq_freeze_depth is added and
        blk_mq_[un]freeze_queue() now operate on this counter instead of
        ->bypass_depth.  The replacement for QUEUE_FLAG_BYPASS isn't added
        but the counter is tested directly.  This will be further updated by
        later changes.
      
      * blk_mq_drain_queue() is dropped and "__" prefix is dropped from
        blk_mq_freeze_queue().  Queue cleanup path now calls
        blk_mq_freeze_queue() directly.
      
      * blk_queue_enter()'s fast path condition is simplified to simply
        check @q->mq_freeze_depth.  Previously, the condition was
      
      	!blk_queue_dying(q) &&
      	    (!blk_queue_bypass(q) || !blk_queue_init_done(q))
      
        mq_freeze_depth is incremented right after dying is set and
        blk_queue_init_done() exception isn't necessary as blk-mq doesn't
        start frozen, which only leaves the blk_queue_bypass() test which
        can be replaced by @q->mq_freeze_depth test.
      
      This change simplifies the code and reduces confusion in the area.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      780db207
    • T
      block, blk-mq: draining can't be skipped even if bypass_depth was non-zero · 776687bc
      Tejun Heo 提交于
      Currently, both blk_queue_bypass_start() and blk_mq_freeze_queue()
      skip queue draining if bypass_depth was already above zero.  The
      assumption is that the one which bumped the bypass_depth should have
      performed draining already; however, there's nothing which prevents a
      new instance of bypassing/freezing from starting before the previous
      one finishes draining.  The current code may allow the later
      bypassing/freezing instances to complete while there still are
      in-flight requests which haven't finished draining.
      
      Fix it by draining regardless of bypass_depth.  We still skip draining
      from blk_queue_bypass_start() while the queue is initializing to avoid
      introducing excessive delays during boot.  INIT_DONE setting is moved
      above the initial blk_queue_bypass_end() so that bypassing attempts
      can't slip inbetween.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      776687bc
    • T
      blk-mq: fix a memory ordering bug in blk_mq_queue_enter() · 531ed626
      Tejun Heo 提交于
      blk-mq uses a percpu_counter to keep track of how many usages are in
      flight.  The percpu_counter is drained while freezing to ensure that
      no usage is left in-flight after freezing is complete.
      
      blk_mq_queue_enter/exit() and blk_mq_[un]freeze_queue() implement this
      per-cpu gating mechanism; unfortunately, it contains a subtle bug -
      smp_wmb() in blk_mq_queue_enter() doesn't prevent prevent the cpu from
      fetching @q->bypass_depth before incrementing @q->mq_usage_counter and
      if freezing happens inbetween the caller can slip through and freezing
      can be complete while there are active users.
      
      Use smp_mb() instead so that bypass_depth and mq_usage_counter
      modifications and tests are properly interlocked.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      531ed626
    • J
      Merge branch 'for-3.17' of... · 17737d3b
      Jens Axboe 提交于
      Merge branch 'for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu into for-3.17/core
      
      Merge the percpu_ref changes from Tejun, he says they are stable now.
      17737d3b
  2. 30 6月, 2014 4 次提交
  3. 29 6月, 2014 9 次提交
    • W
      ARM: 8087/1: ptrace: reload syscall number after secure_computing() check · 42309ab4
      Will Deacon 提交于
      On the syscall tracing path, we call out to secure_computing() to allow
      seccomp to check the syscall number being attempted. As part of this, a
      SIGTRAP may be sent to the tracer and the syscall could be re-written by
      a subsequent SET_SYSCALL ptrace request. Unfortunately, this new syscall
      is ignored by the current code unless TIF_SYSCALL_TRACE is also set on
      the current thread.
      
      This patch slightly reworks the enter path of the syscall tracing code
      so that we always reload the syscall number from
      current_thread_info()->syscall after the potential ptrace traps.
      Acked-by: NKees Cook <keescook@chromium.org>
      Tested-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      42309ab4
    • L
      ARM: 8086/1: Set memblock limit for nommu · 6980c3e2
      Laura Abbott 提交于
      Commit 1c2f87c2 (ARM: 8025/1: Get rid of meminfo) changed find_limits
      to use memblock_get_current_limit for calculating the max_low pfn.
      nommu targets never actually set a limit on memblock though which
      means memblock_get_current_limit will just return the default
      value. Set the memblock_limit to be the end of DDR to make sure
      bounds are calculated correctly.
      Signed-off-by: NLaura Abbott <lauraa@codeaurora.org>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      6980c3e2
    • A
      ARM: 8085/1: sa1100: collie: add top boot mtd partition · 3abe7423
      Andrea Adami 提交于
      The CFI mapping is now perfect so we can expose the top block, read only.
      There isn't much to read, though, just the sharpsl_params values.
      Signed-off-by: NAndrea Adami <andrea.adami@gmail.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      3abe7423
    • A
      ARM: 8084/1: sa1100: collie: revert back to cfi_probe · 92183103
      Andrea Adami 提交于
      Reverts commit d26b17ed
      ARM: sa1100: collie.c: fall back to jedec_probe flash detection
      
      Unfortunately the detection was challenged on the defective unit used for tests:
      one of the NOR chips did not respond to the CFI query.
      Moreover that bad device needed extra delays on erase-suspend/resume cycles.
      
      Tested personally on 3 different units and with feedback of two other users.
      Signed-off-by: NAndrea Adami <andrea.adami@gmail.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      92183103
    • N
      ARM: 8080/1: mcpm.h: remove unused variable declaration · d0ba7cc0
      Nicolas Pitre 提交于
      The sync_phys variable has been replaced by link time computation in
      mcpm_head.S before the code was submitted upstream.
      Signed-off-by: NNicolas Pitre <nico@linaro.org>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      d0ba7cc0
    • T
      ARM: 8076/1: mm: add support for HW coherent systems in PL310 cache · 98ea2dba
      Thomas Petazzoni 提交于
      When a PL310 cache is used on a system that provides hardware
      coherency, the outer cache sync operation is useless, and can be
      skipped. Moreover, on some systems, it is harmful as it causes
      deadlocks between the Marvell coherency mechanism, the Marvell PCIe
      controller and the Cortex-A9.
      
      To avoid this, this commit introduces a new Device Tree property
      'arm,io-coherent' for the L2 cache controller node, valid only for the
      PL310 cache. It identifies the usage of the PL310 cache in an I/O
      coherent configuration. Internally, it makes the driver disable the
      outer cache sync operation.
      
      Note that technically speaking, a fully coherent system wouldn't
      require any of the other .outer_cache operations. However, in
      practice, when booting secondary CPUs, these are not yet coherent, and
      therefore a set of cache maintenance operations are necessary at this
      point. This explains why we keep the other .outer_cache operations and
      only ->sync is disabled.
      
      While in theory any write to a PL310 register could cause the
      deadlock, in practice, disabling ->sync is sufficient to workaround
      the deadlock, since the other cache maintenance operations are only
      used in very specific situations.
      
      Contrary to previous versions of this patch, this new version does not
      simply NULL-ify the ->sync member, because the l2c_init_data
      structures are now 'const' and therefore cannot be modified, which is
      a good thing. Therefore, this patch introduces a separate
      l2c_init_data instance, called of_l2c310_coherent_data.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      98ea2dba
    • L
      Merge tag 'spi-v3.16-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · 24b414d5
      Linus Torvalds 提交于
      Pull spi fixes from Mark Brown:
       "A few driver specific fixes, the biggest one being a fix for the newly
        added Qualcomm SPI controller driver to make it not use its internal
        chip select due to hardware bugs, replacing it with GPIOs"
      
      * tag 'spi-v3.16-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
        spi: qup: Remove chip select function
        spi: qup: Fix order of spi_register_master
        spi: sh-sci: fix use-after-free in sh_sci_spi_remove()
        spi/pxa2xx: fix incorrect SW mode chipselect setting for BayTrail LPSS SPI
      24b414d5
    • L
      Merge tag 'regulator-v3.16-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator · 4194976b
      Linus Torvalds 提交于
      Pull regulator fixes from Mark Brown:
       "Several driver specific fixes here, the palmas fixes being especially
        important for a range of boards - the recent updates to support new
        devices have introduced several regressions"
      
      * tag 'regulator-v3.16-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
        regulator: tps65218: Correct the the config register for LDO1
        regulator: tps65218: Add the missing of_node assignment in probe
        regulator: palmas: fix typo in enable_reg calculation
        regulator: bcm590xx: fix vbus name
        regulator: palmas: Fix SMPS enable/disable/is_enabled
      4194976b
    • L
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending · eb477e03
      Linus Torvalds 提交于
      Pull SCSI target fixes from Nicholas Bellinger:
       "Mostly minor fixes this time around.  The highlights include:
      
         - iscsi-target CHAP authentication fixes to enforce explicit key
           values (Tejas Vaykole + rahul.rane)
         - fix a long-standing OOPs in target-core when a alua configfs
           attribute is accessed after port symlink has been removed.
           (Sebastian Herbszt)
         - fix a v3.10.y iscsi-target regression causing the login reject
           status class/detail to be ignored (Christoph Vu-Brugier)
         - fix a v3.10.y iscsi-target regression to avoid rejecting an
           existing ITT during Data-Out when data-direction is wrong (Santosh
           Kulkarni + Arshad Hussain)
         - fix a iscsi-target related shutdown deadlock on UP kernels (Mikulas
           Patocka)
         - fix a v3.16-rc1 build issue with vhost-scsi + !CONFIG_NET (MST)"
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending:
        iscsi-target: fix iscsit_del_np deadlock on unload
        iovec: move memcpy_from/toiovecend to lib/iovec.c
        iscsi-target: Avoid rejecting incorrect ITT for Data-Out
        tcm_loop: Fix memory leak in tcm_loop_submission_work error path
        iscsi-target: Explicily clear login response PDU in exception path
        target: Fix left-over se_lun->lun_sep pointer OOPs
        iscsi-target; Enforce 1024 byte maximum for CHAP_C key value
        iscsi-target: Convert chap_server_compute_md5 to use kstrtoul
      eb477e03
  4. 28 6月, 2014 11 次提交
    • M
    • M
      Merge remote-tracking branches 'regulator/fix/bcm590xx',... · 11767484
      Mark Brown 提交于
      Merge remote-tracking branches 'regulator/fix/bcm590xx', 'regulator/fix/palmas' and 'regulator/fix/tps65218' into regulator-linus
      11767484
    • T
      percpu-refcount: implement percpu_ref_reinit() and percpu_ref_is_zero() · 2d722782
      Tejun Heo 提交于
      Now that explicit invocation of percpu_ref_exit() is necessary to free
      the percpu counter, we can implement percpu_ref_reinit() which
      reinitializes a released percpu_ref.  This can be used implement
      scalable gating switch which can be drained and then re-opened without
      worrying about memory allocation failures.
      
      percpu_ref_is_zero() is added to be used in a sanity check in
      percpu_ref_exit().  As this function will be useful for other purposes
      too, make it a public interface.
      
      v2: Use smp_read_barrier_depends() instead of smp_load_acquire().  We
          only need data dep barrier and smp_load_acquire() is stronger and
          heavier on some archs.  Spotted by Lai Jiangshan.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Cc: Christoph Lameter <cl@linux-foundation.org>
      Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
      2d722782
    • T
      percpu-refcount: require percpu_ref to be exited explicitly · 9a1049da
      Tejun Heo 提交于
      Currently, a percpu_ref undoes percpu_ref_init() automatically by
      freeing the allocated percpu area when the percpu_ref is killed.
      While seemingly convenient, this has the following niggles.
      
      * It's impossible to re-init a released reference counter without
        going through re-allocation.
      
      * In the similar vein, it's impossible to initialize a percpu_ref
        count with static percpu variables.
      
      * We need and have an explicit destructor anyway for failure paths -
        percpu_ref_cancel_init().
      
      This patch removes the automatic percpu counter freeing in
      percpu_ref_kill_rcu() and repurposes percpu_ref_cancel_init() into a
      generic destructor now named percpu_ref_exit().  percpu_ref_destroy()
      is considered but it gets confusing with percpu_ref_kill() while
      "exit" clearly indicates that it's the counterpart of
      percpu_ref_init().
      
      All percpu_ref_cancel_init() users are updated to invoke
      percpu_ref_exit() instead and explicit percpu_ref_exit() calls are
      added to the destruction path of all percpu_ref users.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Acked-by: NBenjamin LaHaise <bcrl@kvack.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Cc: Christoph Lameter <cl@linux-foundation.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
      Cc: Li Zefan <lizefan@huawei.com>
      9a1049da
    • T
      percpu-refcount: use unsigned long for pcpu_count pointer · 7d742075
      Tejun Heo 提交于
      percpu_ref->pcpu_count is a percpu pointer with a status flag in its
      lowest bit.  As such, it always goes through arithmetic operations
      which is very cumbersome to do on a pointer.  It has to be first
      casted to unsigned long and then back.
      
      Let's just make the field unsigned long so that we can skip the first
      casts.  While at it, rename it to pcpu_counter_ptr to clarify that
      it's a pointer value.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Cc: Christoph Lameter <cl@linux-foundation.org>
      7d742075
    • T
      percpu-refcount: add helpers for ->percpu_count accesses · eae7975d
      Tejun Heo 提交于
      * All four percpu_ref_*() operations implemented in the header file
        perform the same operation to determine whether the percpu_ref is
        alive and extract the percpu pointer.  Factor out the common logic
        into __pcpu_ref_alive().  This doesn't change the generated code.
      
      * There are a couple places in percpu-refcount.c which masks out
        PCPU_REF_DEAD to obtain the percpu pointer.  Factor it out into
        pcpu_count_ptr().
      
      * The above changes make the WARN_ON_ONCE() conditional at the top of
        percpu_ref_kill_and_confirm() the only user of REF_STATUS().  Test
        PCPU_REF_DEAD directly and remove REF_STATUS().
      
      This patch doesn't introduce any functional change.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Cc: Christoph Lameter <cl@linux-foundation.org>
      eae7975d
    • T
      percpu-refcount: one bit is enough for REF_STATUS · d630dc4c
      Tejun Heo 提交于
      percpu-refcount currently reserves two lowest bits of its percpu
      pointer to indicate its state; however, only one bit is used for
      PCPU_REF_DEAD.
      
      Simplify it by removing PCPU_STATUS_BITS/MASK and testing
      PCPU_REF_DEAD directly.  This also allows the compiler to choose a
      more efficient instruction depending on the architecture.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Cc: Christoph Lameter <cl@linux-foundation.org>
      d630dc4c
    • T
      percpu-refcount, aio: use percpu_ref_cancel_init() in ioctx_alloc() · 55c6c814
      Tejun Heo 提交于
      ioctx_alloc() reaches inside percpu_ref and directly frees
      ->pcpu_count in its failure path, which is quite gross.  percpu_ref
      has been providing a proper interface to do this,
      percpu_ref_cancel_init(), for quite some time now.  Let's use that
      instead.
      
      This patch doesn't introduce any behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Acked-by: NBenjamin LaHaise <bcrl@kvack.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      55c6c814
    • M
      iscsi-target: fix iscsit_del_np deadlock on unload · 81a9c5e7
      Mikulas Patocka 提交于
      On uniprocessor preemptible kernel, target core deadlocks on unload. The
      following events happen:
      * iscsit_del_np is called
      * it calls send_sig(SIGINT, np->np_thread, 1);
      * the scheduler switches to the np_thread
      * the np_thread is woken up, it sees that kthread_should_stop() returns
        false, so it doesn't terminate
      * the np_thread clears signals with flush_signals(current); and goes back
        to sleep in iscsit_accept_np
      * the scheduler switches back to iscsit_del_np
      * iscsit_del_np calls kthread_stop(np->np_thread);
      * the np_thread is waiting in iscsit_accept_np and it doesn't respond to
        kthread_stop
      
      The deadlock could be resolved if the administrator sends SIGINT signal to
      the np_thread with killall -INT iscsi_np
      
      The reproducible deadlock was introduced in commit
      db6077fd, but the thread-stopping code was
      racy even before.
      
      This patch fixes the problem. Using kthread_should_stop to stop the
      np_thread is unreliable, so we test np_thread_state instead. If
      np_thread_state equals ISCSI_NP_THREAD_SHUTDOWN, the thread exits.
      Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      81a9c5e7
    • L
      Merge tag 'iommu-fixes-v3.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu · 3e7b256c
      Linus Torvalds 提交于
      Pull IOMMU fixes from Joerg Roedel:
      
       - fix VT-d regression with handling multiple RMRR entries per device
      
       - fix a small race that was left in the mmu_notifier handling in the
         AMD IOMMUv2 driver
      
      * tag 'iommu-fixes-v3.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
        iommu/amd: Fix small race between invalidate_range_end/start
        iommu/vt-d: fix bug in handling multiple RMRRs for the same PCI device
      3e7b256c
    • L
      Merge branch 'x86/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · d1fc98ba
      Linus Torvalds 提交于
      Pull x86 fixes from Peter Anvin:
       "A pile of fixes related to the VDSO, EFI and 32-bit badsys handling.
      
        It turns out that removing the section headers from the VDSO breaks
        gdb, so this puts back most of them.  A very simple typo broke
        rt_sigreturn on some versions of glibc, with obviously disastrous
        results.  The rest is pretty much fixes for the corresponding fallout.
      
        The EFI fixes fixes an arithmetic overflow on 32-bit systems and
        quiets some build warnings.
      
        Finally, when invoking an invalid system call number on x86-32, we
        bypass a bunch of handling, which can make the audit code oops"
      
      * 'x86/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        efi-pstore: Fix an overflow on 32-bit builds
        x86/vdso: Error out in vdso2c if DT_RELA is present
        x86/vdso: Move DISABLE_BRANCH_PROFILING into the vdso makefile
        x86_32, signal: Fix vdso rt_sigreturn
        x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508)
        x86/vdso: Create .build-id links for unstripped vdso files
        x86/vdso: Remove some redundant in-memory section headers
        x86/vdso: Improve the fake section headers
        x86/vdso2c: Use better macros for ELF bitness
        x86/vdso: Discard the __bug_table section
        efi: Fix compiler warnings (unused, const, type)
      d1fc98ba