Commit 68282dd
committed
ring-buffer: Fix resetting of shortest_full
The "shortest_full" variable is used to keep track of the waiter that is
waiting for the smallest amount on the ring buffer before being woken up.
When a tasks waits on the ring buffer, it passes in a "full" value that is
a percentage. 0 means wake up on any data. 1-100 means wake up from 1% to
100% full buffer.
As all waiters are on the same wait queue, the wake up happens for the
waiter with the smallest percentage.
The problem is that the smallest_full on the cpu_buffer that stores the
smallest amount doesn't get reset when all the waiters are woken up. It
does get reset when the ring buffer is reset (echo > /sys/kernel/tracing/trace).
This means that tasks may be woken up more often then when they want to
be. Instead, have the shortest_full field get reset just before waking up
all the tasks. If the tasks wait again, they will update the shortest_full
before sleeping.
Also add locking around setting of shortest_full in the poll logic, and
change "work" to "rbwork" to match the variable name for rb_irq_work
structures that are used in other places.
Link: https://lore.kernel.org/linux-trace-kernel/[email protected]
Cc: [email protected]
Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: linke li <[email protected]>
Cc: Rabin Vincent <[email protected]>
Fixes: 2c2b0a7 ("ring-buffer: Add percentage of ring buffer full to wake up reader")
Signed-off-by: Steven Rostedt (Google) <[email protected]>1 parent b359457 commit 68282dd
1 file changed
+23
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
758 | 764 | | |
759 | 765 | | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
760 | 771 | | |
761 | 772 | | |
762 | 773 | | |
| |||
934 | 945 | | |
935 | 946 | | |
936 | 947 | | |
937 | | - | |
| 948 | + | |
938 | 949 | | |
939 | 950 | | |
940 | | - | |
| 951 | + | |
941 | 952 | | |
942 | 953 | | |
943 | 954 | | |
944 | 955 | | |
945 | 956 | | |
946 | 957 | | |
947 | | - | |
| 958 | + | |
948 | 959 | | |
949 | 960 | | |
950 | 961 | | |
951 | | - | |
952 | | - | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
953 | 968 | | |
954 | 969 | | |
955 | 970 | | |
| 971 | + | |
956 | 972 | | |
957 | | - | |
958 | | - | |
| 973 | + | |
| 974 | + | |
959 | 975 | | |
960 | 976 | | |
961 | 977 | | |
| |||
0 commit comments