Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7597334imm; Thu, 28 Jun 2018 06:27:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKRzruFbLPgObHw2rgsTpIQsQilIAOtJxoOWpop+1hv0zZjoq6MCXrVxWSGLsruyxOq40XA X-Received: by 2002:a17:902:b488:: with SMTP id y8-v6mr10417176plr.157.1530192470099; Thu, 28 Jun 2018 06:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530192470; cv=none; d=google.com; s=arc-20160816; b=BVAqM7d2WQ27YdnDiwejsCS0SUY8vlP8pc5LNkJwwxmenw2a3kL9OhXD977H85XfZb ylg+2LIZPQ1OzZ/8pFtQPlBNxB8Mg95nfcMaykQnov1/x1+4N+OrB/LP4kk2VPVSk2+m Szr1vk+cvfcgthiX6Eb7cW9toGM7VlDaugR3pDW3Gq4WbBPKqr1852Cs3jA+K7lVXb2+ XfkFrgrYnfxFSATF3paq3oSLCpCifEujhRG12YLaBvZthtOiKl1Uu9QbUtX0qE/G9brh ed3YZZiZlpu03wU7kSRQPZuVck77hSkXWqrOKhXNmElxIFKgbu1w1+v4igN9pXfzqjtl 1UQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=u03ZkRe8Mnpsyj14RVd3xZTzCqY+k0jjh5X27jQjsDc=; b=1A60VZE1k8O+/srzZq1pv2ReTF1VeZhwpLqIqh5z0UrjNWu/b4zlPX0qQK9Pi2uN71 WlHkWTdODlgkA7aFade2MPuKqClO5UWscMrr80BeemVb5weuLme6lq2A8GN+JWuCfh/B WOM1uGWK8FHm1qnUyk6i/FOOm7q2BZdvAn6FgE6321hWzT6o9kuWSZzzdvABfV4riSq/ AuDsaJ0hyQZKy1T93x9UwWn0flM+dR6FctNpPKvEOm6B3gh8/gvlvZJkjoxUD9mjPVM4 1c0hjIyEA3+Mc32bu0yEx2TWm9HYONO0z4p81bypvxPWFqQykfamDmwaYVn0BdUbAVwX t1XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=x7EXYNzG; 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 x24-v6si6707190pln.22.2018.06.28.06.27.35; Thu, 28 Jun 2018 06:27:50 -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=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=x7EXYNzG; 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 S965966AbeF1N0x (ORCPT + 99 others); Thu, 28 Jun 2018 09:26:53 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:39352 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964921AbeF1N0v (ORCPT ); Thu, 28 Jun 2018 09:26:51 -0400 Received: by mail-qk0-f194.google.com with SMTP id f3-v6so2932524qkd.6 for ; Thu, 28 Jun 2018 06:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=u03ZkRe8Mnpsyj14RVd3xZTzCqY+k0jjh5X27jQjsDc=; b=x7EXYNzGV0vTfIyZgyjmw274iGVd/fdRo9MvfpDb8Q3Yy9KQRpIzw+LOvUxJpaakdO aH4ugelK+aJeyggiRRBnYqRnXEhaAb2PBpEwt5h4pGD4Wgymt4w8wLLTK4AQDNTTMKBo AbH4wOSqMNu3GgLLjW7IQrs4TqkSj1zap0Phy66UI9SR4lNiUtFgK3mE42bdxLW5m52l solnKnZ9lev+b54ucV8Mo9LaLifr9GhmmKjlAU6rHwhaYVIlOodwf+LLT3EyweJEyuro hBaj9g7C8kdeNNrQ91V1sDiuvxFdhLoOlzQ68ZTCGNz5yAv6shrmzYfwesNU88xg9kdz fClA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=u03ZkRe8Mnpsyj14RVd3xZTzCqY+k0jjh5X27jQjsDc=; b=suXT2eWa7cWcn1j9y2IJhxdCfwwH/B6YWIAoWXFvBZzCHX/mjUwA0wj7cmbR1iEGcp aI9nlLhw+CfILqCYuRIpxYWntlikkUigKfBqDisuLPbGI/zPpsS0MrrvF9KyWRMRZWJT bqWsANJvxQPEwoUJYGv8bftmFWOsv+vdBeSz2xVxkihBy6rPWz8q1mBMKczzClv2gPxH SZ4lvDD0zDLx0Fbuf0EhaDqSbQV729aXTV0vswsDkQzbxEdsz71GZ18LcaocYf3iYf1I 5stgjiL/0TfW3YU4hePbF/l6fy6U17lF9arSYmXwBNQaAk/7B3QGrqeclmxIL+PvWjQO ePBA== X-Gm-Message-State: APt69E2TqHLje1Bdoj+jAN3pLDMxsNLdtxyj/86pGiNVI2UUobJxcGIk 4DkxP/KH60XMHhkmmKtFWw5MmQ== X-Received: by 2002:a37:b91:: with SMTP id 139-v6mr8875422qkl.429.1530192410995; Thu, 28 Jun 2018 06:26:50 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id f9-v6sm4330111qkb.43.2018.06.28.06.26.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jun 2018 06:26:50 -0700 (PDT) Date: Thu, 28 Jun 2018 09:26:49 -0400 From: Josef Bacik To: Jens Axboe Cc: Josef Bacik , 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 Subject: Re: [PATCH 12/15] block: introduce blk-iolatency io controller Message-ID: <20180628132648.wytk67ascubysqun@destiny> References: <20180625151243.2132-1-josef@toxicpanda.com> <20180625151243.2132-13-josef@toxicpanda.com> <05a581ed-8f21-9d89-a813-a03d802d3469@kernel.dk> <20180627192046.ieqncfl6ioy37mof@destiny> <784f0862-0441-5ed2-1beb-3effa82b3438@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <784f0862-0441-5ed2-1beb-3effa82b3438@kernel.dk> User-Agent: NeoMutt/20170714 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 27, 2018 at 01:24:55PM -0600, Jens Axboe wrote: > 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. > This isn't how it works though. You aren't removed from the list until you do finish_wait(), so you don't lose your spot on the list. We only get added to the end of the list if if (list_empty(&wq_entry->entry)) otherwise nothing changes. > 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. Ah yeah that's a good point, I'll go back to using what you had to catch that case. Thanks, Josef