Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp616103ybl; Tue, 7 Jan 2020 11:58:25 -0800 (PST) X-Google-Smtp-Source: APXvYqzjQ4/AnPu02RmyikJuhN5/6NROdptZBj8UTfdoMLda+bxRpmAnGhxpVrYjY8Zl25zBVqjN X-Received: by 2002:aca:3354:: with SMTP id z81mr63693oiz.129.1578427105512; Tue, 07 Jan 2020 11:58:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578427105; cv=none; d=google.com; s=arc-20160816; b=obnpmraBwoVykFZc0xy6Goncvbsj5g3emt3iZE3waaJ3jvRahjdunO2ks6Ykjb/TTW tuhEbBORKCkoMf54lfQdj8gMpD+F6y3SDYeHh0FWrwXQLYPGII0vA+rsvjm8HkLYfOUc WHRD+PznI7SfgX5vmfJogVM6MjaaGdFkZ2qAGon7iSZyeUSzoRVWwkWrSrqYD/b/F4++ p1QnoVOsEnRSNL0g6gh/3d6uWBCf4Q5RqmxjkjVrV+6XmkDgyMC57IhwiFMHlASyhTqB 47PHuoFf0sviCOBk5in9assGeq/dUpIkMBGJtzJLKHib2+4cCuKsyVu8wWsQwgJHoNmd OLqg== 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=Yxkh8StDu3vfVeGtFseg/gks40WP5yhSnsk2dLl/57E=; b=ob0w2w5syVGrU4/szwSQvKaOAxkOGvRE/JlKUqusw2oOCMtICR/GDa/L722w56iWii e9J2D8LcAIVZBYoFRmpKltfiKDPZSMt2hXqADpu14FFQf0KtVWJvGgWC+Pz8m7uujcbH crgcNmOmXgOp8s54o33utZFFdS6valfFLkUwFzJCPjwYRVyYqlU06Y2YJdS6Ua49pA3H cxVVhSxS72arG+DBRX1Ql0IOYDmDdFqj+CKkuR3SaU9vfgRraaV9FjeTX4BtSTmob4BJ 7Hvjf2QuNVEhLgkm2s7zuKXPylaDtWzl/RTykvCaxWyzpcULZsmjFiOQiIQG63KS+x2A UwVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PHyPQo+y; 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 z65si563528oia.33.2020.01.07.11.58.12; Tue, 07 Jan 2020 11:58:25 -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=PHyPQo+y; 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 S1728705AbgAGT52 (ORCPT + 99 others); Tue, 7 Jan 2020 14:57:28 -0500 Received: from mail-pf1-f169.google.com ([209.85.210.169]:45475 "EHLO mail-pf1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728440AbgAGT51 (ORCPT ); Tue, 7 Jan 2020 14:57:27 -0500 Received: by mail-pf1-f169.google.com with SMTP id 2so366225pfg.12 for ; Tue, 07 Jan 2020 11:57:26 -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=Yxkh8StDu3vfVeGtFseg/gks40WP5yhSnsk2dLl/57E=; b=PHyPQo+yCzPgAyKjg4UI6suHI+/ilkeRBuy3mWhSA7DVXVKUcuiIVjWuDG0hXVodbp mcEUZ8yoRDIY3DPtWAuhFQ88QZR7soYmQyLQTqZEszF+yPWu2wMSk1CpA4LR0pAbrVDd q4LBK2ljorr++qqoPelhCd8t1EggBBdeX0WFOtKW4VJUvq6lJa/RNpWb1Q+6eNYfCjNr T9NWKpNAY1pnkoHSYx9wgQ+JL6d2py3WTMFS5HkJExIw+lWTzuUQDmzDKTyKEcA43Sv9 oa3NoHBG3bOurQC3DwKeSF7NSDYXgga0LPUAg3n7pfsZ+UJCxf0vDwgnCF7ayUcKrSKK GNLA== 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=Yxkh8StDu3vfVeGtFseg/gks40WP5yhSnsk2dLl/57E=; b=tFgzXW4TSn0zttr0wm91/E9hpaCOsYt/J6JZEkkNLIGI7sP1vj1aMKNkCpqTCF9gwd UllXJXp3ijoYO9kqyH8OJ2RpAmjaSPNjHA56NxBE8SiojDW2EmDTKco2aytXmHobzml7 07Z4ahFJOEgMA3sZEfkG/tbmgkVRXG+1Bd/uBnZZ3VuChlloTBI0n9j5tMB/8pZc4Q8A wymUJMqZDiLY0nzigSbBdW5Tzm2thlnZDeCt+zy+qwPwvZDwoEHSZvutLOXBT47JIFN5 ktXKO2nT00fuIQ8Ly712zFJs3J3WhEo2fSivKEElC4R3pI9lonG92jpmsL05kVTd15JU kR+A== X-Gm-Message-State: APjAAAXMHazPm8ns29RORg2rx+PS7KvfpX13145drROJmg1rUwveFTy6 uFzeGhL6ach1VFm6mN8JYFO0/A== X-Received: by 2002:a65:538b:: with SMTP id x11mr1139153pgq.395.1578427045338; Tue, 07 Jan 2020 11:57:25 -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 2sm373729pjh.19.2020.01.07.11.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 11:57:24 -0800 (PST) Date: Tue, 7 Jan 2020 11:57:24 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig cc: Robin Murphy , "Lendacky, Thomas" , "Singh, Brijesh" , "Grimm, Jon" , baekhw@google.com, "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" Subject: Re: [rfc] dma-mapping: preallocate unencrypted DMA atomic pool In-Reply-To: <20200107105458.GA3139@lst.de> Message-ID: References: <3213a6ac-5aad-62bc-bf95-fae8ba088b9e@arm.com> <20200107105458.GA3139@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 Tue, 7 Jan 2020, Christoph Hellwig wrote: > > On 01/01/2020 1:54 am, David Rientjes via iommu wrote: > >> Christoph, Thomas, is something like this (without the diagnosic > >> information included in this patch) acceptable for these allocations? > >> Adding expansion support when the pool is half depleted wouldn't be *that* > >> hard. > >> > >> Or are there alternatives we should consider? Thanks! > > > > Are there any platforms which require both non-cacheable remapping *and* > > unencrypted remapping for distinct subsets of devices? > > > > If not (and I'm assuming there aren't, because otherwise this patch is > > incomplete in covering only 2 of the 3 possible combinations), then > > couldn't we keep things simpler by just attributing both properties to the > > single "atomic pool" on the basis that one or the other will always be a > > no-op? In other words, basically just tweaking the existing "!coherent" > > tests to "!coherent || force_dma_unencrypted()" and doing > > set_dma_unencrypted() unconditionally in atomic_pool_init(). > > I think that would make most sense. > I'll rely on Thomas to chime in if this doesn't make sense for the SEV usecase. I think the sizing of the single atomic pool needs to be determined. Our peak usage that we have measured from NVMe is ~1.4MB and atomic_pool is currently sized to 256KB by default. I'm unsure at this time if we need to be able to dynamically expand this pool with a kworker. Maybe when CONFIG_AMD_MEM_ENCRYPT is enabled this atomic pool should be sized to 2MB or so and then when it reaches half capacity we schedule some background work to dynamically increase it? That wouldn't be hard unless the pool can be rapidly depleted. Do we want to increase the atomic pool size by default and then do background dynamic expansion?