Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1503447ybt; Thu, 2 Jul 2020 07:09:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZJOTzjS1aORpKgSg+RfknOme//Jq/C2foSdC1Es9PYCfLs5i7QeAWiQuK2oA4YnguLZmk X-Received: by 2002:a05:6402:306a:: with SMTP id bs10mr27194573edb.51.1593698941590; Thu, 02 Jul 2020 07:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593698941; cv=none; d=google.com; s=arc-20160816; b=WUpBfWCuXTGpZGyMuz7kLrzkey351b1OVMdLos7gijAEB31cqfYpa9Mj04U67+kct3 q1E/uLiWHmyQqydqb4pDhWBbQYM5vKekrgBqSuOWLvX/KtVzsjmRzCD2xK7zu9QKKPx1 FcFHEZMq3OtHVWg3XEd/lJk9APdFHZUS4wmMqD5T+1TEuJ3nK01Wn4LPi8AZi2nI0Qbf imh5ZJISP/nVdD+lfh8KOcUjRXVG51sWBLu8ztyryFFGqhVfnEhsSKrfkLdsV5vieuN4 JQR2Rb05BfGpeALUnMaX4QBddRb7SqnqhOpoHz+C9eYSpuD2w1sr9jdlW3L1MDoA3HIx Je/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9US5bvCKOZdxA4WRvr0RylIuDM7OFe2cCSlWkm5zjr0=; b=ywlHlq73otgbAD5IUxpfUkBIT4gbI3q8UZVJawiZ98F4PE1LJPHHPM46ixksyvyq/i vha3vxWHSC4vNK+EKR0NYbuWUln2oDZS5pLDSTqFbuc4aQw4WbNHWJ5EkKt/mzvsZiK5 y+ttwCDasmAlgZSWvliA1Q1NZZjC1GE7MIi8FtWzXUS9Kr7JT918iQ+Jt1qKOLUZO2No 49oaN9cwaoHH3KcTVVC5N6x0twqrCa0xBEHH5cKnqf2DYMBS9QXISabU2wN8sK63PNaG b3ttE5eMnH/SR6fqYgBnnh9gYZhvyQKcZP6buo3FaYIDXaHfN3i6Ipt1zrP0jJKF5pmW gTQQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si6091787edj.100.2020.07.02.07.08.38; Thu, 02 Jul 2020 07:09:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729565AbgGBOH6 (ORCPT + 99 others); Thu, 2 Jul 2020 10:07:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:45236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729510AbgGBOH6 (ORCPT ); Thu, 2 Jul 2020 10:07:58 -0400 Received: from gaia (unknown [95.146.230.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F272720780; Thu, 2 Jul 2020 14:07:54 +0000 (UTC) Date: Thu, 2 Jul 2020 15:07:52 +0100 From: Catalin Marinas To: Anshuman Khandual Cc: linux-mm@kvack.org, Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Andrew Morton , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 (RESEND) 2/3] mm/sparsemem: Enable vmem_altmap support in vmemmap_alloc_block_buf() Message-ID: <20200702140752.GF22241@gaia> References: <1592442930-9380-1-git-send-email-anshuman.khandual@arm.com> <1592442930-9380-3-git-send-email-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1592442930-9380-3-git-send-email-anshuman.khandual@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2020 at 06:45:29AM +0530, Anshuman Khandual wrote: > There are many instances where vmemap allocation is often switched between > regular memory and device memory just based on whether altmap is available > or not. vmemmap_alloc_block_buf() is used in various platforms to allocate > vmemmap mappings. Lets also enable it to handle altmap based device memory > allocation along with existing regular memory allocations. This will help > in avoiding the altmap based allocation switch in many places. > > While here also implement a regular memory allocation fallback mechanism > when the first preferred device memory allocation fails. This will ensure > preserving the existing semantics on powerpc platform. To summarize there > are three different methods to call vmemmap_alloc_block_buf(). > > (., NULL, false) /* Allocate from system RAM */ > (., altmap, false) /* Allocate from altmap without any fallback */ > (., altmap, true) /* Allocate from altmap with fallback (system RAM) */ [...] > diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c > index bc73abf0bc25..01e25b56eccb 100644 > --- a/arch/powerpc/mm/init_64.c > +++ b/arch/powerpc/mm/init_64.c > @@ -225,12 +225,12 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, > * fall back to system memory if the altmap allocation fail. > */ > if (altmap && !altmap_cross_boundary(altmap, start, page_size)) { > - p = altmap_alloc_block_buf(page_size, altmap); > - if (!p) > - pr_debug("altmap block allocation failed, falling back to system memory"); > + p = vmemmap_alloc_block_buf(page_size, node, > + altmap, true); > + } else { > + p = vmemmap_alloc_block_buf(page_size, node, > + NULL, false); > } > - if (!p) > - p = vmemmap_alloc_block_buf(page_size, node); > if (!p) > return -ENOMEM; Is the fallback argument actually necessary. It may be cleaner to just leave the code as is with the choice between altmap and NULL. If an arch needs a fallback (only powerpc), they have the fallback in place already. I don't see the powerpc code any better after this change. I'm fine with the altmap argument though. -- Catalin