ANDROID: user: Add vendor hook to user for GKI purpose
In order to implement our scheduling tuning policy in certain cases, we need to initialize the variables that we have defined in the user_struct. To achieve this, we will add a vendor hook to user.c at alloc_uid, which will ensure that our own logic is executed during the initialization of the user_struct. Bug: 425550656 Bug: 339371220 Bug: 187458531 Signed-off-by: heshuai1 <heshuai1@xiaomi.com> Change-Id: I078484aac2c3d396aba5971d6d0f491652f3781c (cherry picked from commit c9b8fa644f45e9c99da85d8947f6c7e06771f205) (cherry picked from commit 9ac0923ef565e4de4e1f35edcba6fcb7e45948c9) (cherry picked from commit f0b0ff9fdb8ea1ea56fc7e3c556efdcfa93ec763) [jstultz: Add magic ANDROID_KABI_DECLONLY incantations to try to quiet CRC errors, then split those out into a separate patch] Signed-off-by: John Stultz <jstultz@google.com>
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
#include <trace/hooks/fuse.h>
|
||||
#include <trace/hooks/ogki_honor.h>
|
||||
#include <trace/hooks/suspend.h>
|
||||
#include <trace/hooks/user.h>
|
||||
|
||||
/*
|
||||
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
||||
@@ -572,3 +573,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_charge);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_add_folio);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_node);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_uid);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_user);
|
||||
|
||||
22
include/trace/hooks/user.h
Normal file
22
include/trace/hooks/user.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM user
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH trace/hooks
|
||||
#if !defined(_TRACE_HOOK_USER_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_HOOK_USER_H
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
|
||||
struct user_struct;
|
||||
DECLARE_HOOK(android_vh_alloc_uid,
|
||||
TP_PROTO(struct user_struct *user),
|
||||
TP_ARGS(user));
|
||||
|
||||
DECLARE_HOOK(android_vh_free_user,
|
||||
TP_PROTO(struct user_struct *up),
|
||||
TP_ARGS(up));
|
||||
|
||||
#endif /* _TRACE_HOOK_USER_H */
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <linux/binfmts.h>
|
||||
#include <linux/proc_ns.h>
|
||||
|
||||
#include <trace/hooks/user.h>
|
||||
|
||||
#if IS_ENABLED(CONFIG_BINFMT_MISC)
|
||||
struct binfmt_misc init_binfmt_misc = {
|
||||
.entries = LIST_HEAD_INIT(init_binfmt_misc.entries),
|
||||
@@ -165,6 +167,7 @@ static void user_epoll_free(struct user_struct *up)
|
||||
static void free_user(struct user_struct *up, unsigned long flags)
|
||||
__releases(&uidhash_lock)
|
||||
{
|
||||
trace_android_vh_free_user(up);
|
||||
uid_hash_remove(up);
|
||||
spin_unlock_irqrestore(&uidhash_lock, flags);
|
||||
user_epoll_free(up);
|
||||
@@ -217,6 +220,7 @@ struct user_struct *alloc_uid(kuid_t uid)
|
||||
|
||||
new->uid = uid;
|
||||
refcount_set(&new->__count, 1);
|
||||
trace_android_vh_alloc_uid(new);
|
||||
if (user_epoll_alloc(new)) {
|
||||
kmem_cache_free(uid_cachep, new);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user