projects/linux·commit 42e1b14b

Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

42e1b14b · Linus Torvalds <[email protected]> · 2017-02-20 13:23:30 -08:00

Pull locking updates from Ingo Molnar:
 "The main changes in this cycle were:

   - Implement wraparound-safe refcount_t and kref_t types based on
     generic atomic primitives (Peter Zijlstra)

   - Improve and fix the ww_mutex code (Nicolai Hähnle)

   - Add self-tests to the ww_mutex code (Chris Wilson)

   - Optimize percpu-rwsems with the 'rcuwait' mechanism (Davidlohr
     Bueso)

   - Micro-optimize the current-task logic all around the core kernel
     (Davidlohr Bueso)

   - Tidy up after recent optimizations: remove stale code and APIs,
     clean up the code (Waiman Long)

   - ... plus misc fixes, updates and cleanups"

* 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (50 commits)
  fork: Fix task_struct alignment
  locking/spinlock/debug: Remove spinlock lockup detection code
  lockdep: Fix incorrect condition to print bug msgs for MAX_LOCKDEP_CHAIN_HLOCKS
  lkdtm: Convert to refcount_t testing
  kref: Implement 'struct kref' using refcount_t
  refcount_t: Introduce a special purpose refcount type
  sched/wake_q: Clarify queue reinit comment
  sched/wait, rcuwait: Fix typo in comment
  locking/mutex: Fix lockdep_assert_held() fail
  locking/rtmutex: Flip unlikely() branch to likely() in __rt_mutex_slowlock()
  locking/rwsem: Reinit wake_q after use
  locking/rwsem: Remove unnecessary atomic_long_t casts
  jump_labels: Move header guard #endif down where it belongs
  locking/atomic, kref: Implement kref_put_lock()
  locking/ww_mutex: Turn off __must_check for now
  locking/atomic, kref: Avoid more abuse
  locking/atomic, kref: Use kref_get_unless_zero() more
  locking/atomic, kref: Kill kref_sub()
  locking/atomic, kref: Add kref_read()
  locking/atomic, kref: Add KREF_INIT()
  ...
Commit
42e1b14b6e1455ece2ccbe474c25388d0230a590
Parents
828cad8e · 95cb64c1

Merge commit. Changes below are compared with the first parent: 828cad8e.

Changes

116 files changed · +1864 −761

FileStatusAddDelContent
Documentation/locking/ww-mutex-design.txtmodified+8−4View file
arch/um/drivers/random.cmodified+1−1View file
arch/x86/include/asm/spinlock.hmodified+0−3View file
arch/x86/kernel/jump_label.cmodified+1−2View file
arch/x86/kernel/kvm.cmodified+0−14View file
arch/x86/kernel/paravirt-spinlocks.cmodified+0−3View file
arch/x86/xen/spinlock.cmodified+0−19View file
drivers/block/drbd/drbd_bitmap.cmodified+1−1View file
drivers/block/drbd/drbd_main.cmodified+4−3View file
drivers/block/drbd/drbd_req.cmodified+10−21View file
drivers/block/rbd.cmodified+4−4View file
drivers/block/virtio_blk.cmodified+1−1View file
drivers/gpu/drm/drm_gem_cma_helper.cmodified+1−1View file
drivers/gpu/drm/drm_info.cmodified+1−1View file
drivers/gpu/drm/drm_mode_object.cmodified+2−2View file
drivers/gpu/drm/etnaviv/etnaviv_gem.cmodified+1−1View file
drivers/gpu/drm/i915/i915_gem_object.hmodified+1−1View file
drivers/gpu/drm/msm/msm_gem.cmodified+1−1View file
drivers/gpu/drm/nouveau/nouveau_fence.cmodified+1−1View file
drivers/gpu/drm/omapdrm/omap_gem.cmodified+1−1View file
drivers/gpu/drm/ttm/ttm_bo.cmodified+18−45View file
drivers/gpu/drm/ttm/ttm_execbuf_util.cmodified+1−3View file
drivers/gpu/drm/ttm/ttm_object.cmodified+1−1View file
drivers/infiniband/hw/cxgb3/iwch_cm.hmodified+3−3View file
drivers/infiniband/hw/cxgb3/iwch_qp.cmodified+1−1View file
drivers/infiniband/hw/cxgb4/iw_cxgb4.hmodified+3−3View file
drivers/infiniband/hw/cxgb4/qp.cmodified+1−1View file
drivers/infiniband/hw/usnic/usnic_ib_sysfs.cmodified+3−3View file
drivers/infiniband/hw/usnic/usnic_ib_verbs.cmodified+2−2View file
drivers/md/dm-bufio.cmodified+1−1View file
drivers/md/dm-crypt.cmodified+2−2View file
drivers/md/persistent-data/dm-block-manager.cmodified+2−2View file
drivers/misc/genwqe/card_dev.cmodified+1−1View file
drivers/misc/lkdtm.hmodified+6−2View file
drivers/misc/lkdtm_bugs.cmodified+73−14View file
drivers/misc/lkdtm_core.cmodified+6−2View file
drivers/misc/mei/debugfs.cmodified+1−1View file
drivers/pci/hotplug/pnv_php.cmodified+1−1View file
drivers/pci/slot.cmodified+1−1View file
drivers/scsi/bnx2fc/bnx2fc_io.cmodified+4−4View file
drivers/scsi/cxgbi/libcxgbi.hmodified+2−2View file
drivers/scsi/lpfc/lpfc_debugfs.cmodified+1−1View file
drivers/scsi/lpfc/lpfc_els.cmodified+1−1View file
drivers/scsi/lpfc/lpfc_hbadisc.cmodified+20−20View file
drivers/scsi/lpfc/lpfc_init.cmodified+1−2View file
drivers/scsi/qla2xxx/tcm_qla2xxx.cmodified+2−2View file
drivers/staging/android/ion/ion.cmodified+1−1View file
drivers/staging/comedi/comedi_buf.cmodified+1−1View file
drivers/staging/lustre/lnet/libcfs/linux/linux-debug.cmodified+1−1View file
drivers/target/target_core_pr.cmodified+5−5View file
drivers/target/tcm_fc/tfc_sess.cmodified+1−1View file
drivers/tty/tty_ldsem.cmodified+8−10View file
drivers/usb/gadget/function/f_fs.cmodified+1−1View file
drivers/usb/mon/mon_main.cmodified+1−1View file
fs/exofs/sys.cmodified+1−1View file
fs/fuse/fuse_i.hmodified+1−1View file
fs/ocfs2/cluster/netdebug.cmodified+1−1View file
fs/ocfs2/cluster/tcp.cmodified+1−1View file
fs/ocfs2/dlm/dlmdebug.cmodified+6−6View file
fs/ocfs2/dlm/dlmdomain.cmodified+1−1View file
fs/ocfs2/dlm/dlmmaster.cmodified+4−4View file
fs/ocfs2/dlm/dlmunlock.cmodified+1−1View file
include/asm-generic/rwsem.hmodified+6−7View file
include/drm/drm_framebuffer.hmodified+1−1View file
include/drm/ttm/ttm_bo_api.hmodified+1−14View file
include/drm/ttm/ttm_bo_driver.hmodified+2−2View file
include/linux/jump_label.hmodified+2−2View file
include/linux/kref.hmodified+32−46View file
include/linux/mutex.hmodified+4−1View file
include/linux/percpu-rwsem.hmodified+4−4View file
include/linux/poison.hmodified+1−0View file
include/linux/rcuwait.hadded+63−0View file
include/linux/refcount.hadded+294−0View file
include/linux/sched.hmodified+9−28View file
include/linux/spinlock.hmodified+0−8View file
include/linux/spinlock_api_smp.hmodified+0−2View file
include/linux/spinlock_api_up.hmodified+0−1View file
include/linux/sunrpc/cache.hmodified+1−1View file
include/linux/ww_mutex.hmodified+7−25View file
include/net/bluetooth/hci_core.hmodified+2−2View file
init/version.cmodified+1−3View file
kernel/exit.cmodified+41−11View file
kernel/fork.cmodified+4−2View file
kernel/locking/Makefilemodified+1−0View file
kernel/locking/lockdep.cmodified+1−1View file
kernel/locking/locktorture.cmodified+73−0View file
kernel/locking/mutex-debug.hmodified+0−17View file
kernel/locking/mutex.cmodified+332−184View file
kernel/locking/mutex.hmodified+0−4View file
kernel/locking/percpu-rwsem.cmodified+3−4View file
kernel/locking/qspinlock_paravirt.hmodified+1−1View file
kernel/locking/rtmutex.cmodified+1−1View file
kernel/locking/rwsem-spinlock.cmodified+7−11View file
kernel/locking/rwsem-xadd.cmodified+8−6View file
kernel/locking/semaphore.cmodified+3−4View file
kernel/locking/spinlock.cmodified+0−8View file
kernel/locking/spinlock_debug.cmodified+5−81View file
kernel/locking/test-ww_mutex.cadded+646−0View file
kernel/pid.cmodified+1−3View file
lib/Kconfig.debugmodified+25−0View file
net/bluetooth/6lowpan.cmodified+1−1View file
net/bluetooth/a2mp.cmodified+2−2View file
net/bluetooth/amp.cmodified+2−2View file
net/bluetooth/l2cap_core.cmodified+2−2View file
net/ceph/messenger.cmodified+2−2View file
net/ceph/osd_client.cmodified+5−5View file
net/sunrpc/cache.cmodified+1−1View file
net/sunrpc/svc_xprt.cmodified+3−3View file
net/sunrpc/svcauth.cmodified+10−5View file
net/sunrpc/xprtrdma/svc_rdma_transport.cmodified+2−2View file
security/apparmor/include/apparmor.hmodified+0−6View file
security/apparmor/include/policy.hmodified+2−2View file
tools/testing/selftests/locking/ww_mutex.shadded+10−0View file
tools/testing/selftests/rcutorture/configs/lock/CFLISTmodified+1−0View file
tools/testing/selftests/rcutorture/configs/lock/LOCK07added+6−0View file
tools/testing/selftests/rcutorture/configs/lock/LOCK07.bootadded+1−0View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/locking/ww-mutex-design.txt

View file
diff --git a/Documentation/locking/ww-mutex-design.txt b/Documentation/locking/ww-mutex-design.txt
index 8a112dc..34c3a1b 100644
--- a/Documentation/locking/ww-mutex-design.txt
+++ b/Documentation/locking/ww-mutex-design.txt
@@ -309,11 +309,15 @@ Design:
normal mutex locks, which are far more common. As such there is only a small
increase in code size if wait/wound mutexes are not used.
+ We maintain the following invariants for the wait list:
+ (1) Waiters with an acquire context are sorted by stamp order; waiters
+ without an acquire context are interspersed in FIFO order.
+ (2) Among waiters with contexts, only the first one can have other locks
+ acquired already (ctx->acquired > 0). Note that this waiter may come
+ after other waiters without contexts in the list.
+
In general, not much contention is expected. The locks are typically used to
- serialize access to resources for devices. The only way to make wakeups
- smarter would be at the cost of adding a field to struct mutex_waiter. This
- would add overhead to all cases where normal mutexes are used, and
- ww_mutexes are generally less performance sensitive.
+ serialize access to resources for devices.
Lockdep:
Special care has been taken to warn for as many cases of api abuse

arch/um/drivers/random.c

View file
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index 05523f1..57f0305 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -76,7 +76,7 @@ static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size,
add_sigio_fd(random_fd);
add_wait_queue(&host_read_wait, &wait);
- set_task_state(current, TASK_INTERRUPTIBLE);
+ set_current_state(TASK_INTERRUPTIBLE);
schedule();
remove_wait_queue(&host_read_wait, &wait);

arch/x86/include/asm/spinlock.h

View file
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 921bea7..6d39190 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -23,9 +23,6 @@
/* How long a lock should spin before we consider blocking */
#define SPIN_THRESHOLD (1 << 15)
-extern struct static_key paravirt_ticketlocks_enabled;
-static __always_inline bool static_key_false(struct static_key *key);
-
#include <asm/qspinlock.h>
/*

arch/x86/kernel/jump_label.c

View file
diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index fc25f69..c37bd0f 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -32,8 +32,7 @@ static void bug_at(unsigned char *ip, int line)
* Something went wrong. Crash the box, as something could be
* corrupting the kernel.
*/
- pr_warning("Unexpected op at %pS [%p] (%02x %02x %02x %02x %02x) %s:%d\n",
- ip, ip, ip[0], ip[1], ip[2], ip[3], ip[4], __FILE__, line);
+ pr_crit("jump_label: Fatal kernel bug, unexpected op at %pS [%p] (%5ph) %d\n", ip, ip, ip, line);
BUG();
}

arch/x86/kernel/kvm.c

View file
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 36bc664..099fcba 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -620,18 +620,4 @@ void __init kvm_spinlock_init(void)
}
}
-static __init int kvm_spinlock_init_jump(void)
-{
- if (!kvm_para_available())
- return 0;
- if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
- return 0;
-
- static_key_slow_inc(&paravirt_ticketlocks_enabled);
- printk(KERN_INFO "KVM setup paravirtual spinlock\n");
-
- return 0;
-}
-early_initcall(kvm_spinlock_init_jump);
-
#endif /* CONFIG_PARAVIRT_SPINLOCKS */

arch/x86/kernel/paravirt-spinlocks.c

View file
diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
index 6d4bf81..6259327 100644
--- a/arch/x86/kernel/paravirt-spinlocks.c
+++ b/arch/x86/kernel/paravirt-spinlocks.c
@@ -42,6 +42,3 @@ struct pv_lock_ops pv_lock_ops = {
#endif /* SMP */
};
EXPORT_SYMBOL(pv_lock_ops);
-
-struct static_key paravirt_ticketlocks_enabled = STATIC_KEY_INIT_FALSE;
-EXPORT_SYMBOL(paravirt_ticketlocks_enabled);

arch/x86/xen/spinlock.c

View file
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index e8a9ea7..25a7c43 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -141,25 +141,6 @@ void __init xen_init_spinlocks(void)
pv_lock_ops.vcpu_is_preempted = PV_CALLEE_SAVE(xen_vcpu_stolen);
}
-/*
- * While the jump_label init code needs to happend _after_ the jump labels are
- * enabled and before SMP is started. Hence we use pre-SMP initcall level
- * init. We cannot do it in xen_init_spinlocks as that is done before
- * jump labels are activated.
- */
-static __init int xen_init_spinlocks_jump(void)
-{
- if (!xen_pvspin)
- return 0;
-
- if (!xen_domain())
- return 0;
-
- static_key_slow_inc(&paravirt_ticketlocks_enabled);
- return 0;
-}
-early_initcall(xen_init_spinlocks_jump);
-
static __init int xen_parse_nopvspin(char *arg)
{
xen_pvspin = false;

drivers/block/drbd/drbd_bitmap.c

View file
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index ab62b81..dece26f 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -1070,7 +1070,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned
.done = 0,
.flags = flags,
.error = 0,
- .kref = { ATOMIC_INIT(2) },
+ .kref = KREF_INIT(2),
};
if (!get_ldev_if_state(device, D_ATTACHING)) { /* put is in drbd_bm_aio_ctx_destroy() */

drivers/block/drbd/drbd_main.c

View file
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 8348272..c3ff60c 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2948,7 +2948,6 @@ void drbd_delete_device(struct drbd_device *device)
struct drbd_resource *resource = device->resource;
struct drbd_connection *connection;
struct drbd_peer_device *peer_device;
- int refs = 3;
/* move to free_peer_device() */
for_each_peer_device(peer_device, device)
@@ -2956,13 +2955,15 @@ void drbd_delete_device(struct drbd_device *device)
drbd_debugfs_device_cleanup(device);
for_each_connection(connection, resource) {
idr_remove(&connection->peer_devices, device->vnr);
- refs++;
+ kref_put(&device->kref, drbd_destroy_device);
}
idr_remove(&resource->devices, device->vnr);
+ kref_put(&device->kref, drbd_destroy_device);
idr_remove(&drbd_devices, device_to_minor(device));
+ kref_put(&device->kref, drbd_destroy_device);
del_gendisk(device->vdisk);
synchronize_rcu();
- kref_sub(&device->kref, refs, drbd_destroy_device);
+ kref_put(&device->kref, drbd_destroy_device);
}
static int __init drbd_init(void)

drivers/block/drbd/drbd_req.c

View file
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index de279fe..b489ac2 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -421,7 +421,6 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
struct drbd_peer_device *peer_device = first_peer_device(device);
unsigned s = req->rq_state;
int c_put = 0;
- int k_put = 0;
if (drbd_suspended(device) && !((s | clear) & RQ_COMPLETION_SUSP))
set |= RQ_COMPLETION_SUSP;
@@ -437,6 +436,8 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
/* intent: get references */
+ kref_get(&req->kref);
+
if (!(s & RQ_LOCAL_PENDING) && (set & RQ_LOCAL_PENDING))
atomic_inc(&req->completion_ref);
@@ -473,15 +474,12 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
if (!(s & RQ_LOCAL_ABORTED) && (set & RQ_LOCAL_ABORTED)) {
D_ASSERT(device, req->rq_state & RQ_LOCAL_PENDING);
- /* local completion may still come in later,
- * we need to keep the req object around. */
- kref_get(&req->kref);
++c_put;
}
if ((s & RQ_LOCAL_PENDING) && (clear & RQ_LOCAL_PENDING)) {
if (req->rq_state & RQ_LOCAL_ABORTED)
- ++k_put;
+ kref_put(&req->kref, drbd_req_destroy);
else
++c_put;
list_del_init(&req->req_pending_local);
@@ -503,7 +501,7 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
if (s & RQ_NET_SENT)
atomic_sub(req->i.size >> 9, &device->ap_in_flight);
if (s & RQ_EXP_BARR_ACK)
- ++k_put;
+ kref_put(&req->kref, drbd_req_destroy);
req->net_done_jif = jiffies;
/* in ahead/behind mode, or just in case,
@@ -516,25 +514,16 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
/* potentially complete and destroy */
- if (k_put || c_put) {
- /* Completion does it's own kref_put. If we are going to
- * kref_sub below, we need req to be still around then. */
- int at_least = k_put + !!c_put;
- int refcount = atomic_read(&req->kref.refcount);
- if (refcount < at_least)
- drbd_err(device,
- "mod_rq_state: Logic BUG: %x -> %x: refcount = %d, should be >= %d\n",
- s, req->rq_state, refcount, at_least);
- }
-
/* If we made progress, retry conflicting peer requests, if any. */
if (req->i.waiting)
wake_up(&device->misc_wait);
- if (c_put)
- k_put += drbd_req_put_completion_ref(req, m, c_put);
- if (k_put)
- kref_sub(&req->kref, k_put, drbd_req_destroy);
+ if (c_put) {
+ if (drbd_req_put_completion_ref(req, m, c_put))
+ kref_put(&req->kref, drbd_req_destroy);
+ } else {
+ kref_put(&req->kref, drbd_req_destroy);
+ }
}
static void drbd_report_io_error(struct drbd_device *device, struct drbd_request *req)

drivers/block/rbd.c

View file
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 36d2b9f..436baa6 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1535,7 +1535,7 @@ static bool obj_request_overlaps_parent(struct rbd_obj_request *obj_request)
static void rbd_obj_request_get(struct rbd_obj_request *obj_request)
{
dout("%s: obj %p (was %d)\n", __func__, obj_request,
- atomic_read(&obj_request->kref.refcount));
+ kref_read(&obj_request->kref));
kref_get(&obj_request->kref);
}
@@ -1544,14 +1544,14 @@ static void rbd_obj_request_put(struct rbd_obj_request *obj_request)
{
rbd_assert(obj_request != NULL);
dout("%s: obj %p (was %d)\n", __func__, obj_request,
- atomic_read(&obj_request->kref.refcount));
+ kref_read(&obj_request->kref));
kref_put(&obj_request->kref, rbd_obj_request_destroy);
}
static void rbd_img_request_get(struct rbd_img_request *img_request)
{
dout("%s: img %p (was %d)\n", __func__, img_request,
- atomic_read(&img_request->kref.refcount));
+ kref_read(&img_request->kref));
kref_get(&img_request->kref);
}
@@ -1562,7 +1562,7 @@ static void rbd_img_request_put(struct rbd_img_request *img_request)
{
rbd_assert(img_request != NULL);
dout("%s: img %p (was %d)\n", __func__, img_request,
- atomic_read(&img_request->kref.refcount));
+ kref_read(&img_request->kref));
if (img_request_child_test(img_request))
kref_put(&img_request->kref, rbd_parent_request_destroy);
else

drivers/block/virtio_blk.c

View file
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 10332c2..264c5ea 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -770,7 +770,7 @@ static void virtblk_remove(struct virtio_device *vdev)
/* Stop all the virtqueues. */
vdev->config->reset(vdev);
- refc = atomic_read(&disk_to_dev(vblk->disk)->kobj.kref.refcount);
+ refc = kref_read(&disk_to_dev(vblk->disk)->kobj.kref);
put_disk(vblk->disk);
vdev->config->del_vqs(vdev);
kfree(vblk->vqs);

drivers/gpu/drm/drm_gem_cma_helper.c

View file
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index 1d6c335..33cd516 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -376,7 +376,7 @@ void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj,
off = drm_vma_node_start(&obj->vma_node);
seq_printf(m, "%2d (%2d) %08llx %pad %p %zu",
- obj->name, obj->refcount.refcount.counter,
+ obj->name, kref_read(&obj->refcount),
off, &cma_obj->paddr, cma_obj->vaddr, obj->size);
seq_printf(m, "\n");

drivers/gpu/drm/drm_info.c

View file
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index ffb2ab3..6b68e90 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -118,7 +118,7 @@ static int drm_gem_one_name_info(int id, void *ptr, void *data)
seq_printf(m, "%6d %8zd %7d %8d\n",
obj->name, obj->size,
obj->handle_count,
- atomic_read(&obj->refcount.refcount));
+ kref_read(&obj->refcount));
return 0;
}

drivers/gpu/drm/drm_mode_object.c

View file
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index 9f17085..c6885a4 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -159,7 +159,7 @@ EXPORT_SYMBOL(drm_mode_object_find);
void drm_mode_object_unreference(struct drm_mode_object *obj)
{
if (obj->free_cb) {
- DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, atomic_read(&obj->refcount.refcount));
+ DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, kref_read(&obj->refcount));
kref_put(&obj->refcount, obj->free_cb);
}
}
@@ -176,7 +176,7 @@ EXPORT_SYMBOL(drm_mode_object_unreference);
void drm_mode_object_reference(struct drm_mode_object *obj)
{
if (obj->free_cb) {
- DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, atomic_read(&obj->refcount.refcount));
+ DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, kref_read(&obj->refcount));
kref_get(&obj->refcount);
}
}

drivers/gpu/drm/etnaviv/etnaviv_gem.c

View file
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 114dddb..aa6e35d 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -486,7 +486,7 @@ static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
seq_printf(m, "%08x: %c %2d (%2d) %08lx %p %zd\n",
etnaviv_obj->flags, is_active(etnaviv_obj) ? 'A' : 'I',
- obj->name, obj->refcount.refcount.counter,
+ obj->name, kref_read(&obj->refcount),
off, etnaviv_obj->vaddr, obj->size);
rcu_read_lock();

drivers/gpu/drm/i915/i915_gem_object.h

View file
diff --git a/drivers/gpu/drm/i915/i915_gem_object.h b/drivers/gpu/drm/i915/i915_gem_object.h
index 6a368de..ecfefb9 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/i915_gem_object.h
@@ -256,7 +256,7 @@ extern void drm_gem_object_unreference_unlocked(struct drm_gem_object *);
static inline bool
i915_gem_object_is_dead(const struct drm_i915_gem_object *obj)
{
- return atomic_read(&obj->base.refcount.refcount) == 0;
+ return kref_read(&obj->base.refcount) == 0;
}
static inline bool

drivers/gpu/drm/msm/msm_gem.c

View file
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 8098677..1974ccb 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -642,7 +642,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
seq_printf(m, "%08x: %c %2d (%2d) %08llx %p\t",
msm_obj->flags, is_active(msm_obj) ? 'A' : 'I',
- obj->name, obj->refcount.refcount.counter,
+ obj->name, kref_read(&obj->refcount),
off, msm_obj->vaddr);
for (id = 0; id < priv->num_aspaces; id++)

drivers/gpu/drm/nouveau/nouveau_fence.c

View file
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index a6126c9..88ee60d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -527,7 +527,7 @@ static bool nouveau_fence_no_signaling(struct dma_fence *f)
* caller should have a reference on the fence,
* else fence could get freed here
*/
- WARN_ON(atomic_read(&fence->base.refcount.refcount) <= 1);
+ WARN_ON(kref_read(&fence->base.refcount) <= 1);
/*
* This needs uevents to work correctly, but dma_fence_add_callback relies on

drivers/gpu/drm/omapdrm/omap_gem.c

View file
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 4a90c69..74a9968 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -1033,7 +1033,7 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
off = drm_vma_node_start(&obj->vma_node);
seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d",
- omap_obj->flags, obj->name, obj->refcount.refcount.counter,
+ omap_obj->flags, obj->name, kref_read(&obj->refcount),
off, &omap_obj->paddr, omap_obj->paddr_cnt,
omap_obj->vaddr, omap_obj->roll);

drivers/gpu/drm/ttm/ttm_bo.c

View file
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index d506361..ffc6cb5 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -140,8 +140,8 @@ static void ttm_bo_release_list(struct kref *list_kref)
struct ttm_bo_device *bdev = bo->bdev;
size_t acc_size = bo->acc_size;
- BUG_ON(atomic_read(&bo->list_kref.refcount));
- BUG_ON(atomic_read(&bo->kref.refcount));
+ BUG_ON(kref_read(&bo->list_kref));
+ BUG_ON(kref_read(&bo->kref));
BUG_ON(atomic_read(&bo->cpu_writers));
BUG_ON(bo->mem.mm_node != NULL);
BUG_ON(!list_empty(&bo->lru));
@@ -181,61 +181,46 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
}
EXPORT_SYMBOL(ttm_bo_add_to_lru);
-int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
+static void ttm_bo_ref_bug(struct kref *list_kref)
+{
+ BUG();
+}
+
+void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
{
struct ttm_bo_device *bdev = bo->bdev;
- int put_count = 0;
if (bdev->driver->lru_removal)
bdev->driver->lru_removal(bo);
if (!list_empty(&bo->swap)) {
list_del_init(&bo->swap);
- ++put_count;
+ kref_put(&bo->list_kref, ttm_bo_ref_bug);
}
if (!list_empty(&bo->lru)) {
list_del_init(&bo->lru);
- ++put_count;
+ kref_put(&bo->list_kref, ttm_bo_ref_bug);
}
-
- return put_count;
-}
-
-static void ttm_bo_ref_bug(struct kref *list_kref)
-{
- BUG();
-}
-
-void ttm_bo_list_ref_sub(struct ttm_buffer_object *bo, int count,
- bool never_free)
-{
- kref_sub(&bo->list_kref, count,
- (never_free) ? ttm_bo_ref_bug : ttm_bo_release_list);
}
void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
{
- int put_count;
-
spin_lock(&bo->glob->lru_lock);
- put_count = ttm_bo_del_from_lru(bo);
+ ttm_bo_del_from_lru(bo);
spin_unlock(&bo->glob->lru_lock);
- ttm_bo_list_ref_sub(bo, put_count, true);
}
EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
{
struct ttm_bo_device *bdev = bo->bdev;
- int put_count = 0;
lockdep_assert_held(&bo->resv->lock.base);
if (bdev->driver->lru_removal)
bdev->driver->lru_removal(bo);
- put_count = ttm_bo_del_from_lru(bo);
- ttm_bo_list_ref_sub(bo, put_count, true);
+ ttm_bo_del_from_lru(bo);
ttm_bo_add_to_lru(bo);
}
EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
@@ -447,7 +432,6 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
{
struct ttm_bo_device *bdev = bo->bdev;
struct ttm_bo_global *glob = bo->glob;
- int put_count;
int ret;
spin_lock(&glob->lru_lock);
@@ -455,13 +439,10 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
if (!ret) {
if (!ttm_bo_wait(bo, false, true)) {
- put_count = ttm_bo_del_from_lru(bo);
-
+ ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock);
ttm_bo_cleanup_memtype_use(bo);
- ttm_bo_list_ref_sub(bo, put_count, true);
-
return;
} else
ttm_bo_flush_all_fences(bo);
@@ -504,7 +485,6 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
bool no_wait_gpu)
{
struct ttm_bo_global *glob = bo->glob;
- int put_count;
int ret;
ret = ttm_bo_wait(bo, false, true);
@@ -554,15 +534,13 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
return ret;
}
- put_count = ttm_bo_del_from_lru(bo);
+ ttm_bo_del_from_lru(bo);
list_del_init(&bo->ddestroy);
- ++put_count;
+ kref_put(&bo->list_kref, ttm_bo_ref_bug);
spin_unlock(&glob->lru_lock);
ttm_bo_cleanup_memtype_use(bo);
- ttm_bo_list_ref_sub(bo, put_count, true);
-
return 0;
}
@@ -740,7 +718,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
struct ttm_bo_global *glob = bdev->glob;
struct ttm_mem_type_manager *man = &bdev->man[mem_type];
struct ttm_buffer_object *bo;
- int ret = -EBUSY, put_count;
+ int ret = -EBUSY;
spin_lock(&glob->lru_lock);
list_for_each_entry(bo, &man->lru, lru) {
@@ -771,13 +749,11 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
return ret;
}
- put_count = ttm_bo_del_from_lru(bo);
+ ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock);
BUG_ON(ret != 0);
- ttm_bo_list_ref_sub(bo, put_count, true);
-
ret = ttm_bo_evict(bo, interruptible, no_wait_gpu);
ttm_bo_unreserve(bo);
@@ -1669,7 +1645,6 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)
container_of(shrink, struct ttm_bo_global, shrink);
struct ttm_buffer_object *bo;
int ret = -EBUSY;
- int put_count;
uint32_t swap_placement = (TTM_PL_FLAG_CACHED | TTM_PL_FLAG_SYSTEM);
spin_lock(&glob->lru_lock);
@@ -1692,11 +1667,9 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)
return ret;
}
- put_count = ttm_bo_del_from_lru(bo);
+ ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock);
- ttm_bo_list_ref_sub(bo, put_count, true);
-
/**
* Move to system cached
*/

drivers/gpu/drm/ttm/ttm_execbuf_util.c

View file
diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
index d35bc49..5e1bcab 100644
--- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c

This diff is incomplete. Download the complete patch.

drivers/gpu/drm/ttm/ttm_object.c

View file

This diff is incomplete. Download the complete patch.

drivers/infiniband/hw/cxgb3/iwch_cm.h

View file

This diff is incomplete. Download the complete patch.

drivers/infiniband/hw/cxgb3/iwch_qp.c

View file

This diff is incomplete. Download the complete patch.

drivers/infiniband/hw/cxgb4/iw_cxgb4.h

View file

This diff is incomplete. Download the complete patch.

drivers/infiniband/hw/cxgb4/qp.c

View file

This diff is incomplete. Download the complete patch.

drivers/infiniband/hw/usnic/usnic_ib_sysfs.c

View file

This diff is incomplete. Download the complete patch.

drivers/infiniband/hw/usnic/usnic_ib_verbs.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/dm-bufio.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/dm-crypt.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/persistent-data/dm-block-manager.c

View file

This diff is incomplete. Download the complete patch.

drivers/misc/genwqe/card_dev.c

View file

This diff is incomplete. Download the complete patch.

drivers/misc/lkdtm.h

View file

This diff is incomplete. Download the complete patch.

drivers/misc/lkdtm_bugs.c

View file

This diff is incomplete. Download the complete patch.

drivers/misc/lkdtm_core.c

View file

This diff is incomplete. Download the complete patch.

drivers/misc/mei/debugfs.c

View file

This diff is incomplete. Download the complete patch.

drivers/pci/hotplug/pnv_php.c

View file

This diff is incomplete. Download the complete patch.

drivers/pci/slot.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/bnx2fc/bnx2fc_io.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/cxgbi/libcxgbi.h

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/lpfc/lpfc_debugfs.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/lpfc/lpfc_els.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/lpfc/lpfc_hbadisc.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/lpfc/lpfc_init.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/qla2xxx/tcm_qla2xxx.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/android/ion/ion.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/comedi/comedi_buf.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c

View file

This diff is incomplete. Download the complete patch.

drivers/target/target_core_pr.c

View file

This diff is incomplete. Download the complete patch.

drivers/target/tcm_fc/tfc_sess.c

View file

This diff is incomplete. Download the complete patch.

drivers/tty/tty_ldsem.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/gadget/function/f_fs.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/mon/mon_main.c

View file

This diff is incomplete. Download the complete patch.

fs/exofs/sys.c

View file

This diff is incomplete. Download the complete patch.

fs/fuse/fuse_i.h

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/cluster/netdebug.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/cluster/tcp.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/dlm/dlmdebug.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/dlm/dlmdomain.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/dlm/dlmmaster.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/dlm/dlmunlock.c

View file

This diff is incomplete. Download the complete patch.

include/asm-generic/rwsem.h

View file

This diff is incomplete. Download the complete patch.

include/drm/drm_framebuffer.h

View file

This diff is incomplete. Download the complete patch.

include/drm/ttm/ttm_bo_api.h

View file

This diff is incomplete. Download the complete patch.

include/drm/ttm/ttm_bo_driver.h

View file

This diff is incomplete. Download the complete patch.

include/linux/jump_label.h

View file

This diff is incomplete. Download the complete patch.

include/linux/kref.h

View file

This diff is incomplete. Download the complete patch.

include/linux/mutex.h

View file

This diff is incomplete. Download the complete patch.

include/linux/percpu-rwsem.h

View file

This diff is incomplete. Download the complete patch.

include/linux/poison.h

View file

This diff is incomplete. Download the complete patch.

include/linux/rcuwait.h

View file

This diff is incomplete. Download the complete patch.

include/linux/refcount.h

View file

This diff is incomplete. Download the complete patch.

include/linux/sched.h

View file

This diff is incomplete. Download the complete patch.

include/linux/spinlock.h

View file

This diff is incomplete. Download the complete patch.

include/linux/spinlock_api_smp.h

View file

This diff is incomplete. Download the complete patch.

include/linux/spinlock_api_up.h

View file

This diff is incomplete. Download the complete patch.

include/linux/sunrpc/cache.h

View file

This diff is incomplete. Download the complete patch.

include/linux/ww_mutex.h

View file

This diff is incomplete. Download the complete patch.

include/net/bluetooth/hci_core.h

View file

This diff is incomplete. Download the complete patch.

init/version.c

View file

This diff is incomplete. Download the complete patch.

kernel/exit.c

View file

This diff is incomplete. Download the complete patch.

kernel/fork.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/Makefile

View file

This diff is incomplete. Download the complete patch.

kernel/locking/lockdep.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/locktorture.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/mutex-debug.h

View file

This diff is incomplete. Download the complete patch.

kernel/locking/mutex.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/mutex.h

View file

This diff is incomplete. Download the complete patch.

kernel/locking/percpu-rwsem.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/qspinlock_paravirt.h

View file

This diff is incomplete. Download the complete patch.

kernel/locking/rtmutex.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/rwsem-spinlock.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/rwsem-xadd.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/semaphore.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/spinlock.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/spinlock_debug.c

View file

This diff is incomplete. Download the complete patch.

kernel/locking/test-ww_mutex.c

View file

This diff is incomplete. Download the complete patch.

kernel/pid.c

View file

This diff is incomplete. Download the complete patch.

lib/Kconfig.debug

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/6lowpan.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/a2mp.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/amp.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/l2cap_core.c

View file

This diff is incomplete. Download the complete patch.

net/ceph/messenger.c

View file

This diff is incomplete. Download the complete patch.

net/ceph/osd_client.c

View file

This diff is incomplete. Download the complete patch.

net/sunrpc/cache.c

View file

This diff is incomplete. Download the complete patch.

net/sunrpc/svc_xprt.c

View file

This diff is incomplete. Download the complete patch.

net/sunrpc/svcauth.c

View file

This diff is incomplete. Download the complete patch.

net/sunrpc/xprtrdma/svc_rdma_transport.c

View file

This diff is incomplete. Download the complete patch.

security/apparmor/include/apparmor.h

View file

This diff is incomplete. Download the complete patch.

security/apparmor/include/policy.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/locking/ww_mutex.sh

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/rcutorture/configs/lock/CFLIST

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/rcutorture/configs/lock/LOCK07

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot

View file

This diff is incomplete. Download the complete patch.