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

android_vh_blk_mq_all_tag_iter: The customized solution adds a new tag
type, so need to use the customized solution for traversal

android_vh_blk_mq_queue_tag_busy_iter: The customized solution adds a
new tag type, so need to use the customized solution for traversal

android_vh_blk_mq_free_tags: Release the customized tag

Bug: 319582497

Change-Id: I648a9a31c11c284a75653405b8f8521d9da34d20
Signed-off-by: hao lv <hao.lv5@transsion.com>
This commit is contained in:
hao lv 2024-01-10 20:24:00 +08:00
parent f76294a655
commit 6912e0c8e9
3 changed files with 56 additions and 0 deletions

View File

@ -15,6 +15,8 @@
#include "blk-mq.h" #include "blk-mq.h"
#include "blk-mq-tag.h" #include "blk-mq-tag.h"
#include <trace/hooks/blk_mq.h>
/* /*
* If a previously inactive queue goes active, bump the active user count. * If a previously inactive queue goes active, bump the active user count.
* We need to do this before try to allocate driver tag, then even if fail * We need to do this before try to allocate driver tag, then even if fail
@ -336,8 +338,13 @@ static void bt_tags_for_each(struct blk_mq_tags *tags, struct sbitmap_queue *bt,
static void __blk_mq_all_tag_iter(struct blk_mq_tags *tags, static void __blk_mq_all_tag_iter(struct blk_mq_tags *tags,
busy_tag_iter_fn *fn, void *priv, unsigned int flags) busy_tag_iter_fn *fn, void *priv, unsigned int flags)
{ {
bool skip = false;
WARN_ON_ONCE(flags & BT_TAG_ITER_RESERVED); WARN_ON_ONCE(flags & BT_TAG_ITER_RESERVED);
trace_android_vh_blk_mq_all_tag_iter(&skip, tags, fn, priv);
if (skip)
return;
if (tags->nr_reserved_tags) if (tags->nr_reserved_tags)
bt_tags_for_each(tags, tags->breserved_tags, fn, priv, bt_tags_for_each(tags, tags->breserved_tags, fn, priv,
flags | BT_TAG_ITER_RESERVED); flags | BT_TAG_ITER_RESERVED);
@ -438,6 +445,7 @@ void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn,
{ {
struct blk_mq_hw_ctx *hctx; struct blk_mq_hw_ctx *hctx;
int i; int i;
bool skip = false;
/* /*
* __blk_mq_update_nr_hw_queues() updates nr_hw_queues and queue_hw_ctx * __blk_mq_update_nr_hw_queues() updates nr_hw_queues and queue_hw_ctx
@ -457,6 +465,11 @@ void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn,
if (!blk_mq_hw_queue_mapped(hctx)) if (!blk_mq_hw_queue_mapped(hctx))
continue; continue;
trace_android_vh_blk_mq_queue_tag_busy_iter(&skip, hctx, fn,
priv);
if (skip)
continue;
if (tags->nr_reserved_tags) if (tags->nr_reserved_tags)
bt_for_each(hctx, tags->breserved_tags, fn, priv, true); bt_for_each(hctx, tags->breserved_tags, fn, priv, true);
bt_for_each(hctx, tags->bitmap_tags, fn, priv, false); bt_for_each(hctx, tags->bitmap_tags, fn, priv, false);
@ -556,6 +569,12 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
void blk_mq_free_tags(struct blk_mq_tags *tags, unsigned int flags) void blk_mq_free_tags(struct blk_mq_tags *tags, unsigned int flags)
{ {
bool skip = false;
trace_android_vh_blk_mq_free_tags(&skip, tags);
if (skip)
return;
if (!(flags & BLK_MQ_F_TAG_HCTX_SHARED)) { if (!(flags & BLK_MQ_F_TAG_HCTX_SHARED)) {
sbitmap_queue_free(tags->bitmap_tags); sbitmap_queue_free(tags->bitmap_tags);
sbitmap_queue_free(tags->breserved_tags); sbitmap_queue_free(tags->breserved_tags);

View File

@ -45,6 +45,7 @@
#include <trace/hooks/thermal.h> #include <trace/hooks/thermal.h>
#include <trace/hooks/ufshcd.h> #include <trace/hooks/ufshcd.h>
#include <trace/hooks/block.h> #include <trace/hooks/block.h>
#include <trace/hooks/blk_mq.h>
#include <trace/hooks/cgroup.h> #include <trace/hooks/cgroup.h>
#include <trace/hooks/sys.h> #include <trace/hooks/sys.h>
#include <trace/hooks/traps.h> #include <trace/hooks/traps.h>
@ -532,6 +533,9 @@ 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_allocated_queue_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_blk_flush_plug_list); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_blk_flush_plug_list);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_flush_queue); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_flush_queue);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_mq_all_tag_iter);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_mq_queue_tag_busy_iter);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_mq_free_tags);
/* /*
* For type visibility * For type visibility
*/ */

View File

@ -0,0 +1,33 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM blk_mq
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_BLK_MQ_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_BLK_MQ_H
#include <trace/hooks/vendor_hooks.h>
struct blk_mq_tag_set;
struct blk_mq_hw_ctx;
DECLARE_HOOK(android_vh_blk_mq_all_tag_iter,
TP_PROTO(bool *skip, struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
void *priv),
TP_ARGS(skip, tags, fn, priv));
DECLARE_HOOK(android_vh_blk_mq_queue_tag_busy_iter,
TP_PROTO(bool *skip, struct blk_mq_hw_ctx *hctx, busy_iter_fn * fn,
void *priv),
TP_ARGS(skip, hctx, fn, priv));
DECLARE_HOOK(android_vh_blk_mq_free_tags,
TP_PROTO(bool *skip, struct blk_mq_tags *tags),
TP_ARGS(skip, tags));
#endif /* _TRACE_HOOK_BLK_MQ_H */
/* This part must be outside protection */
#include <trace/define_trace.h>