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=-15.2 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 EF49DC433E0 for ; Fri, 12 Feb 2021 14:15:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 94EC16023B for ; Fri, 12 Feb 2021 14:15:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94EC16023B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EE66F6B00E7; Fri, 12 Feb 2021 09:15:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E70698D0060; Fri, 12 Feb 2021 09:15:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE9268D0057; Fri, 12 Feb 2021 09:15:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id B613F6B00E7 for ; Fri, 12 Feb 2021 09:15:25 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 76282180CCDE1 for ; Fri, 12 Feb 2021 14:15:25 +0000 (UTC) X-FDA: 77809813410.06.7054A6D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 6DA38138 for ; Fri, 12 Feb 2021 14:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613139324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pFui2wB5cJmJppKeE9fg7DgPntP+r/xmUSyZ0JYk3sc=; b=HA2tFRuwvlzt0hwekuqfugAAM6LlK46uNuniBAWDxp3A7IGs0G401hXOwBJg4Dc4D9Wa3+ FC+WLJ0zYHm4ZaLqY6Bf3iGHWCFyoMNaXOHF9j0iqhhP7azl3xv2lIJ6d1JidfSq1HPmNS CmTtlieXCUrqvkEAZ0ogb8ucf8kktNE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-xbkPRNinPeikoybW4Bn4nQ-1; Fri, 12 Feb 2021 09:15:20 -0500 X-MC-Unique: xbkPRNinPeikoybW4Bn4nQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9737107ACF2; Fri, 12 Feb 2021 14:15:15 +0000 (UTC) Received: from [10.36.114.178] (ovpn-114-178.ams2.redhat.com [10.36.114.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29EB95D9FC; Fri, 12 Feb 2021 14:15:09 +0000 (UTC) To: Mike Kravetz , Muchun Song , corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com, willy@infradead.org, osalvador@suse.de, mhocko@suse.com, song.bao.hua@hisilicon.com, naoya.horiguchi@nec.com, joao.m.martins@oracle.com Cc: duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org References: <20210208085013.89436-1-songmuchun@bytedance.com> <20210208085013.89436-5-songmuchun@bytedance.com> <72e772bc-7103-62da-d834-059eb5a3ce5b@oracle.com> From: David Hildenbrand Organization: Red Hat GmbH Subject: Re: [PATCH v15 4/8] mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page Message-ID: <2afd12e0-60cd-0f9e-99a8-8ded09644504@redhat.com> Date: Fri, 12 Feb 2021 15:15:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <72e772bc-7103-62da-d834-059eb5a3ce5b@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Stat-Signature: crs7t5mj3y1dbnst7apbar99hn9utwyb X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6DA38138 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613139323-986330 Content-Transfer-Encoding: quoted-printable 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 11.02.21 19:05, Mike Kravetz wrote: > On 2/8/21 12:50 AM, Muchun Song wrote: >> When we free a HugeTLB page to the buddy allocator, we should allocate= the >> vmemmap pages associated with it. But we may cannot allocate vmemmap p= ages >> when the system is under memory pressure, in this case, we just refuse= to >> free the HugeTLB page instead of looping forever trying to allocate th= e >> pages. >> >> Signed-off-by: Muchun Song >> --- >> include/linux/mm.h | 2 ++ >> mm/hugetlb.c | 19 ++++++++++++- >> mm/hugetlb_vmemmap.c | 30 +++++++++++++++++++++ >> mm/hugetlb_vmemmap.h | 6 +++++ >> mm/sparse-vmemmap.c | 75 ++++++++++++++++++++++++++++++++++++++++++= +++++++++- >> 5 files changed, 130 insertions(+), 2 deletions(-) >=20 > Muchun has done a great job simplifying this patch series and addressin= g > issues as they are brought up. This patch addresses the issue which se= ems > to be the biggest stumbling block to this series. The need to allocate > vmemmap pages to dissolve a hugetlb page to the buddy allocator. The w= ay > it is addressed in this patch is to simply fail to dissolve the hugetlb > page if the vmmemmap pages can not be allocated. IMO, this is an 'acce= ptable' > strategy. If we find ourselves in this situation then we are likely to= be > hitting other corner cases in the system. I wish there was a perfect w= ay > to address this issue, but we have been unable to come up with one. >=20 > There was a decent discussion about this is a previous version of the > series starting here: > https://lore.kernel.org/linux-mm/20210126092942.GA10602@linux/ > In this thread various other options were suggested and discussed. >=20 > I would like to come to some agreement on an acceptable way to handle t= his > specific issue. IMO, it makes little sense to continue refining other > parts of this series if we can not figure out how to move forward on th= is > issue. >=20 > It would be great if David H, David R and Michal could share their opin= ions > on this. No need to review details the code yet (unless you want), but > let's start a discussion on how to move past this issue if we can. So a summary from my side: We might fail freeing a huge page at any point in time iff we are low on=20 kernel (!CMA, !ZONE_MOVABLE) memory. While we could play games with=20 allocating the vmemmap from a huge page itself in some cases (e.g.,=20 !CMA, !ZONE_MOVABLE), simply retrying is way easier and we don't turn=20 the huge page forever unusable. Corner cases might be having many huge pages in ZONE_MOVABLE, freeing=20 them all at once and eating up a lot of kernel memory. But then, the=20 same setup would already be problematic nowadays where we simply always=20 consume that kernel memory for the vmemmap. I think this problem only really becomes visible in corner cases. And=20 someone actively has to enable new behavior. 1. Failing to free a huge page triggered by the user (decrease nr_pages): Bad luck. Try again later. 2. Failing to free a surplus huge page when freed by the application: Bad luck. But who will try again later? 3. Failing to dissolve a free huge page on ZONE_MOVABLE via offline_pages= () This is a bit unfortunate if we have plenty of ZONE_MOVABLE memory but=20 are low on kernel memory. For example, migration of huge pages would=20 still work, however, dissolving the free page does not work. I'd say=20 this is a corner cases. When the system is that much under memory=20 pressure, offlining/unplug can be expected to fail. 4. Failing to dissolve a huge page on CMA/ZONE_MOVABLE via=20 alloc_contig_range() - once we have that handling in place. Mainly=20 affects CMA and virtio-mem. Similar to 3. However, we didn't even take care of huge pages *at all*=20 for now (neither migrate nor dissolve). So actually don't make the=20 current state any worse. virito-mem will handle migration errors=20 gracefully. CMA might be able to fallback on other free areas within the=20 CMA region. I'd say, document the changed behavior properly so people are aware that=20 there might be issues in corner cases with huge pages on CMA / ZONE_MOVAB= LE. --=20 Thanks, David / dhildenb