ANDROID: add hooks into blk-core.c for customized I/O scheduler

android_rvh_blk_allocated_queue_init: Allocate specific request_queue
information and save the pointer address in the ANDROID_OEM_DATA field.
The allocation process may be scheduled, so a restricted hook function
is used

android_rvh_blk_flush_plug_list: Flush the customized plug list. During
this process, the scheduled queue_rq will be called to process the
request, so a restricted hook function is used

Bug: 319582497

Change-Id: I0af3915de899b678ffd4f207cac2e35a744936b8
Signed-off-by: hao lv <hao.lv5@transsion.com>
This commit is contained in:
hao lv 2024-01-10 19:55:59 +08:00
parent ccbc7f8808
commit d269992366
3 changed files with 20 additions and 0 deletions

View File

@ -66,6 +66,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_merge);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_requeue);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_complete);
#undef CREATE_TRACE_POINTS
#include <trace/hooks/block.h>
DEFINE_IDA(blk_queue_ida);
/*
@ -522,6 +525,7 @@ struct request_queue *blk_alloc_queue(int node_id)
{
struct request_queue *q;
int ret;
bool skip = false;
q = kmem_cache_alloc_node(blk_requestq_cachep,
GFP_KERNEL | __GFP_ZERO, node_id);
@ -585,6 +589,10 @@ struct request_queue *blk_alloc_queue(int node_id)
blk_set_default_limits(&q->limits);
q->nr_requests = BLKDEV_MAX_RQ;
trace_android_rvh_blk_allocated_queue_init(&skip, q);
if (skip)
goto fail_ref;
return q;
fail_ref:
@ -1761,6 +1769,7 @@ EXPORT_SYMBOL(blk_check_plugged);
void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
{
trace_android_rvh_blk_flush_plug_list(plug, from_schedule);
flush_plug_callbacks(plug, from_schedule);
if (!list_empty(&plug->mq_list))

View File

@ -529,6 +529,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_blk_mq_alloc_rq_map);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_blk_mq_init_allocated_queue);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_mq_exit_queue);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_mq_alloc_tag_set);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_blk_allocated_queue_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_blk_flush_plug_list);
/*
* For type visibility
*/

View File

@ -26,6 +26,7 @@ struct blk_mq_hw_ctx;
struct bio;
struct request_queue;
struct request;
struct blk_plug;
DECLARE_HOOK(android_vh_blk_alloc_rqs,
TP_PROTO(size_t *rq_size, struct blk_mq_tag_set *set,
@ -98,6 +99,14 @@ DECLARE_HOOK(android_vh_blk_mq_update_nr_requests,
TP_PROTO(bool *skip, struct request_queue *q),
TP_ARGS(skip, q));
DECLARE_RESTRICTED_HOOK(android_rvh_blk_allocated_queue_init,
TP_PROTO(bool *skip, struct request_queue *q),
TP_ARGS(skip, q), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_blk_flush_plug_list,
TP_PROTO(struct blk_plug *plug, bool from_schedule),
TP_ARGS(plug, from_schedule), 1);
#endif /* _TRACE_HOOK_BLOCK_H */
/* This part must be outside protection */