Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp131471pxk; Mon, 5 Oct 2020 20:39:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPONXAPIt4ScV051eJjnA6Ir0Hamny7tBzuVJ1KW0ZrUc435Pj2WVq86ufQ/bM72mTBa5K X-Received: by 2002:aa7:c98f:: with SMTP id c15mr3216796edt.200.1601955554383; Mon, 05 Oct 2020 20:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601955554; cv=none; d=google.com; s=arc-20160816; b=zzIqofrDz3d7g0GBU7tLsTUb8Tpjxoq8bHqXfqUoe4NLkmgr7LCrt5EExDJfyo/0vK cAtafchxiwpgKujMga4ZSGK3J04KEWSk2q2/8OsnsMuNy1GhfNW8DEJ50cWQp3QnIClY dheh6fIDIpqK/TDx4BYOHGpe+iACrR8o7etcP9/iHMWTvMEkXNiPasFV5V53BdK+e17u HZdrTtDW2djDiuZexRe63vnTql8VKrhaO0Bk759q/f0KITR8+zzyK6c9A92XE3nMwsd/ TdoboFR5U5jHk1u6ycLhcaSpaaEcBsvTCwn1VbhN5zE/4lf1DioqwHyOCQAffTM+RMl5 7gdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=y+LHqp0CO+dgCue2eP2m2K0nsDfgsLvhGKpdJ/EAqWE=; b=tj5TR+FUVPoMP24oVWqL0iSBLfmemgUN0ErBolqZU/5yrZ0sZL/c9WC5TlOxU89DLx pY/suX1NZtABbiQfh5W+NYm6GdGJBrbthbYMgIvHKlLH78VVQAOdeSvoIlspXxgh11VA k1jceLM4YRsDwWx+Kg20nA9jXFj1ADYUdmmkoKocaFeC1pTDWoLAupN3HftLiJL27F3Y FhPnLhKY++gBgAfJAB/boFLzWCydAIbgh1+PJVNh/SpaMtP0Ngz5Sm2035PJwu2bNabj lD0X+3IhfFLNyBBBvnN0+pfwFSiKhzTtjBzYKLm+Reew/GQzqZ1hNYybCNyJRrdbhBOA dlcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j1si1456291edr.167.2020.10.05.20.38.51; Mon, 05 Oct 2020 20:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgJFDgz (ORCPT + 99 others); Mon, 5 Oct 2020 23:36:55 -0400 Received: from foss.arm.com ([217.140.110.172]:36820 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbgJFDgz (ORCPT ); Mon, 5 Oct 2020 23:36:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7DDDB113E; Mon, 5 Oct 2020 20:36:54 -0700 (PDT) Received: from [10.163.74.99] (unknown [10.163.74.99]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7045B3F71F; Mon, 5 Oct 2020 20:36:51 -0700 (PDT) Subject: Re: [PATCH v3] arm64/mm: add fallback option to allocate virtually contiguous memory To: Sudarshan Rajagopalan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , Logan Gunthorpe , David Hildenbrand , Andrew Morton , Steven Price References: <9e6178d2828e9c36275487263c5842c688e5b731.1601582954.git.sudaraja@codeaurora.org> From: Anshuman Khandual Message-ID: <49dd60a7-25f4-8dc1-b905-088dff2a84fb@arm.com> Date: Tue, 6 Oct 2020 09:06:20 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <9e6178d2828e9c36275487263c5842c688e5b731.1601582954.git.sudaraja@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/02/2020 01:46 AM, Sudarshan Rajagopalan wrote: > When section mappings are enabled, we allocate vmemmap pages from physically > continuous memory of size PMD_SIZE using vmemmap_alloc_block_buf(). Section > mappings are good to reduce TLB pressure. But when system is highly fragmented > and memory blocks are being hot-added at runtime, its possible that such > physically continuous memory allocations can fail. Rather than failing the > memory hot-add procedure, add a fallback option to allocate vmemmap pages from > discontinuous pages using vmemmap_populate_basepages(). > > Signed-off-by: Sudarshan Rajagopalan > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Anshuman Khandual > Cc: Mark Rutland > Cc: Logan Gunthorpe > Cc: David Hildenbrand > Cc: Andrew Morton > Cc: Steven Price > --- > arch/arm64/mm/mmu.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 75df62f..11f8639 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -1121,8 +1121,15 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, > void *p = NULL; > > p = vmemmap_alloc_block_buf(PMD_SIZE, node, altmap); > - if (!p) > - return -ENOMEM; > + if (!p) { > + /* > + * fallback allocating with virtually > + * contiguous memory for this section > + */ Mapping is always virtually contiguous with or without huge pages. Please drop this comment here, as it's obvious. > + if (vmemmap_populate_basepages(addr, next, node, NULL)) > + return -ENOMEM; Please send in the 'altmap' instead of NULL for allocation from device memory if and when requested.