Re: [PATCH 1/3] mm/gup: track FOLL_PIN pages

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

 



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
 



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux