Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3978552pxb; Tue, 25 Jan 2022 00:30:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXGYXRzFhPb7vt2Pj+fpNR2niz3AgZadMBit816fHd9t5pRUCZoi30TKQlrkP4a5r6+aqb X-Received: by 2002:a17:903:22c9:b0:14b:2c4e:5c35 with SMTP id y9-20020a17090322c900b0014b2c4e5c35mr13764984plg.10.1643099434740; Tue, 25 Jan 2022 00:30:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099434; cv=none; d=google.com; s=arc-20160816; b=KPZ705WRD1kQf1dh1KP57ryknPGUhHtnE7sLssSRYgibpJ6Hk+0OdnHZNukF2JNh4U 1I7NWQgVEk/Qvc78R6y0Z3rtz6F8RnjwtQMmkFBKt00JHVjwbUm31ZFHU1uu5bJ27npH SnBO0hLvy47wuPOi9mHs4s7afMKQKL/bH4Mb1zM+ULOR3mlq8sn+rPUqSODaxiLdflzU mR354WyeTS+NeWXta+Btxc8dSnZLmXTOuHSlQquW5ZxHgBre35sd5x21krhQFbTSXQJb houSGcn49JiwvBKYvRPypJRB/EYUDd9nrschcjhmW/kwsgc/n9DUsBkgq7JgvpABr9ub GF5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oOWvsJ7N4UpZt8FAs6bArC1wnaJtsjiW2XgndASC3kY=; b=MZuyr8WorUI+bxFnWnG3OSqbwxSXTQ/CfrwnbuKoKxNOTuOqtAsh6WGQ0+zzE8B0AV 6bH2UIOF4w1hrHfzn0yz2DQd89fD7PcemUC6ko0bn3RaqZken/F7LpBu+USorYAbKYYE vWZJb9NfRD5e3t+02vYauxrd3eJvvDNynt1PR7e5EnrtnbU5l0nmJuG3YkK3NWDuw2hF hnhIVnxIQxBzx3KTFp6yP3CdPBn4g2u6HNbLVstj2z1QDoamZXnvcJVhZTd+PAc4xixl /IJHZKm6I8iDeICFVGULRFoEaKYnP3StFf3ZarU/Sz6dd01dEDPdp1xg25RvuhMZIx2A q/FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ay0wv7gN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z5si13845501pfa.66.2022.01.25.00.30.22; Tue, 25 Jan 2022 00:30:34 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ay0wv7gN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378257AbiAYCmt (ORCPT + 99 others); Mon, 24 Jan 2022 21:42:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356798AbiAXUcg (ORCPT ); Mon, 24 Jan 2022 15:32:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 515C0C07E282; Mon, 24 Jan 2022 11:44:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EDAF2B81188; Mon, 24 Jan 2022 19:44:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D72DC340E5; Mon, 24 Jan 2022 19:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053454; bh=Bg7anAB4uQgzVMybOL3Xzqrol0AtHIVBdb6VcLuiqKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ay0wv7gNwOPSOHbU7MPCadBGSM63HTABPI50O/DF5n64odCLIgvl3ojB/k/9+90Fv +38l7DP6ldjBqX/J7adsUWjSJ8kIa2aZpW7dtg+bBB5SbUA+QPjtAfIDXWYaFKQ8Fe KnqxkF8uQEkk9BZ2ebSqIaXRsieY64NaDI3qMQ/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baoquan He , Christoph Hellwig , John Donnelly , David Hildenbrand , Marek Szyprowski , Robin Murphy , Borislav Petkov , Christoph Lameter , David Laight , David Rientjes , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Joonsoo Kim , Pekka Enberg , Vlastimil Babka , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 038/563] dma/pool: create dma atomic pool only if dma zone has managed pages Date: Mon, 24 Jan 2022 19:36:43 +0100 Message-Id: <20220124184025.748160672@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baoquan He commit a674e48c5443d12a8a43c3ac42367aa39505d506 upstream. Currently three dma atomic pools are initialized as long as the relevant kernel codes are built in. While in kdump kernel of x86_64, this is not right when trying to create atomic_pool_dma, because there's no managed pages in DMA zone. In the case, DMA zone only has low 1M memory presented and locked down by memblock allocator. So no pages are added into buddy of DMA zone. Please check commit f1d4d47c5851 ("x86/setup: Always reserve the first 1M of RAM"). Then in kdump kernel of x86_64, it always prints below failure message: DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations swapper/0: page allocation failure: order:5, mode:0xcc1(GFP_KERNEL|GFP_DMA), nodemask=(null),cpuset=/,mems_allowed=0 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.13.0-0.rc5.20210611git929d931f2b40.42.fc35.x86_64 #1 Hardware name: Dell Inc. PowerEdge R910/0P658H, BIOS 2.12.0 06/04/2018 Call Trace: dump_stack+0x7f/0xa1 warn_alloc.cold+0x72/0xd6 __alloc_pages_slowpath.constprop.0+0xf29/0xf50 __alloc_pages+0x24d/0x2c0 alloc_page_interleave+0x13/0xb0 atomic_pool_expand+0x118/0x210 __dma_atomic_pool_init+0x45/0x93 dma_atomic_pool_init+0xdb/0x176 do_one_initcall+0x67/0x320 kernel_init_freeable+0x290/0x2dc kernel_init+0xa/0x111 ret_from_fork+0x22/0x30 Mem-Info: ...... DMA: failed to allocate 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocation DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations Here, let's check if DMA zone has managed pages, then create atomic_pool_dma if yes. Otherwise just skip it. Link: https://lkml.kernel.org/r/20211223094435.248523-3-bhe@redhat.com Fixes: 6f599d84231f ("x86/kdump: Always reserve the low 1M when the crashkernel option is specified") Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Acked-by: John Donnelly Reviewed-by: David Hildenbrand Cc: Marek Szyprowski Cc: Robin Murphy Cc: Borislav Petkov Cc: Christoph Lameter Cc: David Laight Cc: David Rientjes Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Joonsoo Kim Cc: Pekka Enberg Cc: Vlastimil Babka Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/dma/pool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/dma/pool.c +++ b/kernel/dma/pool.c @@ -206,7 +206,7 @@ static int __init dma_atomic_pool_init(v GFP_KERNEL); if (!atomic_pool_kernel) ret = -ENOMEM; - if (IS_ENABLED(CONFIG_ZONE_DMA)) { + if (has_managed_dma()) { atomic_pool_dma = __dma_atomic_pool_init(atomic_pool_size, GFP_KERNEL | GFP_DMA); if (!atomic_pool_dma) @@ -229,7 +229,7 @@ static inline struct gen_pool *dma_guess if (prev == NULL) { if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32)) return atomic_pool_dma32; - if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA)) + if (atomic_pool_dma && (gfp & GFP_DMA)) return atomic_pool_dma; return atomic_pool_kernel; }