Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6796048imm; Wed, 27 Jun 2018 13:35:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKGTw4Gls76gw5Tkmad252iULv30v/iGLhyh6mLSb7XxfsmDLSwnC1RM1lU5w+PPQ04u/og X-Received: by 2002:a63:686:: with SMTP id 128-v6mr6364408pgg.338.1530131758680; Wed, 27 Jun 2018 13:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530131758; cv=none; d=google.com; s=arc-20160816; b=wkI2uVST4KIC5QP70iMlX/dee0wUCc6OcbHXpap4AXReHPd79l6SMAxO+TovjlKEeu kRCP4V3ZGSe86JRw52JcRVgxeXh/mJJbyzZOTgiSaF38AvQO7OQp77UfaCf/lYv9xKPK dj7N+TZOu/UfCEfOJ5ScpbIPeMG74PgCRSrDNYEeak/bHwDYHjkzT2GJrNNFCmUT9gWk Qyig7SgmcT5FYAqAcRb3OFutgHQK2OuvWOVZ60nJXyYOx8Lrh8TrFVPNHTSpBN+Ozac6 synN9+IS8FuEnz5E6y/wF58C0eJFG2+j0U0VCSwGjlxkIOLBxhhj/iN5YZ/fYUulhFFq L9zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=xRPfvk3q8fAABxM/Oo8y57EZKXOQJ1gWCmDX8CSfIv4=; b=HC01PB64d5ZrwKDO9FRUILOXg+Fsy0BvV52ZjtUXAAXB1YmdEtBSYubduQgsimb3X6 9V0YzJOqRZIrx8ZzYzgoAozTQ8o2xBPx7CLKOLxriqUeDl22qgrVVBatQzURv+uUYXsn n41XB4fzISN+pLcyWmYnZCiyAQGw/YC9ShVwJSZ+ot/shCDUF15rF71FhxcrsBiaD2Vt EbrfYmcEcgWYCqmkxulRYynlGjGpD7Ad2M0XgQ05rybKZ5lYVOfTerghg1pDGAb5a8ng w86TrxmgJRQFpJPKgUTT4Y7uetg9j5EfWROiThXVlTYIFnQMxw9CbBAtkIL1Ka7p0e62 zAkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=HgWw+kIG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20-v6si4367329pgb.92.2018.06.27.13.35.44; Wed, 27 Jun 2018 13:35:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=HgWw+kIG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934027AbeF0TZA (ORCPT + 99 others); Wed, 27 Jun 2018 15:25:00 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:38164 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934833AbeF0TY7 (ORCPT ); Wed, 27 Jun 2018 15:24:59 -0400 Received: by mail-it0-f68.google.com with SMTP id v83-v6so9047584itc.3 for ; Wed, 27 Jun 2018 12:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xRPfvk3q8fAABxM/Oo8y57EZKXOQJ1gWCmDX8CSfIv4=; b=HgWw+kIGjj/nMeN1vN4Jvux0e4QPEquNAARtaFKiFwkoOpMfOqvMV9yTK+hVUuJo9U UNchVNpzuUnvoOdqqmoU+gARIogFw9FZPsbnKxgEOy3EpfLN0ypKn9G3JIqX1FSQ2TlE r+9re6c/ast6bky+rgGKO1rN34D784DXne3HJHQjYScNds2L6qZHTvlJqfK0W3AYi+6h vA/5B0hj0FcIkTMcoCuXEJkmuOA+9rmtHnVWxx9Na3W7PaRbi9Am871V9ya4o4yJHppF SyyTBDFDk46ir112RmkgYlLwYqk6cijdZHiK2/XTxB9kw11DDvJb5jzD+6Zg/s2IeZQ3 0B2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xRPfvk3q8fAABxM/Oo8y57EZKXOQJ1gWCmDX8CSfIv4=; b=tgD1MQilaypQ8Kou7cD9DAkowphqNn4V6vQIXEyd+85dkkxEBBoTWUAyXh0AtUq7Cv +m6mhX5alkPqt3LaNPbTEHI68VSYtjasBa8+XVybp2Wc1DRJmqPNqAf44FLM0ALy1056 NwSjEzBgU6JBZvuCZqzjnxk/0GtX5OhK2pGJzUAxP0mIJQ+iWqpYH/qcZd9+OoOIebKM 84PXLdDF+jNOn+uDtfc/49Ln6woIf4J7eoy3uKI8cnNAFGlpH044Q+8RAmyL+/llYBt3 73/fCrc5fJCeppTZW+SFtp2Swli/QoBbFVAL3b/Y+BTBFbf91CFV7YWAxVch6pEE7YNu vxVw== X-Gm-Message-State: APt69E1zQGUqtP5RxNwP+4DPYABGbXnrFQLZEiD8M9+nIj+J49/tZA4o e3hVtj/L/9Dny3RZZrbqeqC7tQ== X-Received: by 2002:a02:45cd:: with SMTP id o74-v6mr5854775jad.43.1530127498060; Wed, 27 Jun 2018 12:24:58 -0700 (PDT) Received: from [192.168.1.212] (107.191.0.158.static.utbb.net. [107.191.0.158]) by smtp.gmail.com with ESMTPSA id j11-v6sm2816423itb.16.2018.06.27.12.24.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 12:24:56 -0700 (PDT) Subject: Re: [PATCH 12/15] block: introduce blk-iolatency io controller To: Josef Bacik Cc: linux-block@vger.kernel.org, kernel-team@fb.com, akpm@linux-foundation.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, linux-fsdevel@vger.kernel.org, Josef Bacik References: <20180625151243.2132-1-josef@toxicpanda.com> <20180625151243.2132-13-josef@toxicpanda.com> <05a581ed-8f21-9d89-a813-a03d802d3469@kernel.dk> <20180627192046.ieqncfl6ioy37mof@destiny> From: Jens Axboe Message-ID: <784f0862-0441-5ed2-1beb-3effa82b3438@kernel.dk> Date: Wed, 27 Jun 2018 13:24:55 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180627192046.ieqncfl6ioy37mof@destiny> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/27/18 1:20 PM, Josef Bacik wrote: > On Wed, Jun 27, 2018 at 01:06:31PM -0600, Jens Axboe wrote: >> On 6/25/18 9:12 AM, Josef Bacik wrote: >>> +static void __blkcg_iolatency_throttle(struct rq_qos *rqos, >>> + struct iolatency_grp *iolat, >>> + spinlock_t *lock, bool issue_as_root, >>> + bool use_memdelay) >>> + __releases(lock) >>> + __acquires(lock) >>> +{ >>> + struct rq_wait *rqw = &iolat->rq_wait; >>> + unsigned use_delay = atomic_read(&lat_to_blkg(iolat)->use_delay); >>> + DEFINE_WAIT(wait); >>> + bool first_block = true; >>> + >>> + if (use_delay) >>> + blkcg_schedule_throttle(rqos->q, use_memdelay); >>> + >>> + /* >>> + * To avoid priority inversions we want to just take a slot if we are >>> + * issuing as root. If we're being killed off there's no point in >>> + * delaying things, we may have been killed by OOM so throttling may >>> + * make recovery take even longer, so just let the IO's through so the >>> + * task can go away. >>> + */ >>> + if (issue_as_root || fatal_signal_pending(current)) { >>> + atomic_inc(&rqw->inflight); >>> + return; >>> + } >>> + >>> + if (iolatency_may_queue(iolat, &wait, first_block)) >>> + return; >>> + >>> + do { >>> + prepare_to_wait_exclusive(&rqw->wait, &wait, >>> + TASK_UNINTERRUPTIBLE); >>> + >>> + iolatency_may_queue(iolat, &wait, first_block); >>> + first_block = false; >>> + >>> + if (lock) { >>> + spin_unlock_irq(lock); >>> + io_schedule(); >>> + spin_lock_irq(lock); >>> + } else { >>> + io_schedule(); >>> + } >>> + } while (1); >> >> So how does this wait loop ever exit? >> > > Sigh, I cleaned this up from what we're using in production and did it poorly, > I'll fix it up. Thanks, Also may want to consider NOT using exclusive add if first_block == false, as you'll end up at the tail of the waitqueue after sleeping and being denied. This is similar to the wbt change I posted last week. For may_queue(), your wq_has_sleeper() is also going to be always true inside your loop, since you call it after doing the prepare_to_wait() which adds you to the queue. That's why wbt does the list checks, but it'd be nicer to have a wq_has_other_sleepers() for that. So your first iolatency_may_queue() inside the loop will always be false. -- Jens Axboe