ANDROID: vendor_hook: Add hooks to support reader optimistic spin in rwsem

Since upstream commit 617f3ef951 ("locking/rwsem: Remove
reader optimistic spinning"), vendors have seen increased
contention and blocking on rwsems.

There are attempts to actively fix this upstream:
  https://lore.kernel.org/lkml/20240406081126.8030-1-bongkyu7.kim@samsung.com/

But in the meantime, provide vendorhooks so that vendors can
implement their own optimistic spin routine. In doing so,
vendors see improvements in cold launch times on important apps.

Bug: 433638448
Bug: 331742151

Change-Id: I7466413de9ee1293e86f73880931235d7a9142ac
Signed-off-by: xieliujie <xieliujie@oppo.com>
[jstultz: Rewrote commit message]
Signed-off-by: John Stultz <jstultz@google.com>
(cherry picked from commit abe0af2abe51fae4fb072c8d7124aaa37f1da574)
This commit is contained in:
xieliujie
2024-03-28 18:36:46 +08:00
committed by Todd Kjos
parent 379b99745e
commit 4f0fccc35a
4 changed files with 22 additions and 2 deletions
+6
View File
@@ -47,6 +47,12 @@ DECLARE_HOOK(android_vh_clear_rwsem_writer_owned,
DECLARE_HOOK(android_vh_rwsem_read_trylock_failed,
TP_PROTO(struct rw_semaphore *sem, long *cntp, int *ret),
TP_ARGS(sem, cntp, ret));
DECLARE_HOOK(android_vh_rwsem_direct_rsteal,
TP_PROTO(struct rw_semaphore *sem, bool *steal),
TP_ARGS(sem, steal));
DECLARE_HOOK(android_vh_rwsem_optimistic_rspin,
TP_PROTO(struct rw_semaphore *sem, long *adjustment, bool *rspin),
TP_ARGS(sem, adjustment, rspin));
#endif /* _TRACE_HOOK_RWSEM_H */
/* This part must be outside protection */
#include <trace/define_trace.h>