Re: [PATCH v2 4/8] mm/gup: track FOLL_PIN pages

John Hubbard
2020-01-31T03:19:37Z

On 1/30/20 3:31 AM, Kirill A. Shutemov wrote:
...
>>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>>>> index 0a55dec68925..b1079aaa6f24 100644
>>>> --- a/mm/huge_memory.c
>>>> +++ b/mm/huge_memory.c
>>>> @@ -958,6 +958,11 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
>>>> */
>>>> WARN_ONCE(flags & FOLL_COW, "mm: In follow_devmap_pmd with FOLL_COW set");
>>>> + /* FOLL_GET and FOLL_PIN are mutually exclusive. */
>>>> + if (WARN_ON_ONCE((flags & (FOLL_PIN | FOLL_GET)) ==
>>>> + (FOLL_PIN | FOLL_GET)))
>>>
>>> Too many parentheses.
>>
>>
>> OK, I'll remove at least one. :)
>
> I see two.

ah, correction: actually, the original statement has exactly the right number of parentheses.
The relevant C precedence order is:
==
&
|

...which means that both "&" and "|" operations need parentheses protection from the higher
precedence "==" operation.

(There are other places in the kernel that have this exact pattern, too, with the same
pattern of parentheses that I'm using, of course.)

thanks,
--
John Hubbard
NVIDIA