Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1483196ybi; Sat, 27 Jul 2019 10:40:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOxrdePCmFduKUqO3+E2VUjJ02cOWbsxtl99saQ+l9gsZ7l7bnPTL8PwRYTce1avub2Z8t X-Received: by 2002:a62:fb18:: with SMTP id x24mr27669298pfm.231.1564249248303; Sat, 27 Jul 2019 10:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564249248; cv=none; d=google.com; s=arc-20160816; b=DlCRcGwdksgsiVcGLCI3BiAlZiXpsU1B9y8tF0ERTy70m/oKuKh8+gV0UxRvc0tQ4W yIA6HV2dTc2o+znzIn+ot5z4JMTUCnzX2i/X6d45qrkguKl5PISzmwlVK+BIBoa7n6WC QwYdV+TKAqYtmxTHUAcdSkK6GzuSk1ZA3Yjb17uFVos1OfcH5dMFmGgCl+dWZUpzyzaI Z03Ofr7Ds3od/ycvRjsR7mIMWcA/EJC8piw63m4DLtmur6SHrzEHBOcVioe4t+efhUy7 yS/RBEvuvPu5vL7YWO+HyiCWihobLP5PGICEpR6GKKKnx1bU+V5bxMWEby+3prOv0qSD H37A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FxuNjFEA7s07C73APXQQNAta426oIXYom1FUbQczxhw=; b=IxYCjMQF5zdmzswzY4Z7TSb5hfW1rNvWny707LMSYKqOiOYB3AwgAmPf/14sJsAPg1 ATVVEEq9CC2WATWzpZM78dHhWKyloyr+VW795kG7yOI2XbG1BxN7xnlVsa48XHzTNe4g ensUB6Jl5dt3D2sQZyQOO61UDjo3wKGWoDFO01AJw0roLQgIKFwpPycXLcfRTSShb5t5 JZtAJLVVKn5bWk4u+jj6fr6o7JEXZzUzRsa0+n4kSAAinHncIalqHF6fKqcbU9uxWLVx KZntyzaw5Bb4hkhc2CD6MYqHj6N5b4EOK5BOlHNx7+DsxW18n2j0VVZodEZJYZmJvLp4 UCSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P118mdqt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r33si28141292pgm.371.2019.07.27.10.40.33; Sat, 27 Jul 2019 10:40:48 -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=@chromium.org header.s=google header.b=P118mdqt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388029AbfG0RiP (ORCPT + 99 others); Sat, 27 Jul 2019 13:38:15 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:44184 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387856AbfG0RiP (ORCPT ); Sat, 27 Jul 2019 13:38:15 -0400 Received: by mail-io1-f68.google.com with SMTP id s7so111253653iob.11 for ; Sat, 27 Jul 2019 10:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FxuNjFEA7s07C73APXQQNAta426oIXYom1FUbQczxhw=; b=P118mdqtL3CISSKDME3yit/FU9M8ypTF8xHVnp2a9Yup3YhcYXMS74ai0jUKBP3yIN GiUzFZoan4DR4QjDabidqUZnhIGnlj68IN+bCTQHVANJlKtwprPgM3f8DGezqFyUm97k Mh+PJLGZhGI+2gCBl6sFKQeXoWbs2M7VW+F90= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FxuNjFEA7s07C73APXQQNAta426oIXYom1FUbQczxhw=; b=TbLr/sIhPuHV1FRF4TrrtMyrYF45KdMih0bYynP5CYMwe5t4N1rMo1mvs9xWgrxF2Y Atx0wvaUff2D5LlxrSCijNl3bdxmlz6v2HJ9vGfSnGzvWj960WlbfMGMHQmTCxnU69fb D8Vl7J7b2CimiWVVjfCyRu1CEbg1ltyK1otofVjsW2zuGpyeve21eY0xG/DgPP2AJUDa kXhVKBzqQobXvFP+VRR+sKXKk3dTJe6575w9OZnRLv/QVw2dKYyttHkawTgZIM8RaoCu 1TLNpaNqCkrS0wMVkJ9drAaUJ3AH2fWHymOyvY8ybQHnM3eKrP2BvEP4FJyqAL3VJ48K 5E+Q== X-Gm-Message-State: APjAAAVdr9sSgt+gZaODEplzEAURzLrUdDQ/ubVsto+zVDz/ciWMmSng D57BJ27ysslbaqWuhMV/29aUzHw0Nms= X-Received: by 2002:a5d:94d0:: with SMTP id y16mr55669628ior.123.1564249094029; Sat, 27 Jul 2019 10:38:14 -0700 (PDT) Received: from mail-io1-f49.google.com (mail-io1-f49.google.com. [209.85.166.49]) by smtp.gmail.com with ESMTPSA id e84sm67659990iof.39.2019.07.27.10.38.12 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jul 2019 10:38:12 -0700 (PDT) Received: by mail-io1-f49.google.com with SMTP id q22so1688695iog.4 for ; Sat, 27 Jul 2019 10:38:12 -0700 (PDT) X-Received: by 2002:a6b:5103:: with SMTP id f3mr88917182iob.142.1564249092231; Sat, 27 Jul 2019 10:38:12 -0700 (PDT) MIME-Version: 1.0 References: <20190625051249.39265-1-paolo.valente@linaro.org> <20190625051249.39265-6-paolo.valente@linaro.org> In-Reply-To: <20190625051249.39265-6-paolo.valente@linaro.org> From: Doug Anderson Date: Sat, 27 Jul 2019 10:38:00 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH BUGFIX IMPROVEMENT V2 5/7] block, bfq: detect wakers and unconditionally inject their I/O To: Paolo Valente Cc: Jens Axboe , linux-block@vger.kernel.org, LKML , Ulf Hansson , LinusW , bfq-iosched@googlegroups.com, oleksandr@natalenko.name, bottura.nicola95@gmail.com, srivatsa@csail.mit.edu, Guenter Roeck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Jun 24, 2019 at 10:13 PM Paolo Valente wrote: > > A bfq_queue Q may happen to be synchronized with another > bfq_queue Q2, i.e., the I/O of Q2 may need to be completed for Q to > receive new I/O. We call Q2 "waker queue". > > If I/O plugging is being performed for Q, and Q is not receiving any > more I/O because of the above synchronization, then, thanks to BFQ's > injection mechanism, the waker queue is likely to get served before > the I/O-plugging timeout fires. > > Unfortunately, this fact may not be sufficient to guarantee a high > throughput during the I/O plugging, because the inject limit for Q may > be too low to guarantee a lot of injected I/O. In addition, the > duration of the plugging, i.e., the time before Q finally receives new > I/O, may not be minimized, because the waker queue may happen to be > served only after other queues. > > To address these issues, this commit introduces the explicit detection > of the waker queue, and the unconditional injection of a pending I/O > request of the waker queue on each invocation of > bfq_dispatch_request(). > > One may be concerned that this systematic injection of I/O from the > waker queue delays the service of Q's I/O. Fortunately, it doesn't. On > the contrary, next Q's I/O is brought forward dramatically, for it is > not blocked for milliseconds. > > Reported-by: Srivatsa S. Bhat (VMware) > Tested-by: Srivatsa S. Bhat (VMware) > Signed-off-by: Paolo Valente > --- > block/bfq-iosched.c | 270 ++++++++++++++++++++++++++++++++++++++------ > block/bfq-iosched.h | 25 +++- > 2 files changed, 261 insertions(+), 34 deletions(-) FYI that there is some evidence that this commit, which landed as commit 13a857a4c4e8 ("block, bfq: detect wakers and unconditionally inject their I/O"), is causing use-after-frees, as identified by using slub_debug and/or KASAN. If folks are willing to follow a link to the Chrome OS bug tracker, you can find more details starting at: https://bugs.chromium.org/p/chromium/issues/detail?id=931295#c46 The most relevant part from that discussion so far is that one crash can be seen in bfq_exit_icq_bfqq(): /* reset waker for all queues in woken list */ hlist_for_each_entry_safe(item, n, &bfqq->woken_list, woken_list_node) { item->waker_bfqq = NULL; bfq_clear_bfqq_has_waker(item); ==> hlist_del_init(&item->woken_list_node); } ...where "item" has already been freed. Hopefully Paolo has some ideas here since I'm not sure I'll be able to do any more detailed debugging in the short term. Happy to throw on a test patch and re-start tests though. -Doug