From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19A05C433E0 for ; Fri, 19 Feb 2021 06:08:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8838664ECE for ; Fri, 19 Feb 2021 06:08:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8838664ECE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CAE4C6B0005; Fri, 19 Feb 2021 01:08:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C36F76B006C; Fri, 19 Feb 2021 01:08:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFD5F6B006E; Fri, 19 Feb 2021 01:08:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id 954396B0005 for ; Fri, 19 Feb 2021 01:08:09 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5425318017BF7 for ; Fri, 19 Feb 2021 06:08:09 +0000 (UTC) X-FDA: 77833987098.01.4230627 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf15.hostedemail.com (Postfix) with ESMTP id 3EED4A0000FF for ; Fri, 19 Feb 2021 06:08:08 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 87039AC69; Fri, 19 Feb 2021 06:08:07 +0000 (UTC) MIME-Version: 1.0 Date: Fri, 19 Feb 2021 07:08:06 +0100 From: Oscar Salvador To: Mike Kravetz Cc: Andrew Morton , David Hildenbrand , Michal Hocko , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] mm: Make alloc_contig_range handle free hugetlb pages In-Reply-To: <9a902aae-7478-4287-ad5c-f6b0b7fdf2ad@oracle.com> References: <20210218120028.6499-1-osalvador@suse.de> <20210218120028.6499-2-osalvador@suse.de> <9a902aae-7478-4287-ad5c-f6b0b7fdf2ad@oracle.com> User-Agent: Roundcube Webmail Message-ID: <73df96ab131fb1587c3527a5ca151c08@suse.de> X-Sender: osalvador@suse.de Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: munbc5pubd6snk5fmzeeq3j89nptkq6a X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3EED4A0000FF Received-SPF: none (suse.de>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1613714888-95727 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2021-02-19 03:10, Mike Kravetz wrote: > Those counts will be wrong as there are no huge pages on the node. > > I'll think about this more tomorrow. > Pretty sure this is an issue, but I could be wrong. Just wanted to > give > a heads up. Yes, this is a problem, although the fixup would be to check whether we have any hugepages. Nevertheless, I think we should not be touching surplus at all but rather make the page temporary. I am exploring making migrate_pages() handle free hugepages as Michal suggested, so the approach is cleaner and we do not need extra functions. I yet have to see if that is feasible, as some issues come to my mind like the page needs to be in a list to go to migrate_pages, but if it is in that list, it is not in hugepages_freelist, and that could disrupt userspace as it could not dequeue hugepages if it demands it. I have to check. Shoult not be possible, we can always make the page temporary here. > -- > Mike Kravetz > >> + } >> + } >> + >> + return ret; >> +} >> + >> +bool isolate_or_dissolve_huge_page(struct page *page) >> +{ >> + struct hstate *h = NULL; >> + struct page *head; >> + bool ret = false; >> + >> + spin_lock(&hugetlb_lock); >> + if (PageHuge(page)) { >> + head = compound_head(page); >> + h = page_hstate(head); >> + } >> + spin_unlock(&hugetlb_lock); >> + >> + /* >> + * The page might have been dissolved from under our feet. >> + * If that is the case, return success as if we dissolved it >> ourselves. >> + */ >> + if (!h) >> + return true; >> + >> + /* >> + * Fence off gigantic pages as there is a cyclic dependency >> + * between alloc_contig_range and them. >> + */ >> + if (hstate_is_gigantic(h)) >> + return ret; >> + >> + if(!page_count(head) && alloc_and_dissolve_huge_page(h, head)) >> + ret = true; >> + >> + return ret; >> +} >> + >> struct page *alloc_huge_page(struct vm_area_struct *vma, >> unsigned long addr, int avoid_reserve) >> { >> -- Oscar Salvador SUSE L3