[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8292299c-4c5a-a8cb-22e2-d5c9051f122a@oracle.com>
Date: Tue, 18 Feb 2020 19:49:01 -0800
From: Mike Kravetz <mike.kravetz@...cle.com>
To: "Longpeng (Mike)" <longpeng2@...wei.com>,
Matthew Wilcox <willy@...radead.org>
Cc: akpm@...ux-foundation.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, arei.gonglei@...wei.com,
weidong.huang@...wei.com, weifuqiang@...wei.com,
kvm@...r.kernel.org
Subject: Re: [PATCH] mm/hugetlb: avoid get wrong ptep caused by race
On 2/18/20 6:09 PM, Longpeng (Mike) wrote:
> 在 2020/2/19 4:52, Matthew Wilcox 写道:
>> On Tue, Feb 18, 2020 at 08:10:25PM +0800, Longpeng(Mike) wrote:
>>> {
>>> - pgd_t *pgd;
>>> - p4d_t *p4d;
>>> - pud_t *pud;
>>> - pmd_t *pmd;
>>> + pgd_t *pgdp;
>>> + p4d_t *p4dp;
>>> + pud_t *pudp, pud;
>>> + pmd_t *pmdp, pmd;
>>
>> Renaming the variables as part of a fix is a really bad idea. It obscures
>> the actual fix and makes everybody's life harder. Plus, it's not even
>> renaming to follow the normal convention -- there are only two places
>> (migrate.c and gup.c) which follow this pattern in mm/ while there are
>> 33 that do not.
>>
> Good suggestion, I've never noticed this, thanks.
> By the way, could you give an example if we use this way to fix the bug?
Matthew and others may have better suggestions for naming. However, I would
keep the existing names and add:
pud_t pud_entry;
pmd_t pmd_entry;
Then the *_entry variables are the target of the READ_ONCE()
pud_entry = READ_ONCE(*pud);
if (sz != PUD_SIZE && pud_none(pud_entry))
...
...
pmd_entry = READ_ONCE(*pmd);
if (sz != PMD_SIZE && pmd_none(pmd_entry))
...
...
BTW, thank you for finding this issue!
--
Mike Kravetz
Powered by blists - more mailing lists