Re: [PATCH v3 01/18] block: introduce duration-limits priority class

Bart Van Assche
2023-01-30T20:40:55Z

On 1/28/23 19:52, Damien Le Moal wrote:
> +/*
> + * The 13-bits of ioprio data for each class provide up to 8 QOS hints and
> + * up to 8 priority levels.
> + */
> +#define IOPRIO_PRIO_LEVEL_MASK (IOPRIO_NR_LEVELS - 1)
> +#define IOPRIO_QOS_HINT_SHIFT 10
> +#define IOPRIO_NR_QOS_HINTS 8
> +#define IOPRIO_QOS_HINT_MASK (IOPRIO_NR_QOS_HINTS - 1)
> +#define IOPRIO_PRIO_LEVEL(ioprio) ((ioprio) & IOPRIO_PRIO_LEVEL_MASK)
> +#define IOPRIO_QOS_HINT(ioprio) \
> + (((ioprio) >> IOPRIO_QOS_HINT_SHIFT) & IOPRIO_QOS_HINT_MASK)

Does the QoS level really have to be encoded in bio.bi_ioprio? How about
introducing a new field in the existing hole in struct bio? From the
pahole output:

struct bio {
struct bio * bi_next; /* 0 4 */
struct block_device * bi_bdev; /* 4 4 */
blk_opf_t bi_opf; /* 8 4 */
short unsigned int bi_flags; /* 12 2 */
short unsigned int bi_ioprio; /* 14 2 */
blk_status_t bi_status; /* 16 1 */

/* XXX 3 bytes hole, try to pack */

atomic_t __bi_remaining; /* 20 4 */
struct bvec_iter bi_iter; /* 24 20 */
blk_qc_t bi_cookie; /* 44 4 */
bio_end_io_t * bi_end_io; /* 48 4 */
void * bi_private; /* 52 4 */
struct bio_crypt_ctx * bi_crypt_context; /* 56 4 */
[ ... ]

Thanks,

Bart.