From patchwork Thu Jun 9 21:41:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9168233 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 B41ED60467 for ; Thu, 9 Jun 2016 21:41:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5C1C26E1A for ; Thu, 9 Jun 2016 21:41:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98FC22832A; Thu, 9 Jun 2016 21:41:54 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 F3F4726E1A for ; Thu, 9 Jun 2016 21:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752075AbcFIVlt (ORCPT ); Thu, 9 Jun 2016 17:41:49 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:36199 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751742AbcFIVls (ORCPT ); Thu, 9 Jun 2016 17:41:48 -0400 Received: by mail-it0-f53.google.com with SMTP id a5so49262386ita.1 for ; Thu, 09 Jun 2016 14:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=GHTVJ/7+hPASzCddD92GB2Ygj/j1hIEVdy3a9cwICqo=; b=UdFC+CBRQEkRhAPRODfFtpd3KaNOB06oIpbL4ePnoOElwoOzTGamLLeMDMuS6CBXgk 0qY/xVeZMKyI+2mLNTsHF7CggDRNVaJO307TJVdXgylOVrTPcQyQeYW2kbqTGh5c9ZCv +0xfBKjYtnQSCu2aYQ6vOPnemvcLPw+07FHYud90xyiZPtRJBH/lpE80sM853rJx1UWd fo9mHet5TDeQak0pr68xrO3W7R1375g4zW1Uh+Ft7myov0yEi3ovGffP7IfPcqw79Qk9 kxYY0dYUEBufxnc7E1E47+TUeAJLEz30bchi07VZn17GOOC1UHdJ3Gtn2bQtzXlAmuo9 9Tgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=GHTVJ/7+hPASzCddD92GB2Ygj/j1hIEVdy3a9cwICqo=; b=McFvB2bZKwPzLdPtzTnP1QjMfUgRzVIvfu4ICQjXp8vWszg6KRFG5hQHxnkpOgv8zz 40kbXg44qwlpHQa9LlWJTYAKcBVe8X9jqQWWnVQ8ICdJXZjR8mfW6qMCGVmkS14rkaDv 9uYF7w344ajV/Y6nb0fZytkyDTKJt7GV1Gxt/kpEEijVkMM5+eRHQ8LvqV30D+N7Sy6l ZTdji2OxJmYZNSkm/9p4tAJ75lyGYbIB63KIVYkPGUWuBnixHqpTGfUcq8qexlUP4QtM BlblWbm+vOquwlFVv11wsbcEjkhWUyWJyRg+ijUi1vLjBlPv5ZhZaQy+jOAMo9SuFnRE 88Vw== X-Gm-Message-State: ALyK8tID164VBdsdqCjWGw8spM7d++j17eb+cRxOA9C7QqLIvDFV2hlWh82Gh/8UUVvJbg== X-Received: by 10.36.26.134 with SMTP id 128mr26670523iti.28.1465508506854; Thu, 09 Jun 2016 14:41:46 -0700 (PDT) Received: from [192.168.1.130] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id o68sm14461783itc.0.2016.06.09.14.41.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 14:41:46 -0700 (PDT) Subject: Re: [PATCH] cfq: priority boost on meta/prio marked IO To: Jeff Moyer , Jens Axboe References: <20160608204347.GA30146@kernel.dk> <5759E177.9040307@kernel.dk> Cc: linux-block@vger.kernel.org From: Jens Axboe Message-ID: <5759E299.2060200@kernel.dk> Date: Thu, 9 Jun 2016 15:41:45 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <5759E177.9040307@kernel.dk> 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 On 06/09/2016 03:36 PM, Jens Axboe wrote: > On 06/09/2016 03:28 PM, Jeff Moyer wrote: >> Jens Axboe writes: >> >>> At Facebook, we have a number of cases where people use ionice to set a >>> lower priority, then end up having tasks stuck for a long time because >>> eg meta data updates from an idle priority tasks is blocking out higher >>> priority processes. It's bad enough that it will trigger the softlockup >>> warning. >>> >>> This patch adds code to CFQ that bumps the priority class and data for >>> an idle task, if is doing IO marked as PRIO or META. With this, we no >>> longer see the softlockups. >>> >>> Signed-off-by: Jens Axboe >>> >>> diff --git a/block/blk-core.c b/block/blk-core.c >>> index 32a283eb7274..3cfd67d006fb 100644 >>> --- a/block/blk-core.c >>> +++ b/block/blk-core.c >>> @@ -1781,6 +1781,11 @@ get_rq: >>> rw_flags |= REQ_SYNC; >>> >>> /* >>> + * Add in META/PRIO flags, if set, before we get to the IO >>> scheduler >>> + */ >>> + rw_flags |= (bio->bi_rw & (REQ_META | REQ_PRIO)); >>> + >>> + /* >> >> This needs a docbook update. It now reads: >> >> * @rw_flags: RW and SYNC flags >> >> so whatever flags we're adding should be specified, I guess. >> >> Speaking of which, after much waffling, I think I've decided it would be >> cleaner to limit the priority boost to REQ_PRIO requests only. > > I went and checked, but I don't see it. Where is this? Ah now I see, you're looking at current -git. The patch is against for-4.8/core. Updated version below, dropping REQ_META and changing the naming s/meta/prio. @@ -4295,6 +4296,20 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq) cfq_schedule_dispatch(cfqd); } +static void cfqq_boost_on_prio(struct cfq_queue *cfqq, int op_flags) +{ + if (!(op_flags & REQ_PRIO)) { + cfqq->ioprio_class = cfqq->org_ioprio_class; + cfqq->ioprio = cfqq->org_ioprio; + return; + } + + if (cfq_class_idle(cfqq)) + cfqq->ioprio_class = IOPRIO_CLASS_BE; + if (cfqq->ioprio > IOPRIO_NORM) + cfqq->ioprio = IOPRIO_NORM; +} + static inline int __cfq_may_queue(struct cfq_queue *cfqq) { if (cfq_cfqq_wait_request(cfqq) && !cfq_cfqq_must_alloc_slice(cfqq)) { @@ -4325,6 +4340,7 @@ static int cfq_may_queue(struct request_queue *q, int op, int op_flags) cfqq = cic_to_cfqq(cic, rw_is_sync(op, op_flags)); if (cfqq) { cfq_init_prio_data(cfqq, cic); + cfqq_boost_on_prio(cfqq, op_flags); return __cfq_may_queue(cfqq); } Reviewed-by: Jeff Moyer diff --git a/block/blk-core.c b/block/blk-core.c index 32a283eb7274..3cfd67d006fb 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1781,6 +1781,11 @@ get_rq: rw_flags |= REQ_SYNC; /* + * Add in META/PRIO flags, if set, before we get to the IO scheduler + */ + rw_flags |= (bio->bi_rw & (REQ_META | REQ_PRIO)); + + /* * Grab a free request. This is might sleep but can not fail. * Returns with the queue unlocked. */ diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 4e5978426ee7..f2955c41a306 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -141,7 +141,7 @@ struct cfq_queue { /* io prio of this group */ unsigned short ioprio, org_ioprio; - unsigned short ioprio_class; + unsigned short ioprio_class, org_ioprio_class; pid_t pid; @@ -3700,6 +3700,7 @@ static void cfq_init_prio_data(struct cfq_queue *cfqq, struct cfq_io_cq *cic) * elevate the priority of this queue */ cfqq->org_ioprio = cfqq->ioprio; + cfqq->org_ioprio_class = cfqq->ioprio_class; cfq_clear_cfqq_prio_changed(cfqq); }