blk-throttle: simplify throtl_grp flag handling
blk-throttle is still using function-defining macros to define flag handling functions, which went out style at least a decade ago. Just define the flag as bitmask and use direct bit operations. This patch doesn't make any functional changes. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
c9e0332e87
commit
5b2c16aae0
1 changed files with 9 additions and 25 deletions
|
@ -36,6 +36,10 @@ struct throtl_service_queue {
|
||||||
#define THROTL_SERVICE_QUEUE_INITIALIZER \
|
#define THROTL_SERVICE_QUEUE_INITIALIZER \
|
||||||
(struct throtl_service_queue){ .pending_tree = RB_ROOT }
|
(struct throtl_service_queue){ .pending_tree = RB_ROOT }
|
||||||
|
|
||||||
|
enum tg_state_flags {
|
||||||
|
THROTL_TG_PENDING = 1 << 0, /* on parent's pending tree */
|
||||||
|
};
|
||||||
|
|
||||||
#define rb_entry_tg(node) rb_entry((node), struct throtl_grp, rb_node)
|
#define rb_entry_tg(node) rb_entry((node), struct throtl_grp, rb_node)
|
||||||
|
|
||||||
/* Per-cpu group stats */
|
/* Per-cpu group stats */
|
||||||
|
@ -136,26 +140,6 @@ static inline struct throtl_grp *td_root_tg(struct throtl_data *td)
|
||||||
return blkg_to_tg(td->queue->root_blkg);
|
return blkg_to_tg(td->queue->root_blkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum tg_state_flags {
|
|
||||||
THROTL_TG_FLAG_on_rr = 0, /* on round-robin busy list */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define THROTL_TG_FNS(name) \
|
|
||||||
static inline void throtl_mark_tg_##name(struct throtl_grp *tg) \
|
|
||||||
{ \
|
|
||||||
(tg)->flags |= (1 << THROTL_TG_FLAG_##name); \
|
|
||||||
} \
|
|
||||||
static inline void throtl_clear_tg_##name(struct throtl_grp *tg) \
|
|
||||||
{ \
|
|
||||||
(tg)->flags &= ~(1 << THROTL_TG_FLAG_##name); \
|
|
||||||
} \
|
|
||||||
static inline int throtl_tg_##name(const struct throtl_grp *tg) \
|
|
||||||
{ \
|
|
||||||
return ((tg)->flags & (1 << THROTL_TG_FLAG_##name)) != 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
THROTL_TG_FNS(on_rr);
|
|
||||||
|
|
||||||
#define throtl_log_tg(td, tg, fmt, args...) do { \
|
#define throtl_log_tg(td, tg, fmt, args...) do { \
|
||||||
char __pbuf[128]; \
|
char __pbuf[128]; \
|
||||||
\
|
\
|
||||||
|
@ -369,25 +353,25 @@ static void __throtl_enqueue_tg(struct throtl_data *td, struct throtl_grp *tg)
|
||||||
struct throtl_service_queue *sq = &td->service_queue;
|
struct throtl_service_queue *sq = &td->service_queue;
|
||||||
|
|
||||||
tg_service_queue_add(sq, tg);
|
tg_service_queue_add(sq, tg);
|
||||||
throtl_mark_tg_on_rr(tg);
|
tg->flags |= THROTL_TG_PENDING;
|
||||||
sq->nr_pending++;
|
sq->nr_pending++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void throtl_enqueue_tg(struct throtl_data *td, struct throtl_grp *tg)
|
static void throtl_enqueue_tg(struct throtl_data *td, struct throtl_grp *tg)
|
||||||
{
|
{
|
||||||
if (!throtl_tg_on_rr(tg))
|
if (!(tg->flags & THROTL_TG_PENDING))
|
||||||
__throtl_enqueue_tg(td, tg);
|
__throtl_enqueue_tg(td, tg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __throtl_dequeue_tg(struct throtl_data *td, struct throtl_grp *tg)
|
static void __throtl_dequeue_tg(struct throtl_data *td, struct throtl_grp *tg)
|
||||||
{
|
{
|
||||||
throtl_rb_erase(&tg->rb_node, &td->service_queue);
|
throtl_rb_erase(&tg->rb_node, &td->service_queue);
|
||||||
throtl_clear_tg_on_rr(tg);
|
tg->flags &= ~THROTL_TG_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void throtl_dequeue_tg(struct throtl_data *td, struct throtl_grp *tg)
|
static void throtl_dequeue_tg(struct throtl_data *td, struct throtl_grp *tg)
|
||||||
{
|
{
|
||||||
if (throtl_tg_on_rr(tg))
|
if (tg->flags & THROTL_TG_PENDING)
|
||||||
__throtl_dequeue_tg(td, tg);
|
__throtl_dequeue_tg(td, tg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,7 +948,7 @@ static int tg_set_conf(struct cgroup *cgrp, struct cftype *cft, const char *buf,
|
||||||
throtl_start_new_slice(td, tg, 0);
|
throtl_start_new_slice(td, tg, 0);
|
||||||
throtl_start_new_slice(td, tg, 1);
|
throtl_start_new_slice(td, tg, 1);
|
||||||
|
|
||||||
if (throtl_tg_on_rr(tg)) {
|
if (tg->flags & THROTL_TG_PENDING) {
|
||||||
tg_update_disptime(td, tg);
|
tg_update_disptime(td, tg);
|
||||||
throtl_schedule_next_dispatch(td);
|
throtl_schedule_next_dispatch(td);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue