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] [day] [month] [year] [list]
Message-ID: <1ecddd3f-957f-4dad-90e3-cb820bbe36ec@linux.alibaba.com>
Date: Tue, 6 Feb 2024 09:01:29 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Michal Hocko <mhocko@...e.com>
Cc: akpm@...ux-foundation.org, muchun.song@...ux.dev, osalvador@...e.de,
 david@...hat.com, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] mm: hugetlb: improve the handling of hugetlb
 allocation failure for freed or in-use hugetlb



On 2/5/2024 10:47 PM, Michal Hocko wrote:
> On Mon 05-02-24 20:50:51, Baolin Wang wrote:
>> When handling the freed hugetlb or in-use hugetlb, we should ignore the
>> failure of alloc_buddy_hugetlb_folio() to dissolve the old hugetlb successfully,
>> since we did not use the new allocated hugetlb in this 2 cases. Moreover,
>> moving the allocation into the free hugetlb handling branch.
> 
> The changelog is a bit hard for me to understand. What about the
> following instead?
> alloc_and_dissolve_hugetlb_folio preallocates a new huge page before it
> takes hugetlb_lock. In 3 out of 4 cases the page is not really used and
> therefore the newly allocated page is just freed right away. This is
> wasteful and it might cause pre-mature failures in those cases.
> 
> Address that by moving the allocation down to the only case (hugetlb
> page is really in the free pages pool). We need to drop hugetlb_lock
> to do so and therefore need to recheck the page state after regaining
> it.
> 
> The patch is more of a cleanup than an actual fix to an existing
> problem. There are no known reports about pre-mature failures.

Looks better. Thanks.

>> @@ -3075,6 +3063,24 @@ static int alloc_and_dissolve_hugetlb_folio(struct hstate *h,
>>   		cond_resched();
>>   		goto retry;
>>   	} else {
>> +		if (!new_folio) {
>> +			spin_unlock_irq(&hugetlb_lock);
>> +			/*
>> +			 * Before dissolving the free hugetlb, we need to allocate
>> +			 * a new one for the pool to remain stable.  Here, we
>> +			 * allocate the folio and 'prep' it by doing everything
>> +			 * but actually updating counters and adding to the pool.
>> +			 * This simplifies and let us do most of the processing
>> +			 * under the lock.
>> +			 */
> 
> This comment is not really needed anymore IMHO.

Acked.

> 
>> +			new_folio = alloc_buddy_hugetlb_folio(h, gfp_mask, nid,
>> +							      NULL, NULL);
>> +			if (!new_folio)
>> +				return -ENOMEM;
>> +			__prep_new_hugetlb_folio(h, new_folio);
>> +			goto retry;
>> +		}
>> +
>>   		/*
>>   		 * Ok, old_folio is still a genuine free hugepage. Remove it from
>>   		 * the freelist and decrease the counters. These will be
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ