Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp607147ybl; Fri, 13 Dec 2019 01:34:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxZpFgqhp1LGBI+1SxlgrEcH7CJAG1sa0+PeYB+HM2kx9S7EMlpaDYY75W0U1UDSNc3z6nX X-Received: by 2002:a9d:7b4a:: with SMTP id f10mr1165085oto.4.1576229688475; Fri, 13 Dec 2019 01:34:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576229688; cv=none; d=google.com; s=arc-20160816; b=w5YG0DE43lBZ3cDTygNEgOY3EYqpPhVSld1+d0i0t39MoDb7AcqCdD1Wy8iXu5WdRO cjYILYlr4znWgauVNDFlG7y86MsN6UvPD0DJ6nPsF7oqrX5NN73urMrd0/eZhpjfkALJ qBEAZyjZcPNI6O9IHHng2l1WjpcuKIKdoMCNqZrukjlpcK2cssNtRibilDDnMv9shs/g z+BLGBhoX7sfwynYTpgQpre7klx07AQlA4fWkMFI7MReVp8fDbKmqJFHs7mUJGtQOr+C SegR1kyj40kCSif4oaw1yImcfBz21nWLBnPCkLL8aGbP3r2NaMKPT2woDAS8RuNxATYY oRSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=KY94rQv5/loJQD4i0BZGc7jhqbYj6PtDGEFoVjzh9zM=; b=mwojrkuPJJuWvyqaqTDOgiQ5D31uVNZAQLciGz1Zl+UnducsIjhOVyiTj8pnMLUY5R y8HoMqeUtuQSP7/4rUJzBoYmCVvIefKxbQgV2DJ7hY8eMfpSlYJ9sI4qSf+FAUL2tlAC uzh2h2vw4mv6QfUO8VBkAgGpBSXwiAE1qxzBC+6CiCy4T47z9gmE/JQ2rIqaVIBu2j/m hLXpnVOsVtz+rj1udVRTIlVIu9kY8pR4aKSXv4YGXkujyr9t5o6Kz0XmwPaAoBz3OpuL ypmd7uFPMzXJll4DHTl1Wj3jsyIyu12nfviW+/4niyU19Y/0psOeKrE4ac7sqqeYEnYV HerQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Gu8Vs9E+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l125si4978197oih.223.2019.12.13.01.34.37; Fri, 13 Dec 2019 01:34:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Gu8Vs9E+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbfLMJdj (ORCPT + 99 others); Fri, 13 Dec 2019 04:33:39 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33006 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbfLMJdi (ORCPT ); Fri, 13 Dec 2019 04:33:38 -0500 Received: by mail-pl1-f194.google.com with SMTP id c13so1018254pls.0 for ; Fri, 13 Dec 2019 01:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=KY94rQv5/loJQD4i0BZGc7jhqbYj6PtDGEFoVjzh9zM=; b=Gu8Vs9E+vFF8vFlZQHcm1Yilp0uo8ZYeY6s7APVwLAVv5v7A2KXo3Kxip03kVC8Qkj O6PwgC2GHF+SKubgVvhFvfGrBl+qy6z0udspUM2ac4H/mev6Y16cSo19BM5izD2spoip CTi0RjECdgrDGROEss9lxv5N0Z4RQgv8fnpmnHedCtGzypL7egdRd5P8NPkY7cvwB6eC iV71N7KxJhG81qEhh9VYzoVv1gEo9U6MXwLuKDzocT6jKASm+eULMERULn8xU390DPZ/ GYR6LXfSyJLJ1IWjHcKALyk/0phkNfS6aLbfPIehzQEPOZvIXPv/pQ7oUfRTqc0zYEmk 2b3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=KY94rQv5/loJQD4i0BZGc7jhqbYj6PtDGEFoVjzh9zM=; b=otU4AP6b396ZotweoJoGnPV+0PK607dX2UwGDxA+3asAU6XcAYGdlf+7y9PyE4h5TP tqP6eu6bHzJ+WoHASDD6+LsrIJ+pHw8xVYnLHFnvKqgguiYJOrnd8rHG+ORD8dvIY3nE J+byC6LQeCXvUx8NNbsOaRQxAT91LwqTpda/VQOVu7V39Uo4Qvg9SlWOXsiKalkzgIXq V9rDRe92oxR2XE4Mq9FwM/ZhcJ4pbDoyXGgaLka8/mdm7VUWOrvocRLAlg00yC0IAGd5 fD7jZJGdmjxnVb1N/1ICxTt/GvP1QpyY05L/sjWGgiIM4r6Wdb7vGuznNMmG7w2kLKUv WIYQ== X-Gm-Message-State: APjAAAVWuA+/B3g+rpJk52lYf5Bck/GkFYRRZnBjpG5Rd5XPjhSaFuVm npeFNR7hxTvUA9lZwGLDykN7ng== X-Received: by 2002:a17:90a:db49:: with SMTP id u9mr14893672pjx.13.1576229617625; Fri, 13 Dec 2019 01:33:37 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id w12sm10425259pfd.58.2019.12.13.01.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2019 01:33:36 -0800 (PST) Date: Fri, 13 Dec 2019 01:33:35 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig cc: "Lendacky, Thomas" , Keith Busch , Jens Axboe , "Singh, Brijesh" , Ming Lei , Peter Gonda , Jianxiong Gao , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "iommu@lists.linux-foundation.org" Subject: Re: [bug] __blk_mq_run_hw_queue suspicious rcu usage In-Reply-To: Message-ID: References: <20190905060627.GA1753@lst.de> <1d74607e-37f7-56ca-aba3-5a3bd7a68561@amd.com> <20190918132242.GA16133@lst.de> <20191128064056.GA19822@lst.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Dec 2019, David Rientjes wrote: > Since all DMA must be unencrypted in this case, what happens if all > dma_direct_alloc_pages() calls go through the DMA pool in > kernel/dma/remap.c when force_dma_unencrypted(dev) == true since > __PAGE_ENC is cleared for these ptes? (Ignoring for a moment that this > special pool should likely be a separate dma pool.) > > I assume a general depletion of that atomic pool so > DEFAULT_DMA_COHERENT_POOL_SIZE becomes insufficient. I'm not sure what > size any DMA pool wired up for this specific purpose would need to be > sized at, so I assume dynamic resizing is required. > > It shouldn't be *that* difficult to supplement kernel/dma/remap.c with the > ability to do background expansion of the atomic pool when nearing its > capacity for this purpose? I imagine that if we just can't allocate pages > within the DMA mask that it's the only blocker to dynamic expansion and we > don't oom kill for lowmem. But perhaps vm.lowmem_reserve_ratio is good > enough protection? > > Beyond that, I'm not sure what sizing would be appropriate if this is to > be a generic solution in the DMA API for all devices that may require > unecrypted memory. > Secondly, I'm wondering about how the DMA pool for atomic allocations compares with lowmem reserve for both ZONE_DMA and ZONE_DMA32. For allocations where the classzone index is one of these zones, the lowmem reserve is static, we don't account the amount of lowmem allocated and adjust this for future watermark checks in the page allocator. We always guarantee that reserve is free (absent the depletion of the zone due to GFP_ATOMIC allocations where we fall below the min watermarks). If all DMA memory needs to have _PAGE_ENC cleared when the guest is SEV encrypted, I'm wondering if the entire lowmem reserve could be designed as a pool of lowmem pages rather than a watermark check. If implemented as a pool of pages in the page allocator itself, and today's reserve is static, maybe we could get away with a dynamic resizing based on that static amount? We could offload the handling of this reserve to kswapd such that when the pool falls below today's reserve amount, we dynamically expand, do the necessary unencryption in blockable context, and add to the pool. Bonus is that this provides high-order lowmem reserve if implemented as per-order freelists rather than the current watermark check that provides no guarantees for any high-order lowmem. I don't want to distract from the first set of questions in my previous email because I need an understanding of that anyway, but I'm hoping Christoph can guide me on why the above wouldn't be an improvement even for non encrypted guests.