Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5747661ioo; Wed, 1 Jun 2022 11:42:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzspw61Wg4+kPiBgH3SvDyetj2JGm4ANHV4wzrmbZKDmrew6GmNw/82eZZZFCfJpA+HW/2g X-Received: by 2002:a17:90a:e642:b0:1e3:524e:4cb with SMTP id ep2-20020a17090ae64200b001e3524e04cbmr793568pjb.114.1654108920057; Wed, 01 Jun 2022 11:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654108920; cv=none; d=google.com; s=arc-20160816; b=koi4V1tvML5Mved3LXCB20WBTXauvSzkE8xeE9fGWKjByaqTnCUWhzcv4yD5eRgiqQ 454TtOkVuYSu1wjz1pytuk/Zhjd9t/ZoUbvcW9DMl1GBLa5DfstkRqzTAZq5FF7yXqDh q+WeZ6RsGSK8qvOcWCxO8xI8zrD6TKnOaNE+Kyo47UxfCqLWPYuULiTgLL4JG1mxIssC gB5CUu+LZFZ6SXQJ74cxhvwzHodkZjsOoaALTNKJn4hgsMQZtJqebeLJwwRyfTjIKxxJ Ozr4XCJOUbMqYvJBB19uH7uJq3i0hUZRWoPcK9BUfPLnvpD8KtMkw/4kWm7nPKPfOBSP hAmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=rNdP2kaEaiE3hbuiA/e+g9gDcy+WPELLw0lP/oFemhk=; b=RRpVgUG5c96x6udrrpGeFyP0IUHFICyZX5yBj3SXJtOLT5E/RhNASBFhy3okJHPXG8 soCPBPg6GHKmuBDWnHJQrpD/LS0cWZ9C/x1r1l6I+yAx8yvDlT1XaZ6FCaTY/yx5Cujs pPRJEcZcUH+zVZLA4IHyQnlN90kU3PDjiTfOyom52ebROowvX7XV6Qe9lqlKaoR7ZAJT 3ZFSdpTfp54tNqlVC15NS4Jl5sdb4QuJMF0VL9bytuYxYSpZv3HWS7RUhaOMLsW/7Sxm 8+9UDJbA7UusRc34E7lYbaBb4HbSCv0PovxlnJPorZS3PazCpNHdY+u0IFS8LHEutYvm SvFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k62-20020a636f41000000b00398580e51c9si3606130pgc.76.2022.06.01.11.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 11:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 90E7EBC6C6; Wed, 1 Jun 2022 11:38:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347484AbiEaTsd (ORCPT + 99 others); Tue, 31 May 2022 15:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241900AbiEaTsb (ORCPT ); Tue, 31 May 2022 15:48:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78945DF93 for ; Tue, 31 May 2022 12:48:30 -0700 (PDT) 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 4283523A; Tue, 31 May 2022 12:48:30 -0700 (PDT) Received: from [10.57.81.38] (unknown [10.57.81.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B791E3F766; Tue, 31 May 2022 12:48:28 -0700 (PDT) Message-ID: Date: Tue, 31 May 2022 20:48:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 04/10] dmapool: improve accuracy of debug statistics Content-Language: en-GB To: Tony Battersby , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: iommu@lists.linux-foundation.org, kernel-team@fb.com, Matthew Wilcox , Keith Busch , Andy Shevchenko , Tony Lindgren References: <9b08ab7c-b80b-527d-9adf-7716b0868fbc@cybernetics.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-05-31 19:17, Tony Battersby wrote: > The "total number of blocks in pool" debug statistic currently does not > take the boundary value into account, so it diverges from the "total > number of blocks in use" statistic when a boundary is in effect. Add a > calculation for the number of blocks per allocation that takes the > boundary into account, and use it to replace the inaccurate calculation. > > This depends on the patch "dmapool: fix boundary comparison" for the > calculated blks_per_alloc value to be correct. > > Signed-off-by: Tony Battersby > --- > mm/dmapool.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/mm/dmapool.c b/mm/dmapool.c > index 782143144a32..9e30f4425dea 100644 > --- a/mm/dmapool.c > +++ b/mm/dmapool.c > @@ -47,6 +47,7 @@ struct dma_pool { /* the pool */ > struct device *dev; > unsigned int allocation; > unsigned int boundary; > + unsigned int blks_per_alloc; > char name[32]; > struct list_head pools; > }; > @@ -92,8 +93,7 @@ static ssize_t pools_show(struct device *dev, struct device_attribute *attr, cha > /* per-pool info, no real statistics yet */ > temp = scnprintf(next, size, "%-16s %4zu %4zu %4u %2u\n", Nit: if we're tinkering with this, it's probably worth updating the whole function to use sysfs_emit{_at}(). > pool->name, blocks, > - (size_t) pages * > - (pool->allocation / pool->size), > + (size_t) pages * pool->blks_per_alloc, > pool->size, pages); > size -= temp; > next += temp; > @@ -168,6 +168,9 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev, > retval->size = size; > retval->boundary = boundary; > retval->allocation = allocation; > + retval->blks_per_alloc = > + (allocation / boundary) * (boundary / size) + > + (allocation % boundary) / size; Do we really need to store this? Sure, 4 divisions (which could possibly be fewer given the constraints on boundary) isn't the absolute cheapest calculation, but I still can't imagine anyone would be polling sysfs stats hard enough to even notice. Thanks, Robin. > > INIT_LIST_HEAD(&retval->pools); >