Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp226379ybz; Wed, 15 Apr 2020 07:39:05 -0700 (PDT) X-Google-Smtp-Source: APiQypJBNrE6L0h90qXziJKmoR6axnxjkKoI3KlSximuHXXQCMpsdldWOfBQmSl5FSrnQ8qHaE9Y X-Received: by 2002:a50:af02:: with SMTP id g2mr25842874edd.69.1586961545609; Wed, 15 Apr 2020 07:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586961545; cv=none; d=google.com; s=arc-20160816; b=xIu9vp/tEyVaZ0S6RZ/+IMBIi//YOko4WtcqXASW158d64RYvjFLvZTZjuGHO1pGTl ulM495pEiu3sGZ4jwgJxqY2m939g1i/ednMBM+xuD+X07hpRKXFz2SWAFZZm/KTChCjh D78CwEbgqOnPBNA1M8tJkx9jxLbT8KkR3RauP+dMrP2mkg2cb1ksb8fTbkXtjLwVTsDQ nbBMVN3ZqksdfzCp1gzHzcMHZHpIKXoTV+QkKiqmJMIaAHd2dkUR3rsNyuIt72h0T47g Qiy3uGmSL20pItGgRUZ7dCeRQM4ikuo7RRMANhwmUcev0fIBLgBSjl7+CkOeXcA+eavN c6HA== 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=ESsKmnN/8XjLZGFCRgaE4t6oba6cTfi788uzFnxL0dM=; b=qsMFjElidUr0i9b1s71TtwcGqqEMZEvg4LdTK29DLG1I6G/a/6rjQSBg3jreZ8XJgk mohcHVJ4mgsM1S7kupWLBi+dP3CLWgSZbzTYIgSrRLqXs1aLzjLlSg3EOsdbBz8DzVvi 0NiWbpVU1zOqnX8i5+DEl1HBEnh2OQ3HPFoPvp7vjWIIJefqpOwTbCvXiP6PqF1HxUz6 i5O1v9adU+bcJ5c9JJeCKxAB4hGQZdKfLUwsvpyqnF9OTNSWfOQKVTkXQvuSjiKW7fU2 zD5CRCQTQXS80R0QCoz2wQXTyj+moIiPZAWPjg1XQ9j8Ur96izFUya8/AP5o3NPw6/PQ hhhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B8Zpz7Tg; spf=pass (google.com: best guess record for 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si5586504edq.75.2020.04.15.07.38.40; Wed, 15 Apr 2020 07:39:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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=@google.com header.s=20161025 header.b=B8Zpz7Tg; spf=pass (google.com: best guess record for 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392207AbgDOAGH (ORCPT + 99 others); Tue, 14 Apr 2020 20:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2634554AbgDOAFB (ORCPT ); Tue, 14 Apr 2020 20:05:01 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7376C061A0E for ; Tue, 14 Apr 2020 17:05:01 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 188so659272pgj.13 for ; Tue, 14 Apr 2020 17:05:01 -0700 (PDT) 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=ESsKmnN/8XjLZGFCRgaE4t6oba6cTfi788uzFnxL0dM=; b=B8Zpz7TgZ1vEk8R/IpXo/21kD7KbRuD+XLLWXecF+QlLac8VLY2jSNWWBUXQwDhEdH lqqcgClcDh2UJeu8UR4B8dAEiRwzdwUJ3wq/Rdc814Jt8PsyHkUwIDPC7Bu5ApdVzgqc Pfl+mVhUnQpuYKHQMNXiUmkRnL3+OostdVxdmsYR4y63MEzRq0S8Lm5sLkP6zs7m1C1U UX+ZNvmkNypoZBKFiH0Aye9M5y+wEYwVZoPbv0T2HxR4RLDnIEWF8JOGjBmzOvlV0Fo2 pK+8Q2H/XmRMQijHm6TF5DygcosQAubi/LPQYJiy0xpzyz7fsMTUpSyFBu/D8p45eevb mDbw== 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=ESsKmnN/8XjLZGFCRgaE4t6oba6cTfi788uzFnxL0dM=; b=eFpb2rElusuFoHUg9emmoMQ7PrN0STaoidzSLDbHOlsKNMIH2DE5q3Ick4cJdzv2GE HObiX6ybUcouHJGkmhOYrAw3EHiyMjcPZgPrPo04cwnOamLCtGdV674xMad0+vMbauyB 8rtUKPooQUw7Elux11dV5UraGTa/zjFYIFg8r9SE0HXaKwDBAX4FTsDU1+FrMP6vGuRn fYWmnQwSJCrR2vzcW8jCcrroXx1yxqdTzW0Y5Pxt+sPal23z7D/a/t143nytS22iOx6P IjKuoFPjRDIUIFvm30IngxOIFeOWGLRehW33obrigNrGWYmHayvnrfU5+O+ndxBwGern CYpQ== X-Gm-Message-State: AGi0PuZaytiV4f0HT8n4j+c+oyQJZaP6y3TMInh0QSv9jA/6uGrunktu 4bAWGhHIKt9qrGPK87+ZSILI8A== X-Received: by 2002:a63:d904:: with SMTP id r4mr24446955pgg.323.1586909101065; Tue, 14 Apr 2020 17:05:01 -0700 (PDT) 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 128sm1061161pfx.187.2020.04.14.17.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 17:05:00 -0700 (PDT) Date: Tue, 14 Apr 2020 17:04:59 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Christoph Hellwig , Tom Lendacky cc: Brijesh Singh , Jon Grimm , Joerg Roedel , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Subject: [patch 5/7] dma-pool: add pool sizes to debugfs In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) 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 The atomic DMA pools can dynamically expand based on non-blocking allocations that need to use it. Export the sizes of each of these pools, in bytes, through debugfs for measurement. Suggested-by: Christoph Hellwig Signed-off-by: David Rientjes --- kernel/dma/pool.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c index cf052314d9e4..3e22022c933b 100644 --- a/kernel/dma/pool.c +++ b/kernel/dma/pool.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2020 Google LLC */ +#include #include #include #include @@ -15,6 +16,11 @@ static struct gen_pool *atomic_pool_dma __ro_after_init; static struct gen_pool *atomic_pool_dma32 __ro_after_init; static struct gen_pool *atomic_pool_kernel __ro_after_init; +#ifdef CONFIG_DEBUG_FS +static unsigned long pool_size_dma; +static unsigned long pool_size_dma32; +static unsigned long pool_size_kernel; +#endif #define DEFAULT_DMA_COHERENT_POOL_SIZE SZ_256K static size_t atomic_pool_size = DEFAULT_DMA_COHERENT_POOL_SIZE; @@ -29,6 +35,38 @@ static int __init early_coherent_pool(char *p) } early_param("coherent_pool", early_coherent_pool); +#ifdef CONFIG_DEBUG_FS +static void __init dma_atomic_pool_debugfs_init(void) +{ + struct dentry *root; + + root = debugfs_create_dir("dma_pools", NULL); + if (IS_ERR_OR_NULL(root)) + return; + + debugfs_create_ulong("pool_size_dma", 0400, root, &pool_size_dma); + debugfs_create_ulong("pool_size_dma32", 0400, root, &pool_size_dma32); + debugfs_create_ulong("pool_size_kernel", 0400, root, &pool_size_kernel); +} + +static void dma_atomic_pool_size_add(gfp_t gfp, size_t size) +{ + if (gfp & __GFP_DMA) + pool_size_dma += size; + else if (gfp & __GFP_DMA32) + pool_size_dma32 += size; + else + pool_size_kernel += size; +} +#else +static inline void dma_atomic_pool_debugfs_init(void) +{ +} +static inline void dma_atomic_pool_size_add(gfp_t gfp, size_t size) +{ +} +#endif /* CONFIG_DEBUG_FS */ + static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size, gfp_t gfp) { @@ -76,6 +114,7 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size, if (ret) goto encrypt_mapping; + dma_atomic_pool_size_add(gfp, pool_size); return 0; encrypt_mapping: @@ -160,6 +199,8 @@ static int __init dma_atomic_pool_init(void) if (!atomic_pool_dma32) ret = -ENOMEM; } + + dma_atomic_pool_debugfs_init(); return ret; } postcore_initcall(dma_atomic_pool_init);