Subject: [PATCH 4/5] iommu/dma: Finish optimising higher-order allocations

From: [email-masked] (Robin Murphy)
Date: Fri, 8 Apr 2016 17:33:32 +0100

On 08/04/16 06:32, Yong Wu wrote:
> On Thu, 2016-04-07 at 18:42 +0100, Robin Murphy wrote:
>>   		/*
>> @@ -215,8 +221,9 @@ static struct page **__iommu_dma_alloc_pages(unsigned int count, gfp_t gfp)
>>   		 * than a necessity, hence using __GFP_NORETRY until
>>   		 * falling back to single-page allocations.
>>   		 */
>> -		for (order = min_t(unsigned int, order, __fls(count));
>> -		     order > 0; order--) {
>> +		for (pgsize_orders &= (2U << __fls(count)) - 1;
>> +		     (order = __fls(pgsize_orders)) > min_order;
>> +		     pgsize_orders &= (1U << order) - 1) {
>>   			page = alloc_pages(gfp | __GFP_NORETRY, order);
>>   			if (!page)
>>   				continue;
>> @@ -230,7 +237,7 @@ static struct page **__iommu_dma_alloc_pages(unsigned int count, gfp_t gfp)
>>   			}
>>   		}
>>   		if (!page)
>> -			page = alloc_page(gfp);
>> +			page = alloc_pages(gfp, order);
>
> A small question: Do we need split it too if order != 0 here?

Ah, good point, somehow I missed that. It didn't stop my framebuffer 
console working kernel-side, but indeed I can't mmap it due to the 
un-split pages. I'll take that as an excuse to have a go at refactoring 
the whole thing to maybe not reach 5 levels of indentation.

Thanks,
Robin.

>
>
>>   		if (!page) {
>>   			__iommu_dma_free_pages(pages, i);
>>   			return NULL;
> [...]
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>