iommu/iova: Optimise rbtree searching
authorZhen Lei <thunder.leizhen@huawei.com>
Thu, 21 Sep 2017 15:52:42 +0000 (16:52 +0100)
committerJoerg Roedel <jroedel@suse.de>
Wed, 27 Sep 2017 15:09:56 +0000 (17:09 +0200)
commit2070f940a6d5148cf2df0d0087ff0a64d9f15237
tree33eaa069e7e259009034651a3241ee8318ee55b9
parente19b205be43d11bff638cad4487008c48d21c103
iommu/iova: Optimise rbtree searching

Checking the IOVA bounds separately before deciding which direction to
continue the search (if necessary) results in redundantly comparing both
pfns twice each. GCC can already determine that the final comparison op
is redundant and optimise it down to 3 in total, but we can go one
further with a little tweak of the ordering (which makes the intent of
the code that much cleaner as a bonus).

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Zhen Lei <thunder.leizhen@huawei.com>
Tested-by: Nate Watterson <nwatters@codeaurora.org>
[rm: rewrote commit message to clarify]
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iova.c