From patchwork Fri Jan 25 00:12:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10780321 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 D982B91E for ; Fri, 25 Jan 2019 00:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA0532F802 for ; Fri, 25 Jan 2019 00:13:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDECA2F81A; Fri, 25 Jan 2019 00:13:11 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 660032F802 for ; Fri, 25 Jan 2019 00:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbfAYANK (ORCPT ); Thu, 24 Jan 2019 19:13:10 -0500 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:59807 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbfAYANK (ORCPT ); Thu, 24 Jan 2019 19:13:10 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=bo.liu@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0TIwmQ-K_1548375188; Received: from localhost(mailfrom:bo.liu@linux.alibaba.com fp:SMTPD_---0TIwmQ-K_1548375188) by smtp.aliyun-inc.com(127.0.0.1); Fri, 25 Jan 2019 08:13:08 +0800 From: Liu Bo To: linux-block@vger.kernel.org Cc: Josef Bacik , Jens Axboe Subject: [PATCH v2 2/3] Blk-iolatency: warn on negative inflight IO counter Date: Fri, 25 Jan 2019 08:12:48 +0800 Message-Id: <20190125001249.72688-3-bo.liu@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb6 In-Reply-To: <20190125001249.72688-1-bo.liu@linux.alibaba.com> References: <20190125001249.72688-1-bo.liu@linux.alibaba.com> MIME-Version: 1.0 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 This is to catch any unexpected negative value of inflight IO counter. Signed-off-by: Liu Bo --- block/blk-iolatency.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 1893686a9c1f..2620baa1f699 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -592,6 +592,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) u64 now = ktime_to_ns(ktime_get()); bool issue_as_root = bio_issue_as_root_blkg(bio); bool enabled = false; + int inflight = 0; blkg = bio->bi_blkg; if (!blkg || !bio_flagged(bio, BIO_TRACKED)) @@ -613,7 +614,8 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) } rqw = &iolat->rq_wait; - atomic_dec(&rqw->inflight); + inflight = atomic_dec_return(&rqw->inflight); + WARN_ON_ONCE(inflight < 0); if (iolat->min_lat_nsec == 0) goto next; iolatency_record_time(iolat, &bio->bi_issue, now,