From patchwork Tue May 1 22:14:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10374553 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 011A660384 for ; Tue, 1 May 2018 22:15:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7E0A28D3B for ; Tue, 1 May 2018 22:15:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAB1528D41; Tue, 1 May 2018 22:15:10 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFED728D3B for ; Tue, 1 May 2018 22:15:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5F816B0007; Tue, 1 May 2018 18:15:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E6AC6B0008; Tue, 1 May 2018 18:15:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 888C16B0009; Tue, 1 May 2018 18:15:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it0-f72.google.com (mail-it0-f72.google.com [209.85.214.72]) by kanga.kvack.org (Postfix) with ESMTP id 60E486B0007 for ; Tue, 1 May 2018 18:15:08 -0400 (EDT) Received: by mail-it0-f72.google.com with SMTP id d66-v6so11031446itc.8 for ; Tue, 01 May 2018 15:15:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:to:cc:subject :from:references:in-reply-to:message-id:date:mime-version; bh=OYJw6g/sl52r6/5PYcnMmkWP+TX7x2D6EipZcIUvS0I=; b=LRaWwdvn3mp8JNLb+u5yx/IrYgIGNtlSKs+R4Druz52BgUPOxiQXbO90SLGcSJk7G5 xGFZkHhCWq+JUORfVGWVVbBRCmSjq16RhIuafHMp5H21jefio0XC9sjfPK90qBFasbCl Y1w3Ho2a0lgB7YQgr3YqShxxsMO1XiWblrlIPZ1/9G91bl+SC6FiQ23bHiFVneU5s4b8 Lwbj+bbHNvkJx9fx33EI63VC+lnXAyQRSe92n1ySzGKRDnOztPLJsjDR41RpcRdW5nUp ElFn5Y3rulE96+QdjG0YjbHi7SQzX9AaUDkS8i+IDZGv2h2WvNTdKeW2k4zACpBl6te6 Wo1w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp X-Gm-Message-State: ALQs6tCzmS+8Fr3v+9hTlYXpxZUt7b0RF2X8XVm5tsagjmcUTEzGcPNd vKNzu5LzuJVHcrfw1RXdvyHkjDJA5Gwjcl7P0dW2BkTlA8mGawKcAIW1h59xSq+jnoumENYOnH5 xQFIUjt7oDKRwlC7CEBpJ1/M1FWqY/jMiSgCl5VZLbAAglGzwrW6mfRYnxQ0iHuNPeQ== X-Received: by 2002:a6b:520d:: with SMTP id g13-v6mr17056161iob.89.1525212908122; Tue, 01 May 2018 15:15:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZphg3zNNdj25c66YVUT1/a8KG59EWJu4NqZ4HQVsBX57Sm4Q2ytxaRuXjyxEymWWXWAXfLC X-Received: by 2002:a6b:520d:: with SMTP id g13-v6mr17056073iob.89.1525212906878; Tue, 01 May 2018 15:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525212906; cv=none; d=google.com; s=arc-20160816; b=CGzEiQMFea1L7vxCC/Ir/kwdfyHH8IT8OaMkVusHf+z/FZAxx/pBKrD6PjNenGcPkW LOVN35J0A+dDKxGUlGpTthUzEjL7+8fHFnbf0boDuG/INDNJnfd9iYLHc0L4Hk2QdkIo 0kI8C/dUoFkhB3ep0EL9muR8PmmvpHUll1CL1i3gdnD9ilN6jk1pIb2YqQmGhnUpKSrA sjpus6FSsLZLzf4rs0+P3zi04N73i4LPi3q69Eg+5tU7ooBRCy92aP4fGjrwh0b8n+Ch S9+40esaslQ7iO1ht2n3VTXaYxoVUsthCEoZaaIfnMjmQFw+lxt+yg+TF/guZm3iZXml 0rpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:date:message-id:in-reply-to:references:from:subject:cc :to:arc-authentication-results; bh=OYJw6g/sl52r6/5PYcnMmkWP+TX7x2D6EipZcIUvS0I=; b=Xgy2lWtWbP5myISQgcCZ6y05O5Yqf89BASk6Y/lvYQ3miOd+VGaFo9BgefUyVj9+3i SgnW4YP/PFeV9ed11OvGbZb+UFBaGe7aSmHaPh5TN3/TgqTLPYwOHWiYARenQ/eZa7H/ 61zNUJMaHrV9e3CHifBbKlhyknMrXEnKN6ANHNql2TcBKODw8H3jW7qUI01S8wkYKAiy 4f+VzVk1ejGrwPj/Mujh03mp/S9Dw4SLWObDgwFmWYId8wettlhoTxonfLcZ1O+IYIF3 qsPBcumcXP9wy477ib3x3n6AkxaPlCUqZalJTZlUPe4SAwWnJoHD/FHH2GY+F8oI/zWI WqAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id o189-v6si8511567itc.9.2018.05.01.15.15.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 15:15:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) client-ip=202.181.97.72; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from fsav305.sakura.ne.jp (fsav305.sakura.ne.jp [153.120.85.136]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w41MEodd087683; Wed, 2 May 2018 07:14:50 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav305.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav305.sakura.ne.jp); Wed, 02 May 2018 07:14:50 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav305.sakura.ne.jp) Received: from AQUA (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w41MEnKf087679; Wed, 2 May 2018 07:14:50 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: axboe@kernel.dk, torvalds@linux-foundation.org Cc: jack@suse.cz, tj@kernel.org, syzbot+c0cf869505e03bdf1a24@syzkaller.appspotmail.com, christophe.jaillet@wanadoo.fr, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, zhangweiping@didichuxing.com, akpm@linux-foundation.org, dvyukov@google.com, linux-block@vger.kernel.org Subject: Re: INFO: task hung in wb_shutdown (2) From: Tetsuo Handa References: <94eb2c05b2d83650030568cc8bd9@google.com> <43302799-1c50-4cab-b974-9fe1ca584813@I-love.SAKURA.ne.jp> In-Reply-To: Message-Id: <201805020714.FDD52145.OOJtOFVFSMLQFH@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Wed, 2 May 2018 07:14:51 +0900 Mime-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP >From 1b90d7f71d60e743c69cdff3ba41edd1f9f86f93 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Wed, 2 May 2018 07:07:55 +0900 Subject: [PATCH v2] bdi: wake up concurrent wb_shutdown() callers. syzbot is reporting hung tasks at wait_on_bit(WB_shutting_down) in wb_shutdown() [1]. This seems to be because commit 5318ce7d46866e1d ("bdi: Shutdown writeback on all cgwbs in cgwb_bdi_destroy()") forgot to call wake_up_bit(WB_shutting_down) after clear_bit(WB_shutting_down). Introduce a helper function clear_and_wake_up_bit() and use it, in order to avoid similar errors in future. [1] https://syzkaller.appspot.com/bug?id=b297474817af98d5796bc544e1bb806fc3da0e5e Signed-off-by: Tetsuo Handa Reported-by: syzbot Fixes: 5318ce7d46866e1d ("bdi: Shutdown writeback on all cgwbs in cgwb_bdi_destroy()") Cc: Tejun Heo Cc: Jan Kara Cc: Jens Axboe Suggested-by: Linus Torvalds Reviewed-by: Jan Kara --- include/linux/wait_bit.h | 17 +++++++++++++++++ mm/backing-dev.c | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/wait_bit.h b/include/linux/wait_bit.h index 9318b21..2b0072f 100644 --- a/include/linux/wait_bit.h +++ b/include/linux/wait_bit.h @@ -305,4 +305,21 @@ struct wait_bit_queue_entry { __ret; \ }) +/** + * clear_and_wake_up_bit - clear a bit and wake up anyone waiting on that bit + * + * @bit: the bit of the word being waited on + * @word: the word being waited on, a kernel virtual address + * + * You can use this helper if bitflags are manipulated atomically rather than + * non-atomically under a lock. + */ +static inline void clear_and_wake_up_bit(int bit, void *word) +{ + clear_bit_unlock(bit, word); + /* See wake_up_bit() for which memory barrier you need to use. */ + smp_mb__after_atomic(); + wake_up_bit(word, bit); +} + #endif /* _LINUX_WAIT_BIT_H */ diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 023190c..fa5e6d7 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -383,7 +383,7 @@ static void wb_shutdown(struct bdi_writeback *wb) * the barrier provided by test_and_clear_bit() above. */ smp_wmb(); - clear_bit(WB_shutting_down, &wb->state); + clear_and_wake_up_bit(WB_shutting_down, &wb->state); } static void wb_exit(struct bdi_writeback *wb)