mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 04:40:51 +07:00
block: Optimize ioprio_best()
Since ioprio_best() translates IOPRIO_CLASS_NONE into IOPRIO_CLASS_BE and since lower numerical priority values represent a higher priority a simple numerical comparison is sufficient. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com> Tested-by: Adam Manzanares <adam.manzanares@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
parent
0be0dee64e
commit
9a87182c4b
@ -163,22 +163,12 @@ static int get_task_ioprio(struct task_struct *p)
|
|||||||
|
|
||||||
int ioprio_best(unsigned short aprio, unsigned short bprio)
|
int ioprio_best(unsigned short aprio, unsigned short bprio)
|
||||||
{
|
{
|
||||||
unsigned short aclass;
|
|
||||||
unsigned short bclass;
|
|
||||||
|
|
||||||
if (!ioprio_valid(aprio))
|
if (!ioprio_valid(aprio))
|
||||||
aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
|
aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
|
||||||
if (!ioprio_valid(bprio))
|
if (!ioprio_valid(bprio))
|
||||||
bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
|
bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
|
||||||
|
|
||||||
aclass = IOPRIO_PRIO_CLASS(aprio);
|
return min(aprio, bprio);
|
||||||
bclass = IOPRIO_PRIO_CLASS(bprio);
|
|
||||||
if (aclass == bclass)
|
|
||||||
return min(aprio, bprio);
|
|
||||||
if (aclass > bclass)
|
|
||||||
return bprio;
|
|
||||||
else
|
|
||||||
return aprio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
|
SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
|
||||||
|
Loading…
Reference in New Issue
Block a user