Commit 538d710
posix-timers: Make lock_timer() use guard()
The lookup and locking of posix timers requires the same repeating pattern
at all usage sites:
tmr = lock_timer(tiner_id);
if (!tmr)
return -EINVAL;
....
unlock_timer(tmr);
Solve this with a guard implementation, which works in most places out of
the box except for those, which need to unlock the timer inside the guard
scope.
Though the only places where this matters are timer_delete() and
timer_settime(). In both cases the timer pointer needs to be preserved
across the end of the scope, which is solved by storing the pointer in a
variable outside of the scope.
timer_settime() also has to protect the timer with RCU before unlocking,
which obviously can't use guard(rcu) before leaving the guard scope as that
guard is cleaned up before the unlock. Solve this by providing the RCU
protection open coded.
[ tglx: Made it work and added change log ]
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/all/20250224162103.GD11590@noisy.programming.kicks-ass.net
Link: https://lore.kernel.org/all/20250308155624.087465658@linutronix.de1 parent 1d25bdd commit 538d710
2 files changed
Lines changed: 50 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
295 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
296 | 307 | | |
297 | | - | |
298 | | - | |
| 308 | + | |
299 | 309 | | |
300 | 310 | | |
301 | 311 | | |
| |||
375 | 385 | | |
376 | 386 | | |
377 | 387 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 388 | + | |
383 | 389 | | |
384 | 390 | | |
385 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
| |||
682 | 691 | | |
683 | 692 | | |
684 | 693 | | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | 694 | | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
697 | 698 | | |
698 | 699 | | |
699 | 700 | | |
| |||
747 | 748 | | |
748 | 749 | | |
749 | 750 | | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
| 751 | + | |
| 752 | + | |
761 | 753 | | |
762 | 754 | | |
763 | 755 | | |
| |||
875 | 867 | | |
876 | 868 | | |
877 | 869 | | |
878 | | - | |
879 | | - | |
| 870 | + | |
880 | 871 | | |
881 | 872 | | |
882 | | - | |
883 | | - | |
884 | 873 | | |
885 | 874 | | |
886 | 875 | | |
887 | 876 | | |
888 | 877 | | |
889 | 878 | | |
890 | 879 | | |
891 | | - | |
892 | | - | |
| 880 | + | |
| 881 | + | |
893 | 882 | | |
894 | | - | |
895 | | - | |
| 883 | + | |
| 884 | + | |
896 | 885 | | |
897 | | - | |
898 | | - | |
| 886 | + | |
| 887 | + | |
899 | 888 | | |
900 | | - | |
901 | | - | |
| 889 | + | |
| 890 | + | |
902 | 891 | | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
908 | 895 | | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
918 | 899 | | |
| 900 | + | |
919 | 901 | | |
920 | | - | |
921 | 902 | | |
922 | 903 | | |
923 | 904 | | |
| |||
1028 | 1009 | | |
1029 | 1010 | | |
1030 | 1011 | | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
| 1012 | + | |
1035 | 1013 | | |
1036 | | - | |
1037 | | - | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
1038 | 1018 | | |
1039 | 1019 | | |
1040 | 1020 | | |
| |||
0 commit comments