lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 Dec 2019 21:53:45 -0800
From:   John Hubbard <jhubbard@...dia.com>
To:     Jan Kara <jack@...e.cz>
CC:     Andrew Morton <akpm@...ux-foundation.org>,
        Al Viro <viro@...iv.linux.org.uk>,
        Alex Williamson <alex.williamson@...hat.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Björn Töpel <bjorn.topel@...el.com>,
        Christoph Hellwig <hch@...radead.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Daniel Vetter <daniel@...ll.ch>,
        Dave Chinner <david@...morbit.com>,
        David Airlie <airlied@...ux.ie>,
        "David S . Miller" <davem@...emloft.net>,
        Ira Weiny <ira.weiny@...el.com>,
        Jason Gunthorpe <jgg@...pe.ca>, Jens Axboe <axboe@...nel.dk>,
        Jonathan Corbet <corbet@....net>,
        Jérôme Glisse <jglisse@...hat.com>,
        Magnus Karlsson <magnus.karlsson@...el.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Michal Hocko <mhocko@...e.com>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Paul Mackerras <paulus@...ba.org>,
        Shuah Khan <shuah@...nel.org>,
        Vlastimil Babka <vbabka@...e.cz>, <bpf@...r.kernel.org>,
        <dri-devel@...ts.freedesktop.org>, <kvm@...r.kernel.org>,
        <linux-block@...r.kernel.org>, <linux-doc@...r.kernel.org>,
        <linux-fsdevel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
        <linux-media@...r.kernel.org>, <linux-rdma@...r.kernel.org>,
        <linuxppc-dev@...ts.ozlabs.org>, <netdev@...r.kernel.org>,
        <linux-mm@...ck.org>, LKML <linux-kernel@...r.kernel.org>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH v9 23/25] mm/gup: track FOLL_PIN pages

On 12/11/19 3:28 AM, Jan Kara wrote:
...
> 
> The patch looks mostly good to me now. Just a few smaller comments below.
> 
>> Suggested-by: Jan Kara <jack@...e.cz>
>> Suggested-by: Jérôme Glisse <jglisse@...hat.com>
>> Reviewed-by: Jan Kara <jack@...e.cz>
>> Reviewed-by: Jérôme Glisse <jglisse@...hat.com>
>> Reviewed-by: Ira Weiny <ira.weiny@...el.com>
> 
> I think you inherited here the Reviewed-by tags from the "add flags" patch
> you've merged into this one but that's not really fair since this patch
> does much more... In particular I didn't give my Reviewed-by tag for this
> patch yet.

OK, I've removed those reviewed-by's. (I felt bad about dropping them, after
people had devoted time to reviewing, but I do see that it's wrong to imply
that they've reviewed this much much larger thing.)

...
> 
> I somewhat wonder about the asymmetry of try_grab_compound_head() vs
> try_grab_page() in the treatment of 'flags'. How costly would it be to make
> them symmetric (i.e., either set FOLL_GET for try_grab_compound_head()
> callers or make sure one of FOLL_GET, FOLL_PIN is set for try_grab_page())?
> 
> Because this difference looks like a subtle catch in the long run...

Done. It is only a modest code-level change, at least the way I've done it, which is
setting FOLL_GET for try_grab_compound_head(). In order to do that, I set
it at the top of the internal gup fast calling stacks, which is actually a good
design anyway: gup fast is logically doing FOLL_GET in all cases. So setting
the flag internally is accurate and consistent with the overall design.


> ...
> 
>> @@ -1522,8 +1536,8 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
>>   skip_mlock:
>>   	page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT;
>>   	VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page);
>> -	if (flags & FOLL_GET)
>> -		get_page(page);
>> +	if (!try_grab_page(page, flags))
>> +		page = ERR_PTR(-EFAULT);
> 
> I think you need to also move the try_grab_page() earlier in the function.
> At this point the page may be marked as mlocked and you'd need to undo that
> in case try_grab_page() fails.


OK, I've moved it up, adding a "subpage" variable in order to make that work.

> 
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index ac65bb5e38ac..0aab6fe0072f 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -4356,7 +4356,13 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
>>   same_page:
>>   		if (pages) {
>>   			pages[i] = mem_map_offset(page, pfn_offset);
>> -			get_page(pages[i]);
>> +			if (!try_grab_page(pages[i], flags)) {
>> +				spin_unlock(ptl);
>> +				remainder = 0;
>> +				err = -ENOMEM;
>> +				WARN_ON_ONCE(1);
>> +				break;
>> +			}
>>   		}
> 
> This function does a refcount overflow check early so that it doesn't have
> to do try_get_page() here. So that check can be now removed when you do
> try_grab_page() here anyway since that early check seems to be just a tiny
> optimization AFAICT.
> 
> 								Honza
> 

Yes. I've removed it, good spot.


thanks,
-- 
John Hubbard
NVIDIA

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ