Skip to content

Commit

Permalink
os-linux: Cleanup IO priority class and value macros
Browse files Browse the repository at this point in the history
In os/os-linux.h, define the ioprio() macro using the already defined
IOPRIO_MAX_PRIO macro instead of hard coding the maximum priority value
again. Also move the definitions of the ioprio_class() and ioprio()
macros before the ioprio_value() function and use ioprio_class() inside
ioprio_value_is_class_rt() instead of re-coding the iopriority class
extraction again in that function.

Signed-off-by: Damien Le Moal <[email protected]>
Reviewed-by: Niklas Cassel <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
damien-lemoal authored and axboe committed Jul 21, 2023
1 parent fc37e3d commit d4d503a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions os/os-linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ enum {
#define IOPRIO_MIN_PRIO_CLASS 0
#define IOPRIO_MAX_PRIO_CLASS 3

#define ioprio_class(ioprio) ((ioprio) >> IOPRIO_CLASS_SHIFT)
#define ioprio(ioprio) ((ioprio) & IOPRIO_MAX_PRIO)

static inline int ioprio_value(int ioprio_class, int ioprio)
{
/*
Expand All @@ -144,7 +147,7 @@ static inline int ioprio_value(int ioprio_class, int ioprio)

static inline bool ioprio_value_is_class_rt(unsigned int priority)
{
return (priority >> IOPRIO_CLASS_SHIFT) == IOPRIO_CLASS_RT;
return ioprio_class(priority) == IOPRIO_CLASS_RT;
}

static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio)
Expand All @@ -153,9 +156,6 @@ static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio)
ioprio_value(ioprio_class, ioprio));
}

#define ioprio_class(ioprio) ((ioprio) >> IOPRIO_CLASS_SHIFT)
#define ioprio(ioprio) ((ioprio) & 7)

#ifndef CONFIG_HAVE_GETTID
static inline int gettid(void)
{
Expand Down

0 comments on commit d4d503a

Please sign in to comment.