Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp98965pxv; Thu, 24 Jun 2021 03:48:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLT8ItwUORG46+xZj0abuaWeCeUXzc+ZF8Rxj0dZlBSF12XOnTj5DTMlkAbUO4HqEkF7kp X-Received: by 2002:a6b:b554:: with SMTP id e81mr3608963iof.163.1624531727079; Thu, 24 Jun 2021 03:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624531727; cv=none; d=google.com; s=arc-20160816; b=KCGSDDvxTVMF+MiZmwRBA4fQcqiRI8lpkuAT/OMpVKpIkKboU9RYQyBP+yXx6r/wFH 7iQ4GqUVFU5O5FEVyZPgDUcF2bAcL2ZDk28ewgiTU2HPOtdaIRJkncniDD8Nt6npYP31 t/cX4/rhzvVta5z4hEqUUo8Dr9r/GEr22xaa7bCaSDjKsQFPBglunw4cSMYH22FWXIAO X3kwk7bCbKnGUSajfWUqglY3uknP3q9Bq5YoHcowSwRjQ8ofWCq9Wj7fZmQdHF0hWcBu xQ2p+q4rbBIFDsiw5UCgGsYCJcpHY+uyZOG7hD4SJ/b+c9fxgUlo94wZlceLo3maCTcb vX5w== 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=4OVB0Ms7NZiFcbq+7Aux8lLi14MhI/3Y4I9kOEheptk=; b=nbEG1EbqoOUTVc2tIr42cpzsFO5mjvo19DpSfrYbh8SNRgqTmCcgYVXSopsJYuZea9 QtQG++3LBWZnpCFyMD/UTEliv/5adVBCzN/X/iwSY+w5y3tV52eLA9knCPASRRS8BEnG LD+eryQeW2mOje2bnyVL3tsgY1nkoZfq4CiJ/icdkK5miD0HBdPiPtQaPuzo3pMlYukN F/fCaOlj0uFlt8ROePesrgZ8QqG4MayGy7o7miVRMc5u1lRQds1J4WSdOwBHox6XSg8d 47nwMq//ZviBILxw+LSTk4XuxCHXjF3qHE2RaVF6ih27P6mQ00LQvXEWeRyg9GGMDXLJ B0qw== 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 l23si2840455jaf.47.2021.06.24.03.48.34; Thu, 24 Jun 2021 03:48:46 -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 S232214AbhFXKt5 (ORCPT + 99 others); Thu, 24 Jun 2021 06:49:57 -0400 Received: from foss.arm.com ([217.140.110.172]:53598 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231294AbhFXKt5 (ORCPT ); Thu, 24 Jun 2021 06:49:57 -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 3A05231B; Thu, 24 Jun 2021 03:47:38 -0700 (PDT) Received: from [10.57.9.136] (unknown [10.57.9.136]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6E5F73F718; Thu, 24 Jun 2021 03:47:36 -0700 (PDT) Subject: Re: [PATCH RFC 0/2] dma-pool: allow user to disable atomic pool To: Baoquan He , Christoph Hellwig Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, rientjes@google.com, rppt@linux.ibm.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, kexec@lists.infradead.org, iommu@lists.linux-foundation.org, m.szyprowski@samsung.com References: <20210624052010.5676-1-bhe@redhat.com> <20210624092930.GA802261@MiWiFi-R3L-srv> From: Robin Murphy Message-ID: <8b3d4e02-6e94-ad59-a480-fed8e55c009a@arm.com> Date: Thu, 24 Jun 2021 11:47:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210624092930.GA802261@MiWiFi-R3L-srv> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-06-24 10:29, Baoquan He wrote: > On 06/24/21 at 08:40am, Christoph Hellwig wrote: >> So reduce the amount allocated. But the pool is needed for proper >> operation on systems with memory encryption. And please add the right >> maintainer or at least mailing list for the code you're touching next >> time. > > Oh, I thoutht it's memory issue only, should have run > ./scripts/get_maintainer.pl. sorry. > > About reducing the amount allocated, it may not help. Because on x86_64, > kdump kernel doesn't put any page of memory into buddy allocator of DMA > zone. Means it will defenitely OOM for atomic_pool_dma initialization. > > Wondering in which case or on which device the atomic pool is needed on > AMD system with mem encrytion enabled. As we can see, the OOM will > happen too in kdump kernel on Intel system, even though it's not > necessary. Hmm, I think the Kconfig reshuffle has actually left a slight wrinkle here. For DMA_DIRECT_REMAP=y we can assume an atomic pool is always needed, since that was the original behaviour anyway. However the implications of AMD_MEM_ENCRYPT=y are different - even if support is enabled, it still should only be relevant if mem_encrypt_active(), so it probably does make sense to have an additional runtime gate on that. From a quick scan, use of dma_alloc_from_pool() already depends on force_dma_unencrypted() so that's probably fine already, but I think we'd need a bit of extra protection around dma_free_from_pool() to prevent gen_pool_has_addr() dereferencing NULL if the pools are uninitialised, even with your proposed patch as it is. Presumably nothing actually called dma_direct_free() when you tested this? Robin.