[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <132c05dc-ee18-029e-4f04-4a7cf532dd9d@nvidia.com>
Date: Mon, 27 Jan 2020 10:17:51 -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>,
Christoph Hellwig <hch@...radead.org>,
Dan Williams <dan.j.williams@...el.com>,
Dave Chinner <david@...morbit.com>,
Ira Weiny <ira.weiny@...el.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Jonathan Corbet <corbet@....net>,
Jérôme Glisse <jglisse@...hat.com>,
"Kirill A . Shutemov" <kirill@...temov.name>,
Michal Hocko <mhocko@...e.com>,
Mike Kravetz <mike.kravetz@...cle.com>,
Shuah Khan <shuah@...nel.org>,
Vlastimil Babka <vbabka@...e.cz>, <linux-doc@...r.kernel.org>,
<linux-fsdevel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
<linux-rdma@...r.kernel.org>, <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH 1/3] mm/gup: track FOLL_PIN pages
On 1/27/20 3:06 AM, Jan Kara wrote:
> On Fri 24-01-20 18:11:13, John Hubbard wrote:
>> +static __maybe_unused struct page *try_grab_compound_head(struct page *page,
>> + int refs,
>> + unsigned int flags)
>> +{
>> + if (flags & FOLL_GET)
>> + return try_get_compound_head(page, refs);
>> + else if (flags & FOLL_PIN) {
>> + int orig_refs = refs;
>> +
>> + /*
>> + * When pinning a compound page of order > 1 (which is what
>> + * hpage_pincount_available() checks for), use an exact count to
>> + * track it, via hpage_pincount_inc/_dec().
>> + *
>> + * However, be sure to *also* increment the normal page refcount
>> + * field at least once, so that the page really is pinned.
>> + */
>> + if (!hpage_pincount_available(page))
>> + refs *= GUP_PIN_COUNTING_BIAS;
>> +
>> + page = try_get_compound_head(page, refs);
>> + if (!page)
>> + return NULL;
>> +
>> + if (hpage_pincount_available(page))
>> + hpage_pincount_inc(page);
>
> Umm, adding just 1 to pincount looks dangerous to me as
> try_grab_compound_head() would not compose - you could not release
> references acquired by try_grab_compound_head() with refs==2 by two calls
> to put_compound_head() with refs==1. So I'd rather have here:
> hpage_pincount_add(page, refs) and similarly in put_compound_head().
> Otherwise the patch looks good to me from a quick look.
>
> Honza
Yes, you are right. The hpage_pincount really should track refs. I'll fix it
up.
thanks,
--
John Hubbard
NVIDIA
Powered by blists - more mailing lists