From patchwork Mon Feb 13 15:02:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9569921 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 C858060572 for ; Mon, 13 Feb 2017 15:03:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE972282E2 for ; Mon, 13 Feb 2017 15:03:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A187228356; Mon, 13 Feb 2017 15:03:00 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 49B2927D4D for ; Mon, 13 Feb 2017 15:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752232AbdBMPCp (ORCPT ); Mon, 13 Feb 2017 10:02:45 -0500 Received: from mail-it0-f49.google.com ([209.85.214.49]:35849 "EHLO mail-it0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752067AbdBMPCP (ORCPT ); Mon, 13 Feb 2017 10:02:15 -0500 Received: by mail-it0-f49.google.com with SMTP id c7so189400978itd.1 for ; Mon, 13 Feb 2017 07:02:15 -0800 (PST) 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=I2++zI68n+yC2U/CvGZh+tPVdzZUE+TvIgkQIkXSLVg=; b=FCTJEeCWAT66kpC2Qjoa8cXZ7VSaYvd+RAdPDpMW/PWDCNNlfXpQ0HDMVOeGzLDjwS QEOrHeUWBFHqs4sb/a6XojIOTVhcu21BxRxCtPJVyDzVnxf8xYP8v04/PrWfM1Fl05HN AtIkqPa5u7ev4uhplNlrgKSZY3YmEEPGVVVJaNDdEnA4jHzTPQN723fynUY4bB7WxOV8 r/fZT+Q1/EOvDXGDd/ZiACb3IlHUlK9rotzJ4nAuXrL9I6aybYfZ8nS707KD3p9Jx9nv ZHC5Uj8bC98c7YUythKf/PtvdIzn0eHmymShOkp5BDFkTG/nAVy0RXZplbkbK5B/T25H DeDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=I2++zI68n+yC2U/CvGZh+tPVdzZUE+TvIgkQIkXSLVg=; b=qlTLWS9ixKOcYXiYBWVB0VsBscaU+GJ4zfdT3Aisxj7r2y6sVY2peWZR+7htRwJzL/ j2t/YEERGFIu7x+deGhWyZoMYRJMttiAEMTUO6COFyVpf8+oJve0Iq5J9arFkG9LKaOj lQUFyy8KuuQ0PySvbs3YWn1TWyxroTwlPsp9oN9nYY4XJsCZA2hmlDgeEEGsLjNkt6jl 28yIc4Qw+TWu4UZZ/3dtx9YykQwoQhEW9GyRhC/XzsFj1BX8M82hP5z05vsqRDNYzKpK 3CQ7rypEfHY2kRpT1K/KfKXVHT+YKAQG1WbuUO8q0M/ff5Hzp05Jbi5G+pAU2FUKY+tG AdnQ== X-Gm-Message-State: AMke39kCt4x1F9bKnMGZ0j7iRdbBbRkLSC/phs/D71aTTNNCVzx0HELFKztdn7YqFiJWcQ== X-Received: by 10.36.165.79 with SMTP id w15mr21314576iti.77.1486998134415; Mon, 13 Feb 2017 07:02:14 -0800 (PST) Received: from [192.168.1.154] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id o13sm1850472ith.5.2017.02.13.07.02.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Feb 2017 07:02:13 -0800 (PST) Subject: Re: [BUG] Potential deadlock in the block layer To: Thomas Gleixner , LKML References: Cc: linux-block@vger.kernel.org, Gabriel C , Steven Rostedt , Peter Zijlstra , Linus Torvalds From: Jens Axboe Message-ID: <4d3f25fc-7480-769c-2f4f-e5271a47f7c3@kernel.dk> Date: Mon, 13 Feb 2017 08:02:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: 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 02/13/2017 07:14 AM, Thomas Gleixner wrote: > Gabriel reported the lockdep splat below while investigating something > different. > > Explanation for the splat is in the function comment above > del_timer_sync(). > > I can reproduce it as well and it's clearly broken. Agree, the disable logic is broken. The below isn't super pretty, but it should do the trick for 4.10. diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index c73a6fcaeb9d..838f07e2b64a 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -3758,7 +3758,7 @@ static void cfq_init_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq, } #ifdef CONFIG_CFQ_GROUP_IOSCHED -static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) +static bool check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) { struct cfq_data *cfqd = cic_to_cfqd(cic); struct cfq_queue *cfqq; @@ -3775,15 +3775,7 @@ static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) * spuriously on a newly created cic but there's no harm. */ if (unlikely(!cfqd) || likely(cic->blkcg_serial_nr == serial_nr)) - return; - - /* - * If we have a non-root cgroup, we can depend on that to - * do proper throttling of writes. Turn off wbt for that - * case, if it was enabled by default. - */ - if (nonroot_cg) - wbt_disable_default(cfqd->queue); + return nonroot_cg; /* * Drop reference to queues. New queues will be assigned in new @@ -3804,9 +3796,13 @@ static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) } cic->blkcg_serial_nr = serial_nr; + return nonroot_cg; } #else -static inline void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) { } +static inline bool check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) +{ + return false; +} #endif /* CONFIG_CFQ_GROUP_IOSCHED */ static struct cfq_queue ** @@ -4448,11 +4444,12 @@ cfq_set_request(struct request_queue *q, struct request *rq, struct bio *bio, const int rw = rq_data_dir(rq); const bool is_sync = rq_is_sync(rq); struct cfq_queue *cfqq; + bool disable_wbt; spin_lock_irq(q->queue_lock); check_ioprio_changed(cic, bio); - check_blkcg_changed(cic, bio); + disable_wbt = check_blkcg_changed(cic, bio); new_queue: cfqq = cic_to_cfqq(cic, is_sync); if (!cfqq || cfqq == &cfqd->oom_cfqq) { @@ -4488,6 +4485,10 @@ cfq_set_request(struct request_queue *q, struct request *rq, struct bio *bio, rq->elv.priv[0] = cfqq; rq->elv.priv[1] = cfqq->cfqg; spin_unlock_irq(q->queue_lock); + + if (disable_wbt) + wbt_disable_default(q); + return 0; }