block/bfq-iosched.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
The size of struct bfq_iocq_bfqq_data can be reduced by moving a few fields
around.
On a x86_64, with allmodconfig, this shrinks the size from 144 to 128
bytes.
The main benefit is to reduce the size of struct bfq_io_cq from 1360 to
1232.
This structure is stored in a dedicated slab cache. So reducing its size
improves cache usage.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
On my system, struct bfq_io_cq are stored in 8 pages slab. Each of these
slabs hold 24 entries.
$ sudo cat /proc/slabinfo | grep bfq_io
bfq_io_cq 378 384 1360 24 8 : tunables 0 0 0 : slabdata 16 16 0
With the new layout, we should store 26 entries.
(8 * 4096 / 1232 = 26.60)
---
block/bfq-iosched.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 687a3a7ba784..0b4704932d72 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -427,9 +427,6 @@ struct bfq_iocq_bfqq_data {
*/
bool saved_IO_bound;
- u64 saved_io_start_time;
- u64 saved_tot_idle_time;
-
/*
* Same purpose as the previous fields for the values of the
* field keeping the queue's belonging to a large burst
@@ -450,6 +447,9 @@ struct bfq_iocq_bfqq_data {
*/
unsigned int saved_weight;
+ u64 saved_io_start_time;
+ u64 saved_tot_idle_time;
+
/*
* Similar to previous fields: save wr information.
*/
@@ -457,13 +457,13 @@ struct bfq_iocq_bfqq_data {
unsigned long saved_last_wr_start_finish;
unsigned long saved_service_from_wr;
unsigned long saved_wr_start_at_switch_to_srt;
- unsigned int saved_wr_cur_max_time;
struct bfq_ttime saved_ttime;
+ unsigned int saved_wr_cur_max_time;
/* Save also injection state */
- u64 saved_last_serv_time_ns;
unsigned int saved_inject_limit;
unsigned long saved_decrease_time_jif;
+ u64 saved_last_serv_time_ns;
/* candidate queue for a stable merge (due to close creation time) */
struct bfq_queue *stable_merge_bfqq;
--
2.50.1
在 2025/08/02 15:25, Christophe JAILLET 写道:
> The size of struct bfq_iocq_bfqq_data can be reduced by moving a few fields
> around.
>
> On a x86_64, with allmodconfig, this shrinks the size from 144 to 128
> bytes.
> The main benefit is to reduce the size of struct bfq_io_cq from 1360 to
> 1232.
>
> This structure is stored in a dedicated slab cache. So reducing its size
> improves cache usage.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.
>
> On my system, struct bfq_io_cq are stored in 8 pages slab. Each of these
> slabs hold 24 entries.
>
> $ sudo cat /proc/slabinfo | grep bfq_io
> bfq_io_cq 378 384 1360 24 8 : tunables 0 0 0 : slabdata 16 16 0
>
> With the new layout, we should store 26 entries.
> (8 * 4096 / 1232 = 26.60)
> ---
> block/bfq-iosched.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
> index 687a3a7ba784..0b4704932d72 100644
> --- a/block/bfq-iosched.h
> +++ b/block/bfq-iosched.h
> @@ -427,9 +427,6 @@ struct bfq_iocq_bfqq_data {
> */
> bool saved_IO_bound;
>
> - u64 saved_io_start_time;
> - u64 saved_tot_idle_time;
> -
> /*
> * Same purpose as the previous fields for the values of the
> * field keeping the queue's belonging to a large burst
> @@ -450,6 +447,9 @@ struct bfq_iocq_bfqq_data {
> */
> unsigned int saved_weight;
>
> + u64 saved_io_start_time;
> + u64 saved_tot_idle_time;
> +
> /*
> * Similar to previous fields: save wr information.
> */
> @@ -457,13 +457,13 @@ struct bfq_iocq_bfqq_data {
> unsigned long saved_last_wr_start_finish;
> unsigned long saved_service_from_wr;
> unsigned long saved_wr_start_at_switch_to_srt;
> - unsigned int saved_wr_cur_max_time;
> struct bfq_ttime saved_ttime;
> + unsigned int saved_wr_cur_max_time;
>
> /* Save also injection state */
> - u64 saved_last_serv_time_ns;
> unsigned int saved_inject_limit;
> unsigned long saved_decrease_time_jif;
> + u64 saved_last_serv_time_ns;
>
> /* candidate queue for a stable merge (due to close creation time) */
> struct bfq_queue *stable_merge_bfqq;
>
On Sat, 02 Aug 2025 09:25:59 +0200, Christophe JAILLET wrote:
> The size of struct bfq_iocq_bfqq_data can be reduced by moving a few fields
> around.
>
> On a x86_64, with allmodconfig, this shrinks the size from 144 to 128
> bytes.
> The main benefit is to reduce the size of struct bfq_io_cq from 1360 to
> 1232.
>
> [...]
Applied, thanks!
[1/1] block, bfq: Reorder struct bfq_iocq_bfqq_data
commit: 407728da41cd6450cec6a4277027015a75744d56
Best regards,
--
Jens Axboe
© 2016 - 2026 Red Hat, Inc.