Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1641044ybb; Sat, 21 Mar 2020 02:46:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtrh2RJsGRkGknp7DU2RRQHUtj1AfdSJued5DwG7T7LYldjerCglmP9u7hag0w0TfLFLM51 X-Received: by 2002:aca:4cd8:: with SMTP id z207mr9591952oia.155.1584783962087; Sat, 21 Mar 2020 02:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584783962; cv=none; d=google.com; s=arc-20160816; b=tpRuNr5hZzO/mId5PrMTtpnau36l9VD6+rYOz6fYn56Gj7hXKspTrCJGpkSblijtdk lw8spGrBNi24kAfKJIbf9jd8iRl7qpEv0kQxQ7+Uqajmr332Wk0bJq+kb6Lg5E2GGKyK OEiv2zJF+bpeNOZvchMZRJ/N1VNcyeesalmXW5uTG1XepoQUhjzj1mXL31a/wj8ccqPB 3676o/Rnt+dOt2oFb0cwnimemJ9zuRk1AUMEWrZagdDItH4Dv259EhKbOvlrvigqCdoc tk4BAcbW+VLGIYN3XLooDVBLA2lHE2wed28HycxD2gDCBo4m/Vmhv1wRUsXSJmR8lCg8 bbTw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p07172ZoAYLhgL8MhlQdQDPQm1FytxKJ4TUV9O0POto=; b=fwF4bDr2HMrIWUoiRDX1h2bhUzkXhAYMCHAD+04qTelC9qshafHvt7LPNrCblJN/yt TdzfUJxC4Iim0ugyiYx8kj2jDQmDTCg5eWlg5ZmFsY1ShVtx7AzCXmFkAq/l9g5Y51hg +u9+qYVa+qz4lo0xD5i0tk3KTWYja7mh9dgDtTT0lDE5qjFwaEMvXIojzSIIaejN5raM bygwY+CRZO63/3BEpeNIJ4sRb6DltzS7FYj9biacK+6oEin4snRqp4oKnW5yIcAzuAAF gQwsPxQtSTK8WbNp7sXmUW8b1A/fFHfNEbwKBb6/Dh0LJJZpZlqHtBTj5w643IqHI73y Ld0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zdXLpXQc; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19si4477446otp.98.2020.03.21.02.45.51; Sat, 21 Mar 2020 02:46:02 -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=@linaro.org header.s=google header.b=zdXLpXQc; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbgCUJpX (ORCPT + 99 others); Sat, 21 Mar 2020 05:45:23 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39944 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728426AbgCUJpU (ORCPT ); Sat, 21 Mar 2020 05:45:20 -0400 Received: by mail-wm1-f66.google.com with SMTP id a81so3161844wmf.5 for ; Sat, 21 Mar 2020 02:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p07172ZoAYLhgL8MhlQdQDPQm1FytxKJ4TUV9O0POto=; b=zdXLpXQcmYSY7ZbBRXUOXbyjJ6V4owIHKwkhSp5juYJCLE0AaXgek+6PXgKKrLdwwd 2X6dU/PbshRwWKHUipBZ0UKJmMpzKbJQN9fW44JFPIDGQZ2i8NAImsWRN0w/gQt9M6LY LWqA1VNcWBXl7WtBw6nsN5in5dKCG/zWK2LzR/cOQmZenyrQmRjh+wp5lTfDqzaAQEH+ xdOQ/VOSghP5CeLTG5s7/hMnz1b25ZPKBf0FDc3u1Cfz7Vfsfi9/BB8FJKGwXAEL2yuD K+0Y88lobxoddQ/vTyjNKI4f1b3eCjAPzXNlVjH3z3A5MvCFm54LaRS6Jcd6IBb3/qZL FgOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p07172ZoAYLhgL8MhlQdQDPQm1FytxKJ4TUV9O0POto=; b=qCjf0Kz11LoaZRhSB/hUnUoJA26sHh1MsBBPpegcWbzUNpNJlSL4CD7yfFYF09LY+J H5KuM6yjQUSYfZhK4EIS/VHqAXt/GTizC60PVtS+CYDCJdRnxl6SdFeDLxRpAQ8VIXxH R7R8NGBFU9IcgpTkD0U7wIVi4cYJEbzLDjj4I5uBYhrNduDipYeToFmeYmjndCaMoiI6 Rb8UJxgQ3cWcHmlfDEmucnSXtZjMgsoXCNIVhBd/eeGIshFclIefKqJufknZJhL7Id7g 5isBcMqv27vr17ilaLEdMUiscV87V1+oDx9pyxDpkunEoxY5ELyr0Ytvej+Qhdac0hQV OSfQ== X-Gm-Message-State: ANhLgQ24OVHF10GA4lzhzir+zbk+Hrn1SLcMlDF+d7WvH+rbEopBZXas VOl9IMj/swhqjgA9S8H1xEpbgA== X-Received: by 2002:a1c:7209:: with SMTP id n9mr15153060wmc.188.1584783918623; Sat, 21 Mar 2020 02:45:18 -0700 (PDT) Received: from localhost.localdomain ([84.33.129.193]) by smtp.gmail.com with ESMTPSA id z203sm5396378wmg.12.2020.03.21.02.45.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Mar 2020 02:45:17 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, rasibley@redhat.com, vkabatov@redhat.com, xzhou@redhat.com, jstancek@redhat.com, Paolo Valente , cki-project@redhat.com Subject: [PATCH BUGFIX 4/4] block, bfq: invoke flush_idle_tree after reparent_active_queues in pd_offline Date: Sat, 21 Mar 2020 10:45:21 +0100 Message-Id: <20200321094521.85986-5-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200321094521.85986-1-paolo.valente@linaro.org> References: <20200321094521.85986-1-paolo.valente@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In bfq_pd_offline(), the function bfq_flush_idle_tree() is invoked to flush the rb tree that contains all idle entities belonging to the pd (cgroup) being destroyed. In particular, bfq_flush_idle_tree() is invoked before bfq_reparent_active_queues(). Yet the latter may happen to add some entities to the idle tree. It happens if, in some of the calls to bfq_bfqq_move() performed by bfq_reparent_active_queues(), the queue to move is empty and gets expired. This commit simply reverses the invocation order between bfq_flush_idle_tree() and bfq_reparent_active_queues(). Tested-by: cki-project@redhat.com Signed-off-by: Paolo Valente --- block/bfq-cgroup.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index efb89db7ba24..68882b9b8f11 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -893,13 +893,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd) for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) { st = bfqg->sched_data.service_tree + i; - /* - * The idle tree may still contain bfq_queues belonging - * to exited task because they never migrated to a different - * cgroup from the one being destroyed now. - */ - bfq_flush_idle_tree(st); - /* * It may happen that some queues are still active * (busy) upon group destruction (if the corresponding @@ -913,6 +906,19 @@ static void bfq_pd_offline(struct blkg_policy_data *pd) * scheduler has taken no reference. */ bfq_reparent_active_queues(bfqd, bfqg, st, i); + + /* + * The idle tree may still contain bfq_queues + * belonging to exited task because they never + * migrated to a different cgroup from the one being + * destroyed now. In addition, even + * bfq_reparent_active_queues() may happen to add some + * entities to the idle tree. It happens if, in some + * of the calls to bfq_bfqq_move() performed by + * bfq_reparent_active_queues(), the queue to move is + * empty and gets expired. + */ + bfq_flush_idle_tree(st); } __bfq_deactivate_entity(entity, false); -- 2.20.1