From patchwork Tue Mar 21 16:24:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9637075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE40A602CC for ; Tue, 21 Mar 2017 16:28:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFB8228306 for ; Tue, 21 Mar 2017 16:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A48F92830A; Tue, 21 Mar 2017 16:28:28 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9657C28343 for ; Tue, 21 Mar 2017 16:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756962AbdCUQ0D (ORCPT ); Tue, 21 Mar 2017 12:26:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:36622 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758128AbdCUQYe (ORCPT ); Tue, 21 Mar 2017 12:24:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BF1BAAC9A; Tue, 21 Mar 2017 16:24:27 +0000 (UTC) From: Hannes Reinecke To: Jens Axboe Cc: Omar Sandoval , linux-block@vger.kernel.org, Linux Kernel Mailinglist , Hannes Reinecke Subject: [PATCH] blk-mq: add statistics for tag allocation failures Date: Tue, 21 Mar 2017 17:24:21 +0100 Message-Id: <1490113461-63123-1-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Hannes Reinecke --- block/blk-mq-debugfs.c | 15 +++++++++++++++ block/blk-mq-tag.c | 6 ++++-- block/blk-mq-tag.h | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index f6d9179..51622f6 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -161,6 +161,8 @@ static void blk_mq_debugfs_tags_show(struct seq_file *m, { seq_printf(m, "nr_tags=%u\n", tags->nr_tags); seq_printf(m, "nr_reserved_tags=%u\n", tags->nr_reserved_tags); + seq_printf(m, "starved_count=%u\n", tags->starved_count); + seq_printf(m, "failed_count=%u\n", tags->failed_count); seq_printf(m, "active_queues=%d\n", atomic_read(&tags->active_queues)); @@ -190,6 +192,18 @@ static int hctx_tags_show(struct seq_file *m, void *v) return res; } +static ssize_t hctx_tags_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct blk_mq_hw_ctx *hctx = m->private; + struct blk_mq_tags *tags = hctx->tags; + + tags->starved_count = 0; + tags->failed_count = 0; + return count; +} + static int hctx_tags_open(struct inode *inode, struct file *file) { return single_open(file, hctx_tags_show, inode->i_private); @@ -198,6 +212,7 @@ static int hctx_tags_open(struct inode *inode, struct file *file) static const struct file_operations hctx_tags_fops = { .open = hctx_tags_open, .read = seq_read, + .write = hctx_tags_write, .llseek = seq_lseek, .release = single_release, }; diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 54c8436..692ca28 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -125,9 +125,10 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) if (tag != -1) goto found_tag; - if (data->flags & BLK_MQ_REQ_NOWAIT) + if (data->flags & BLK_MQ_REQ_NOWAIT) { + tags->failed_count++; return BLK_MQ_TAG_FAIL; - + } ws = bt_wait_ptr(bt, data->hctx); drop_ctx = data->ctx == NULL; do { @@ -152,6 +153,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) if (tag != -1) break; + tags->starved_count++; if (data->ctx) blk_mq_put_ctx(data->ctx); diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h index 6349742..f4f618f 100644 --- a/block/blk-mq-tag.h +++ b/block/blk-mq-tag.h @@ -10,6 +10,9 @@ struct blk_mq_tags { unsigned int nr_tags; unsigned int nr_reserved_tags; + unsigned int starved_count; + unsigned int failed_count; + atomic_t active_queues; struct sbitmap_queue bitmap_tags;