Received: by 10.192.165.148 with SMTP id m20csp1969246imm; Thu, 3 May 2018 08:15:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo6jdTQiiW9bsMnE2VnoY5dFsUNsdtW4CPXznGfC5vAt6MQwE2cgtEEx8khvJ1VLNodcE0B X-Received: by 2002:a63:6a04:: with SMTP id f4-v6mr19721189pgc.225.1525360547778; Thu, 03 May 2018 08:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525360547; cv=none; d=google.com; s=arc-20160816; b=dA2M/9uYBzKlQEcoIU/YLmGhHsUV/AhU6P1oRLgsJKWT4xQ31I+2DwmR8OxrPnFsp5 P3RlM2a6fppWGmiFeSYgl9g8NfvVfkURcrtSgrNnI2pciNNBMCBCNkHgSHtcywcxpZKp itAXp8g7PS1qDNsv/6AaXBMqAP8mihm+moJE13NCs5GGjefEfM+eLE6rENdszjxNrFFd zuBICMWNxcZtubQ7nwKJu7/DD1GRRnWS+stcSs3B+aT18tqdWyN/B3ttZgd7ePWNTbw0 Ab2S9lb1FelYGkgZSZ5o/Edxtgngo2QpEQqshWk2BCc5CuqYesjDI5eWYK5bpDqRY3cg q//Q== 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:arc-authentication-results; bh=7tVZ9Fw8a1he9R9lSGJWC+jC0KuJPy+s49oHiKudcPc=; b=y382keKqnbM2oG2oeiLO+4FO4aKkwvDcDeSFx/ZAqcxVEdiSpjKg/kpauvqh0L8Kdm 5yNjsS+9AYiK6wPVxK0YHhZwem58RCcJxm94U30slPHFeb+jU9Kh8kndgoA1cURaDeIT wcSkSBeRKi2iJfo4hAIE2/fL5uIomV16AOrfCIZ+jUAG69CwxXV2Lg6dxeT7BVEe6V9O kc66/8kqtz9NSu9scmHJrnzpAd9hPhEBAw6pKqkqJgxKlLL6ltNvuvRXhRBw1kktmh0k dgp1hJ9f88TNi9H1d0DKLSDMhnM2gdWLkBfWYM1dTQp9aBTZ0LUuehSnXNTPsm1Ecijm J1wA== ARC-Authentication-Results: i=1; mx.google.com; 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 99-v6si14010160plc.601.2018.05.03.08.15.33; Thu, 03 May 2018 08:15:47 -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; 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 S1751401AbeECPNt (ORCPT + 99 others); Thu, 3 May 2018 11:13:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:50617 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbeECPNr (ORCPT ); Thu, 3 May 2018 11:13:47 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0BBF5ADCD; Thu, 3 May 2018 15:13:46 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A59891E0C5F; Thu, 3 May 2018 17:13:43 +0200 (CEST) Date: Thu, 3 May 2018 17:13:43 +0200 From: Jan Kara To: Tetsuo Handa Cc: axboe@kernel.dk, torvalds@linux-foundation.org, 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) Message-ID: <20180503151343.2ijvp3mzdqfwbiay@quack2.suse.cz> References: <94eb2c05b2d83650030568cc8bd9@google.com> <43302799-1c50-4cab-b974-9fe1ca584813@I-love.SAKURA.ne.jp> <201805020714.FDD52145.OOJtOFVFSMLQFH@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201805020714.FDD52145.OOJtOFVFSMLQFH@I-love.SAKURA.ne.jp> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 02-05-18 07:14:51, Tetsuo Handa wrote: > >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 Thanks for debugging this and for the fix Tetsuo! The patch looks good to me. You can add: Reviewed-by: Jan Kara Honza > --- > 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) > -- > 1.8.3.1 -- Jan Kara SUSE Labs, CR