Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f0f512e authored by JianMin Liu's avatar JianMin Liu Committed by Todd Kjos
Browse files

ANDROID: futex: Add vendor hook for wait queue



Add the hook for the waiter list of futex to allow
vendor perform wait queue enhancement

Bug: 163431711

Signed-off-by: default avatarJianMin Liu <jian-min.liu@mediatek.com>
Change-Id: I68218b89c35b23aa5529099bb0bbbd031bdeafef
parent 3b773b24
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <trace/hooks/net.h>
#include <trace/hooks/binder.h>
#include <trace/hooks/rwsem.h>
#include <trace/hooks/futex.h>

/*
 * Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -40,3 +41,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_wake);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_finished);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_rwsem_list_add);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_futex_plist_add);
+26 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM futex
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_FUTEX_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_FUTEX_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
#include <linux/plist.h>
/*
 * Following tracepoints are not exported in tracefs and provide a
 * mechanism for vendor modules to hook and extend functionality
 */
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
DECLARE_HOOK(android_vh_alter_futex_plist_add,
	TP_PROTO(struct plist_node *node,
		 struct plist_head *head,
		 bool *already_on_hb),
	TP_ARGS(node, head, already_on_hb));
#else
#define trace_android_vh_alter_futex_plist_add(node, head, already_on_hb)
#endif
#endif /* _TRACE_HOOK_FUTEX_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
+5 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@
#include <asm/futex.h>

#include "locking/rtmutex_common.h"
#include <trace/hooks/futex.h>

/*
 * READ this before attempting to hack on futexes!
@@ -2346,6 +2347,7 @@ queue_unlock(struct futex_hash_bucket *hb)
static inline void __queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
{
	int prio;
	bool already_on_hb = false;

	/*
	 * The priority used to register this element is
@@ -2358,6 +2360,8 @@ static inline void __queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
	prio = min(current->normal_prio, MAX_RT_PRIO);

	plist_node_init(&q->list, prio);
	trace_android_vh_alter_futex_plist_add(&q->list, &hb->chain, &already_on_hb);
	if (!already_on_hb)
		plist_add(&q->list, &hb->chain);
	q->task = current;
}