From patchwork Wed Feb 7 19:41:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10205887 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 7BA5A602D8 for ; Wed, 7 Feb 2018 19:42:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BF3929104 for ; Wed, 7 Feb 2018 19:42:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60E0329108; Wed, 7 Feb 2018 19:42:00 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham 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 C987F290F6 for ; Wed, 7 Feb 2018 19:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754154AbeBGTl7 (ORCPT ); Wed, 7 Feb 2018 14:41:59 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:45990 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754048AbeBGTl6 (ORCPT ); Wed, 7 Feb 2018 14:41:58 -0500 Received: by mail-pg0-f67.google.com with SMTP id m136so691870pga.12 for ; Wed, 07 Feb 2018 11:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t/yD1VNiadgzPbGSAEBRMVNLF5O+0HGBsUCFjQo/4xY=; b=prsLXsnIO07zKqxuhz2G2av/pI4w7NetReGuJI9jUXLFyJrVZkyBnQ2FCyXM5iY3lj WVWPpFfv1T2663Bkc4Kp8WWuwoGgSJnc0DzM5f5ragkvnprCNR8O/tbxL8nixTUMxY5y e/4DCbG89jzvfaL/2eUhA96POvKf1BxuuPQqAAoGkuza4lRMsyz0wRz2vNBeyd0MfsUc i4DWFHJLAa+cnjhYwDiHbl5uFVRE7T4ooTWX/39+mod9QDxeF2y6JrgjmexXZs1+Aj6j 0LAgLrVzp72W73Zy6VzCK+8xC3FfK+z1O6RfHKYf3zsUWFvld5lLkDnCwO3g2HAGdmVe MprQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t/yD1VNiadgzPbGSAEBRMVNLF5O+0HGBsUCFjQo/4xY=; b=Lt85CL3K2Ds4YeOQzwrUFw6B08Djql3QJk1Dqbz0ZX45LE9+nhnQ4pz9u8PCFhnMGW nYdM04isAfC3RLoKChlYbghF0tSpHMx0qRra+Lb2K6aYqMoF1iRM4wTFIaFTmdbM16MY /2WBFAGE7zhDE1MKP+i+XYs/eqwdF1Lii6oIumFTEvP+haGL09JPAWT+2LZOSacS89Yr H1bC4VuPbGp0Zb2l8m9eST5BOpRa9rrHeLAK64//H/SFklXQtM21QtcZxASVC+FdT/hP Yhf8rVqyXQSDMFVtCR5MsB4UTRqvkCWc3SOOZCFDTQCB1xxQn9jcOY8hNJ+1NE+iSCq1 Nc5Q== X-Gm-Message-State: APf1xPB2Qz/3/yo8ine19WrWhW+R1ofyQGJTHZGrw7XbQQIpjCL2pa1H Rzef+4hGCJFakWee7FJ14dUWbg== X-Google-Smtp-Source: AH8x225SD19fCVWK0OjZMXW849N9QTSMiBFk22OfETbrlPPp8bq/icVIp0Wzf6vaE2lF6h8ZpOjVkQ== X-Received: by 10.98.242.2 with SMTP id m2mr7168020pfh.102.1518032517604; Wed, 07 Feb 2018 11:41:57 -0800 (PST) Received: from midnight.lan (2600-6c52-6200-09b7-0000-0000-0000-0d66.dhcp6.chtrptr.net. [2600:6c52:6200:9b7::d66]) by smtp.gmail.com with ESMTPSA id q24sm6136554pgn.46.2018.02.07.11.41.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 11:41:57 -0800 (PST) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Tang Junhui Subject: [PATCH 1/8] bcache: add journal statistic Date: Wed, 7 Feb 2018 11:41:39 -0800 Message-Id: <20180207194146.5095-2-mlyle@lyle.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180207194146.5095-1-mlyle@lyle.org> References: <20180207194146.5095-1-mlyle@lyle.org> 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 From: Tang Junhui Sometimes, Journal takes up a lot of CPU, we need statistics to know what's the journal is doing. So this patch provide some journal statistics: 1) reclaim: how many times the journal try to reclaim resource, usually the journal bucket or/and the pin are exhausted. 2) flush_write: how many times the journal try to flush btree node to cache device, usually the journal bucket are exhausted. 3) retry_flush_write: how many times the journal retry to flush the next btree node, usually the previous tree node have been flushed by other thread. we show these statistic by sysfs interface. Through these statistics We can totally see the status of journal module when the CPU is too high. Signed-off-by: Tang Junhui Reviewed-by: Michael Lyle --- drivers/md/bcache/bcache.h | 4 ++++ drivers/md/bcache/journal.c | 5 +++++ drivers/md/bcache/sysfs.c | 15 +++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 5e2d4e80198e..b98d7705acb6 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -658,6 +658,10 @@ struct cache_set { atomic_long_t writeback_keys_done; atomic_long_t writeback_keys_failed; + atomic_long_t reclaim; + atomic_long_t flush_write; + atomic_long_t retry_flush_write; + enum { ON_ERROR_UNREGISTER, ON_ERROR_PANIC, diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index a87165c1d8e5..f5296007a9d5 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -377,6 +377,8 @@ static void btree_flush_write(struct cache_set *c) */ struct btree *b, *best; unsigned i; + + atomic_long_inc(&c->flush_write); retry: best = NULL; @@ -397,6 +399,7 @@ static void btree_flush_write(struct cache_set *c) if (!btree_current_write(b)->journal) { mutex_unlock(&b->write_lock); /* We raced */ + atomic_long_inc(&c->retry_flush_write); goto retry; } @@ -476,6 +479,8 @@ static void journal_reclaim(struct cache_set *c) unsigned iter, n = 0; atomic_t p; + atomic_long_inc(&c->reclaim); + while (!atomic_read(&fifo_front(&c->journal.pin))) fifo_pop(&c->journal.pin, p); diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index b4184092c727..46e7a6b3e7c7 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -65,6 +65,9 @@ read_attribute(bset_tree_stats); read_attribute(state); read_attribute(cache_read_races); +read_attribute(reclaim); +read_attribute(flush_write); +read_attribute(retry_flush_write); read_attribute(writeback_keys_done); read_attribute(writeback_keys_failed); read_attribute(io_errors); @@ -545,6 +548,15 @@ SHOW(__bch_cache_set) sysfs_print(cache_read_races, atomic_long_read(&c->cache_read_races)); + sysfs_print(reclaim, + atomic_long_read(&c->reclaim)); + + sysfs_print(flush_write, + atomic_long_read(&c->flush_write)); + + sysfs_print(retry_flush_write, + atomic_long_read(&c->retry_flush_write)); + sysfs_print(writeback_keys_done, atomic_long_read(&c->writeback_keys_done)); sysfs_print(writeback_keys_failed, @@ -731,6 +743,9 @@ static struct attribute *bch_cache_set_internal_files[] = { &sysfs_bset_tree_stats, &sysfs_cache_read_races, + &sysfs_reclaim, + &sysfs_flush_write, + &sysfs_retry_flush_write, &sysfs_writeback_keys_done, &sysfs_writeback_keys_failed,