From patchwork Fri Jan 11 11:07:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 1023512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43bg8Q2Khrz9sCh; Fri, 11 Jan 2019 22:08:22 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ghufg-00073r-Au; Fri, 11 Jan 2019 11:08:16 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1ghufe-00072R-51 for kernel-team@lists.ubuntu.com; Fri, 11 Jan 2019 11:08:14 +0000 Received: from mail-qt1-f200.google.com ([209.85.160.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ghufd-0004t4-Qq for kernel-team@lists.ubuntu.com; Fri, 11 Jan 2019 11:08:13 +0000 Received: by mail-qt1-f200.google.com with SMTP id b16so15969301qtc.22 for ; Fri, 11 Jan 2019 03:08:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=MddJ+UxxA2K3kBbz9rxuhkA5GeHGKg7Cag2vTJn7Cxg=; b=F5SMP7VCiRtEW1gXm12uCHfdu1i/H1UeJPEETOIkj3k5YkM0ffnMwE+dLnLgJdWETQ hVswomsiFRfr6IVF9MbYtSNPXNqB5mwFeibu3O6ETjkHDB1vBYLyK7t6H4J+CXEttJ3a 1YStScWYAOrWsajsjc/Cx1W7hjrXIE4Efgcr/OA2XIujxakdeqsIMVwWYDoHQYJHDn8H dhXNEpPiFpQ9J/sBNwaw5/m7oz+dDILDec2vgSqZd7kqzmhjow61INM8/4KAQMfNRKDv uPkOqTG2FNvoXB679VsB+r88WSV1QuZiKP5Dsw+aLW/d8esFzeDW45KODEP+rOury1fs n2Rg== X-Gm-Message-State: AJcUukdLg7rzWF3BqIlLrobVNOX4TkldLPZF2VqNuodXUVYK9XV0u/76 N9sfuxmY9pcE/cVzFlbHmErXF47extFYSk9rb5xVgoeyt2NU7k+5O0lxNc7fhGq5+VpnxNnQkkj t/J+p329vcQoPbGww+ufGygwj/I4Uqe6bVXLMPAVDdQ== X-Received: by 2002:a0c:c138:: with SMTP id f53mr13463689qvh.225.1547204892854; Fri, 11 Jan 2019 03:08:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ZxVxeJaOEkYTk+honAoDi6+SKtHyZfzs7Elr5NEt0T9u+OssMzc0CodtQecSddH33HCCpEQ== X-Received: by 2002:a0c:c138:: with SMTP id f53mr13463681qvh.225.1547204892705; Fri, 11 Jan 2019 03:08:12 -0800 (PST) Received: from localhost.localdomain ([177.181.227.3]) by smtp.gmail.com with ESMTPSA id o65sm39280460qkl.11.2019.01.11.03.08.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:08:12 -0800 (PST) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [SRU B][PATCH v2 3/7] blk-wbt: move disable check into get_limit() Date: Fri, 11 Jan 2019 09:07:53 -0200 Message-Id: <20190111110757.17936-4-mfo@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190111110757.17936-1-mfo@canonical.com> References: <20190111110757.17936-1-mfo@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jens Axboe BugLink: https://bugs.launchpad.net/bugs/1810998 Check it in one place, instead of in multiple places. Tested-by: Anchal Agarwal Signed-off-by: Jens Axboe (backported from commit ffa358dcaae1f2f00926484e712e06daa8953cb4) [mfo: backport: - blk-wbt.c: - hunk 1: refresh lower context lines due to lack of commit 782f569774d7 ("blk-wbt: throttle discards like background writes"), not required / introduces a new thing/behavior.] - hunk 2: s/rq_wait_inc_below(rqw/atomic_inc_below(&rqw->inflight/ - hunk 3: s/rq_wait_inc_below(rqw/atomic_inc_below(&rqw->inflight/ Signed-off-by: Mauricio Faria de Oliveira --- block/blk-wbt.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 145f192a8007..0d3c01cfe30c 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -483,6 +483,13 @@ static inline unsigned int get_limit(struct rq_wb *rwb, unsigned long rw) { unsigned int limit; + /* + * If we got disabled, just return UINT_MAX. This ensures that + * we'll properly inc a new IO, and dec+wakeup at the end. + */ + if (!rwb_enabled(rwb)) + return UINT_MAX; + /* * At this point we know it's a buffered write. If this is * kswapd trying to free memory, or REQ_SYNC is set, then @@ -517,16 +524,6 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct, struct rq_wait *rqw = get_rq_wait(rwb, wb_acct); DECLARE_WAITQUEUE(wait, current); - /* - * inc it here even if disabled, since we'll dec it at completion. - * this only happens if the task was sleeping in __wbt_wait(), - * and someone turned it off at the same time. - */ - if (!rwb_enabled(rwb)) { - atomic_inc(&rqw->inflight); - return; - } - if (!waitqueue_active(&rqw->wait) && atomic_inc_below(&rqw->inflight, get_limit(rwb, rw))) return; @@ -535,11 +532,6 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct, do { set_current_state(TASK_UNINTERRUPTIBLE); - if (!rwb_enabled(rwb)) { - atomic_inc(&rqw->inflight); - break; - } - if (atomic_inc_below(&rqw->inflight, get_limit(rwb, rw))) break;