From: Sebastian Ott Date: Tue, 2 Aug 2016 21:04:13 +0000 (-0700) Subject: lib/iommu-helper: skip to next segment X-Git-Tag: v4.8~308^2~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f003a1f182bb821f13775338a4bf8711830f927a;p=platform%2Fkernel%2Flinux-amlogic.git lib/iommu-helper: skip to next segment When a large enough area in the iommu bitmap is found but would span a boundary we continue the search starting from the next bit position. For large allocations this can lead to several useless invocations of bitmap_find_next_zero_area() and iommu_is_span_boundary(). Continue the search from the start of the next segment (which is the next bit position such that we'll not cross the same segment boundary again). Link: http://lkml.kernel.org/r/alpine.LFD.2.20.1606081910070.3211@schleppi Signed-off-by: Sebastian Ott Reviewed-by: Gerald Schaefer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c index c27e269..a816f3a 100644 --- a/lib/iommu-helper.c +++ b/lib/iommu-helper.c @@ -29,8 +29,7 @@ again: index = bitmap_find_next_zero_area(map, size, start, nr, align_mask); if (index < size) { if (iommu_is_span_boundary(index, nr, shift, boundary_size)) { - /* we could do more effectively */ - start = index + 1; + start = ALIGN(shift + index, boundary_size) - shift; goto again; } bitmap_set(map, index, nr);