Re: [PATCH v2] drm/i915: prevent out of range pt in the PDE macros (take 3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 06, 2015 at 12:21:05PM +0100, Dave Gordon wrote:
> ... although I still think my version is (slightly) easier to read.
> Or it could be improved even more by moving the increment of 'iter'
> to the end, making it one line shorter and perhaps helping the
> compiler a little :)
> 
> #define gen8_for_each_pml4e(pdp, pml4, start, length, temp, iter)      \
>         for (iter = gen8_pml4e_index(start);                           \
>              iter < GEN8_PML4ES_PER_PML4 &&                            \
>                 (pdp = (pml4)->pdps[iter], length > 0);                \
>              temp = ALIGN(start+1, 1ULL << GEN8_PML4E_SHIFT) - start,  \
>              temp = min(temp, length),                                 \
>              start += temp, length -= temp, ++iter)

Shorter, yes, but we may as well take advantage of not using [iter] if
length == 0, so meh.
 
> Or, noting that 'temp' is never used in the generated loop bodies,
> we could eliminate the parameter and make it local to the loop
> header :)
> 
> #define gen8_for_each_pml4e(pdp, pml4, start, length, iter)            \
>         for (iter = gen8_pml4e_index(start);                           \
>              iter < GEN8_PML4ES_PER_PML4 &&                            \
>                 (pdp = (pml4)->pdps[iter], length > 0);                \
>              ({ u64 temp = ALIGN(start+1, 1ULL << GEN8_PML4E_SHIFT);   \
>                     temp = min(temp - start, length);                  \
>                     start += temp, length -= temp; }),                 \
>                 ++iter)

Removing extraneous parameters from macros is differently a usability win.
Care to spin a real patch so we can see how it looks in practice?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux