ANDROID: shmem: vendor hook in shmem_alloc_page

Some drivers can maintain its own pool of shmem pages that can reduce
the latencies in allocation of them by avoiding in getting a page from
buddy. To support this, add a vendor hook which first tries to get the
page from the driver maintained shmem pool when shmem_alloc_page is
called. If failed, it will simply fall back to the original path.

Bug: 187798288
Change-Id: I5deaf995b2e2ac40c2192096435954ee3f4a4fa8
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
This commit is contained in:
Charan Teja Reddy
2021-07-06 19:04:50 +05:30
committed by Suren Baghdasaryan
parent bd2ca0ba5b
commit 964220d080
3 changed files with 27 additions and 1 deletions

View File

@@ -64,6 +64,7 @@
#include <trace/hooks/cpuidle_psci.h>
#include <trace/hooks/fips140.h>
#include <trace/hooks/remoteproc.h>
#include <trace/hooks/shmem_fs.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -106,6 +107,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_wait_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_start);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_show_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shmem_alloc_page);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_idle_enter);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_idle_exit);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mpam_set);

View File

@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM shmem_fs
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_SHMEM_FS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_SHMEM_FS_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
struct page;
DECLARE_HOOK(android_vh_shmem_alloc_page,
TP_PROTO(struct page **page),
TP_ARGS(page));
#endif /* _TRACE_HOOK_SHMEM_FS_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@@ -42,6 +42,9 @@
#include <asm/tlbflush.h> /* for arch/microblaze update_mmu_cache() */
#undef CREATE_TRACE_POINTS
#include <trace/hooks/shmem_fs.h>
static struct vfsmount *shm_mnt;
#ifdef CONFIG_SHMEM
@@ -1560,7 +1563,11 @@ static struct page *shmem_alloc_page(gfp_t gfp,
struct shmem_inode_info *info, pgoff_t index)
{
struct vm_area_struct pvma;
struct page *page;
struct page *page = NULL;
trace_android_vh_shmem_alloc_page(&page);
if (page)
return page;
shmem_pseudo_vma_init(&pvma, info, index);
page = alloc_page_vma(gfp, &pvma, 0);