hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/tty/tty_ldsem.c
....@@ -34,29 +34,6 @@
3434 #include <linux/sched/task.h>
3535
3636
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
-
6037 #if BITS_PER_LONG == 64
6138 # define LDSEM_ACTIVE_MASK 0xffffffffL
6239 #else
....@@ -234,6 +211,7 @@
234211 raw_spin_lock_irq(&sem->wait_lock);
235212 if (waiter.task) {
236213 atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count);
214
+ sem->wait_readers--;
237215 list_del(&waiter.list);
238216 raw_spin_unlock_irq(&sem->wait_lock);
239217 put_task_struct(waiter.task);
....@@ -319,17 +297,17 @@
319297 {
320298 long count;
321299
322
- lockdep_acquire_read(sem, subclass, 0, _RET_IP_);
300
+ rwsem_acquire_read(&sem->dep_map, subclass, 0, _RET_IP_);
323301
324302 count = atomic_long_add_return(LDSEM_READ_BIAS, &sem->count);
325303 if (count <= 0) {
326
- lock_stat(sem, contended);
304
+ lock_contended(&sem->dep_map, _RET_IP_);
327305 if (!down_read_failed(sem, count, timeout)) {
328
- lockdep_release(sem, 1, _RET_IP_);
306
+ rwsem_release(&sem->dep_map, _RET_IP_);
329307 return 0;
330308 }
331309 }
332
- lock_stat(sem, acquired);
310
+ lock_acquired(&sem->dep_map, _RET_IP_);
333311 return 1;
334312 }
335313
....@@ -338,17 +316,17 @@
338316 {
339317 long count;
340318
341
- lockdep_acquire(sem, subclass, 0, _RET_IP_);
319
+ rwsem_acquire(&sem->dep_map, subclass, 0, _RET_IP_);
342320
343321 count = atomic_long_add_return(LDSEM_WRITE_BIAS, &sem->count);
344322 if ((count & LDSEM_ACTIVE_MASK) != LDSEM_ACTIVE_BIAS) {
345
- lock_stat(sem, contended);
323
+ lock_contended(&sem->dep_map, _RET_IP_);
346324 if (!down_write_failed(sem, count, timeout)) {
347
- lockdep_release(sem, 1, _RET_IP_);
325
+ rwsem_release(&sem->dep_map, _RET_IP_);
348326 return 0;
349327 }
350328 }
351
- lock_stat(sem, acquired);
329
+ lock_acquired(&sem->dep_map, _RET_IP_);
352330 return 1;
353331 }
354332
....@@ -371,8 +349,8 @@
371349
372350 while (count >= 0) {
373351 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_);
376354 return 1;
377355 }
378356 }
....@@ -397,8 +375,8 @@
397375
398376 while ((count & LDSEM_ACTIVE_MASK) == 0) {
399377 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_);
402380 return 1;
403381 }
404382 }
....@@ -412,7 +390,7 @@
412390 {
413391 long count;
414392
415
- lockdep_release(sem, 1, _RET_IP_);
393
+ rwsem_release(&sem->dep_map, _RET_IP_);
416394
417395 count = atomic_long_add_return(-LDSEM_READ_BIAS, &sem->count);
418396 if (count < 0 && (count & LDSEM_ACTIVE_MASK) == 0)
....@@ -426,7 +404,7 @@
426404 {
427405 long count;
428406
429
- lockdep_release(sem, 1, _RET_IP_);
407
+ rwsem_release(&sem->dep_map, _RET_IP_);
430408
431409 count = atomic_long_add_return(-LDSEM_WRITE_BIAS, &sem->count);
432410 if (count < 0)