From patchwork Mon Nov 12 15:45:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Battersby X-Patchwork-Id: 10678879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3773314E2 for ; Mon, 12 Nov 2018 15:46:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 288CE2929B for ; Mon, 12 Nov 2018 15:46:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C8EA29920; Mon, 12 Nov 2018 15:46:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB0E629385 for ; Mon, 12 Nov 2018 15:46:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFD746B02A5; Mon, 12 Nov 2018 10:46:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD1606B02A6; Mon, 12 Nov 2018 10:46:01 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C5186B02A7; Mon, 12 Nov 2018 10:46:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 6EE4B6B02A5 for ; Mon, 12 Nov 2018 10:46:01 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id f81-v6so24750722qkb.14 for ; Mon, 12 Nov 2018 07:46:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:subject :to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=iX8zRGNPu62ZIigyZz2yhUPQAoybGxa86J9C5XNhZEs=; b=VCZcyTbRD0QqrSZVS+9shC/lMVymib7ZOHMUik/gK3omJUtoUHCu4eOhx+uC3qrXe3 peYykIQGNsUgA/2P5lKeZCTBiDUaCwSEJyIlXsRV6daFJAs+1RZFHNvvkSxPjm9E5hfy oHdblmNbhcA2lw+RRAlbTWXbOj4AjCd/jX6F30gELc29nfapszPp9bBB0hfzngBYbZZx eG4RkctftSom8toamCFqHW33gNjOYTW5OpAtB+fbey9J+Gw0vjRvIiF/zqUyoUXCJT66 gb+Rw3RS3kUo0SL7ec9myQQHZT4bZdjVNK7YryPld25SgZJtOw+CPs753zeKEV3zpnG3 U4vw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of btv1==854ac0a7dab==tonyb@cybernetics.com designates 173.71.130.66 as permitted sender) smtp.mailfrom="btv1==854ac0a7dab==tonyb@cybernetics.com" X-Gm-Message-State: AGRZ1gIdLzMLRV60OwVcdrOr1AOdrnusQJvLU+P2Vdt69/hdrkbW1gS0 inbC1G9WHWbYlDNmWltwaANAL9ERJS1COfB5/e+k0gAl/HifIc3mjvM2ngWgW/VLs/4wotNZCsU SFga+Ahx02dBllypNP4hg6ylOZvc8AngTLwd/L8qzcqZCChi5fZyfyt+82PHVH5W8Ag== X-Received: by 2002:a37:a053:: with SMTP id j80mr1363821qke.356.1542037561177; Mon, 12 Nov 2018 07:46:01 -0800 (PST) X-Google-Smtp-Source: AJdET5fxe3K9aaJPVw8L5uHW8mRKkWWc/L5lKbfg6M7H8ZLQvlyH9ItqmsM6vICdEGZz7SX537uf X-Received: by 2002:a37:a053:: with SMTP id j80mr1363791qke.356.1542037560451; Mon, 12 Nov 2018 07:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542037560; cv=none; d=google.com; s=arc-20160816; b=ZVmCG1diXqPiXNTYTmnbNlYmjAaRhz8IAhqHW/fzH0JfUdEUI80uVPHUyjqaBa46xL cPA2q1vsenbdbCikKOJ0qQA8rpzjO0zCLbPtTK+tHkCve8pqktVMIs0zfKKCtzlWjuBx 1okQhY93Czj8UO/DKy2fecDPuEfygosZV8CzzPdSKN5GL+pMZgvy1nlpSUQDw6fXu3e0 vArT9bwK2f1X9tBCPlD3pWVa/Yz15aoXbT2uwRe/4iDna2F0VvFph1SJaZUQ8v4E9cZo 2Vk62HeNK0X/Pyf3udeLAcLLrZi1IPDXA/N0RaYo7jneRp01O4DFdfyphDsQt+Lwhe7G gupw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-language:content-transfer-encoding:mime-version:user-agent :date:message-id:cc:to:subject:from; bh=iX8zRGNPu62ZIigyZz2yhUPQAoybGxa86J9C5XNhZEs=; b=A4ZsSlpsn6Kde8fkACL3o5coVxSIAk3GAM1+wirz805MF9Hn4+iWRGRMX/3eYoIlDw CkBRrqF62aU3MYYHYBDfus0Pu1k07gScK6zHhHKIEAn5eMWUuHiTxmcN29i5zVieu9ph BkzP+2OgZVJK0E+8P+9VdWYXFDLo83SVlO+x9e7fWC6QN/Ct8a2ZIVYc6sZOSMhls5oK joGQeeKfG6i57vDKnSwj3+/1WTswS9nAsmMbtk46Q88KPtqCCXCisAHuroJqfQLWQ05H y89sF8/QsHzYrI9f6k5yt24tGrexZnRxsrvT3u90zx80twk4FyHTFpRNBFH+DJAQDR9b 4IlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of btv1==854ac0a7dab==tonyb@cybernetics.com designates 173.71.130.66 as permitted sender) smtp.mailfrom="btv1==854ac0a7dab==tonyb@cybernetics.com" Received: from mail.cybernetics.com (mail.cybernetics.com. [173.71.130.66]) by mx.google.com with ESMTPS id r41si497493qtj.56.2018.11.12.07.46.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 07:46:00 -0800 (PST) Received-SPF: pass (google.com: domain of btv1==854ac0a7dab==tonyb@cybernetics.com designates 173.71.130.66 as permitted sender) client-ip=173.71.130.66; Authentication-Results: mx.google.com; spf=pass (google.com: domain of btv1==854ac0a7dab==tonyb@cybernetics.com designates 173.71.130.66 as permitted sender) smtp.mailfrom="btv1==854ac0a7dab==tonyb@cybernetics.com" X-ASG-Debug-ID: 1542037558-0fb3b01fb3add6a0001-v9ZeMO Received: from cybernetics.com ([10.157.1.126]) by mail.cybernetics.com with ESMTP id SkzT8XAKr4RyHkVH (version=SSLv3 cipher=DES-CBC3-SHA bits=112 verify=NO); Mon, 12 Nov 2018 10:45:58 -0500 (EST) X-Barracuda-Envelope-From: tonyb@cybernetics.com X-ASG-Whitelist: Client Received: from [10.157.2.224] (account tonyb HELO [192.168.200.1]) by cybernetics.com (CommuniGate Pro SMTP 5.1.14) with ESMTPSA id 8529365; Mon, 12 Nov 2018 10:45:58 -0500 From: Tony Battersby Subject: [PATCH v4 8/9] dmapool: improve accuracy of debug statistics To: Matthew Wilcox , Christoph Hellwig , Marek Szyprowski , iommu@lists.linux-foundation.org, linux-mm@kvack.org X-ASG-Orig-Subj: [PATCH v4 8/9] dmapool: improve accuracy of debug statistics Cc: linux-scsi@vger.kernel.org Message-ID: Date: Mon, 12 Nov 2018 10:45:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US X-Barracuda-Connect: UNKNOWN[10.157.1.126] X-Barracuda-Start-Time: 1542037558 X-Barracuda-Encrypted: DES-CBC3-SHA X-Barracuda-URL: https://10.157.1.122:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 1632 X-Virus-Scanned: by bsmtpd at cybernetics.com X-Barracuda-BRTS-Status: 1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Tony Battersby --- This depends on patch #1 "dmapool: fix boundary comparison" for the calculated blks_per_alloc value to be correct. The added blks_per_alloc value will also be used in the next patch. --- linux/mm/dmapool.c.orig 2018-08-06 17:48:54.000000000 -0400 +++ linux/mm/dmapool.c 2018-08-06 17:52:53.000000000 -0400 @@ -61,6 +61,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; }; @@ -105,8 +106,7 @@ show_pools(struct device *dev, struct de /* per-pool info, no real statistics yet */ temp = scnprintf(next, size, "%-16s %4zu %4zu %4u %2u\n", pool->name, blocks, - (size_t) pages * - (pool->allocation / pool->size), + (size_t) pages * pool->blks_per_alloc, pool->size, pages); size -= temp; next += temp; @@ -182,6 +182,9 @@ struct dma_pool *dma_pool_create(const c retval->size = size; retval->boundary = boundary; retval->allocation = allocation; + retval->blks_per_alloc = + (allocation / boundary) * (boundary / size) + + (allocation % boundary) / size; INIT_LIST_HEAD(&retval->pools);