.. | .. |
---|
34 | 34 | #include <linux/sched/task.h> |
---|
35 | 35 | |
---|
36 | 36 | |
---|
37 | | -#ifdef CONFIG_DEBUG_LOCK_ALLOC |
---|
38 | | -# define __acq(l, s, t, r, c, n, i) \ |
---|
39 | | - lock_acquire(&(l)->dep_map, s, t, r, c, n, i) |
---|
40 | | -# define __rel(l, n, i) \ |
---|
41 | | - lock_release(&(l)->dep_map, n, i) |
---|
42 | | -#define lockdep_acquire(l, s, t, i) __acq(l, s, t, 0, 1, NULL, i) |
---|
43 | | -#define lockdep_acquire_nest(l, s, t, n, i) __acq(l, s, t, 0, 1, n, i) |
---|
44 | | -#define lockdep_acquire_read(l, s, t, i) __acq(l, s, t, 1, 1, NULL, i) |
---|
45 | | -#define lockdep_release(l, n, i) __rel(l, n, i) |
---|
46 | | -#else |
---|
47 | | -# define lockdep_acquire(l, s, t, i) do { } while (0) |
---|
48 | | -# define lockdep_acquire_nest(l, s, t, n, i) do { } while (0) |
---|
49 | | -# define lockdep_acquire_read(l, s, t, i) do { } while (0) |
---|
50 | | -# define lockdep_release(l, n, i) do { } while (0) |
---|
51 | | -#endif |
---|
52 | | - |
---|
53 | | -#ifdef CONFIG_LOCK_STAT |
---|
54 | | -# define lock_stat(_lock, stat) lock_##stat(&(_lock)->dep_map, _RET_IP_) |
---|
55 | | -#else |
---|
56 | | -# define lock_stat(_lock, stat) do { } while (0) |
---|
57 | | -#endif |
---|
58 | | - |
---|
59 | | - |
---|
60 | 37 | #if BITS_PER_LONG == 64 |
---|
61 | 38 | # define LDSEM_ACTIVE_MASK 0xffffffffL |
---|
62 | 39 | #else |
---|
.. | .. |
---|
234 | 211 | raw_spin_lock_irq(&sem->wait_lock); |
---|
235 | 212 | if (waiter.task) { |
---|
236 | 213 | atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count); |
---|
| 214 | + sem->wait_readers--; |
---|
237 | 215 | list_del(&waiter.list); |
---|
238 | 216 | raw_spin_unlock_irq(&sem->wait_lock); |
---|
239 | 217 | put_task_struct(waiter.task); |
---|
.. | .. |
---|
319 | 297 | { |
---|
320 | 298 | long count; |
---|
321 | 299 | |
---|
322 | | - lockdep_acquire_read(sem, subclass, 0, _RET_IP_); |
---|
| 300 | + rwsem_acquire_read(&sem->dep_map, subclass, 0, _RET_IP_); |
---|
323 | 301 | |
---|
324 | 302 | count = atomic_long_add_return(LDSEM_READ_BIAS, &sem->count); |
---|
325 | 303 | if (count <= 0) { |
---|
326 | | - lock_stat(sem, contended); |
---|
| 304 | + lock_contended(&sem->dep_map, _RET_IP_); |
---|
327 | 305 | if (!down_read_failed(sem, count, timeout)) { |
---|
328 | | - lockdep_release(sem, 1, _RET_IP_); |
---|
| 306 | + rwsem_release(&sem->dep_map, _RET_IP_); |
---|
329 | 307 | return 0; |
---|
330 | 308 | } |
---|
331 | 309 | } |
---|
332 | | - lock_stat(sem, acquired); |
---|
| 310 | + lock_acquired(&sem->dep_map, _RET_IP_); |
---|
333 | 311 | return 1; |
---|
334 | 312 | } |
---|
335 | 313 | |
---|
.. | .. |
---|
338 | 316 | { |
---|
339 | 317 | long count; |
---|
340 | 318 | |
---|
341 | | - lockdep_acquire(sem, subclass, 0, _RET_IP_); |
---|
| 319 | + rwsem_acquire(&sem->dep_map, subclass, 0, _RET_IP_); |
---|
342 | 320 | |
---|
343 | 321 | count = atomic_long_add_return(LDSEM_WRITE_BIAS, &sem->count); |
---|
344 | 322 | if ((count & LDSEM_ACTIVE_MASK) != LDSEM_ACTIVE_BIAS) { |
---|
345 | | - lock_stat(sem, contended); |
---|
| 323 | + lock_contended(&sem->dep_map, _RET_IP_); |
---|
346 | 324 | if (!down_write_failed(sem, count, timeout)) { |
---|
347 | | - lockdep_release(sem, 1, _RET_IP_); |
---|
| 325 | + rwsem_release(&sem->dep_map, _RET_IP_); |
---|
348 | 326 | return 0; |
---|
349 | 327 | } |
---|
350 | 328 | } |
---|
351 | | - lock_stat(sem, acquired); |
---|
| 329 | + lock_acquired(&sem->dep_map, _RET_IP_); |
---|
352 | 330 | return 1; |
---|
353 | 331 | } |
---|
354 | 332 | |
---|
.. | .. |
---|
371 | 349 | |
---|
372 | 350 | while (count >= 0) { |
---|
373 | 351 | if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_READ_BIAS)) { |
---|
374 | | - lockdep_acquire_read(sem, 0, 1, _RET_IP_); |
---|
375 | | - lock_stat(sem, acquired); |
---|
| 352 | + rwsem_acquire_read(&sem->dep_map, 0, 1, _RET_IP_); |
---|
| 353 | + lock_acquired(&sem->dep_map, _RET_IP_); |
---|
376 | 354 | return 1; |
---|
377 | 355 | } |
---|
378 | 356 | } |
---|
.. | .. |
---|
397 | 375 | |
---|
398 | 376 | while ((count & LDSEM_ACTIVE_MASK) == 0) { |
---|
399 | 377 | if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_WRITE_BIAS)) { |
---|
400 | | - lockdep_acquire(sem, 0, 1, _RET_IP_); |
---|
401 | | - lock_stat(sem, acquired); |
---|
| 378 | + rwsem_acquire(&sem->dep_map, 0, 1, _RET_IP_); |
---|
| 379 | + lock_acquired(&sem->dep_map, _RET_IP_); |
---|
402 | 380 | return 1; |
---|
403 | 381 | } |
---|
404 | 382 | } |
---|
.. | .. |
---|
412 | 390 | { |
---|
413 | 391 | long count; |
---|
414 | 392 | |
---|
415 | | - lockdep_release(sem, 1, _RET_IP_); |
---|
| 393 | + rwsem_release(&sem->dep_map, _RET_IP_); |
---|
416 | 394 | |
---|
417 | 395 | count = atomic_long_add_return(-LDSEM_READ_BIAS, &sem->count); |
---|
418 | 396 | if (count < 0 && (count & LDSEM_ACTIVE_MASK) == 0) |
---|
.. | .. |
---|
426 | 404 | { |
---|
427 | 405 | long count; |
---|
428 | 406 | |
---|
429 | | - lockdep_release(sem, 1, _RET_IP_); |
---|
| 407 | + rwsem_release(&sem->dep_map, _RET_IP_); |
---|
430 | 408 | |
---|
431 | 409 | count = atomic_long_add_return(-LDSEM_WRITE_BIAS, &sem->count); |
---|
432 | 410 | if (count < 0) |
---|