Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1024972imm; Thu, 4 Oct 2018 07:08:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV60q6tvlfg0tiXD9D0V59kxD6cumxqUn6uz0VabsW0xzF66eHHDrfnoo/QJvf2AQ5dyDI3ZU X-Received: by 2002:a62:11cb:: with SMTP id 72-v6mr6893606pfr.120.1538662107155; Thu, 04 Oct 2018 07:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538662107; cv=none; d=google.com; s=arc-20160816; b=cxOCUgdEEcdTU0xfrh9LEdhgpdBlivfBj4M5QQ2Qaj4lcJX5pp0vCi8Z1ZNh3YZue0 C/MpNzfSYTaO4d9zYRIk6tC31R5NzWvzRI3ypTEXYGBOgJz8ZMpehqUPc2MTtM6RPoIQ u2U09WRPT0UvW6WB31R0uPeEc6csEafh3hAwL2BL46Lx84viQN0pC4lDpX+4uTQVF6TM Sz8WMt+bviXDu5FkWlGGewGAq6yJ8dLVctK9U4tMKvzz1Wa928lY+oYZ3Qr94yhC6N6q id/hFqniDh4OdIoQRCnjcKEP+xUFwXrwm3D08yCfQ1byIO1z3SrJHbvCQnyYKeicCBuf Ppqg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:reply-to:from:references:cc:to:subject:dkim-signature :dkim-filter; bh=/+jd7c8Be2Q66V7cUgTmMjbwu+tWkf/S98vILRYWLys=; b=0X18fy83uG6qeMP8PNoKPERglqfHx2ZRhwBALmdwxGJVDaFTXQ4aKZMkwL6fV4SxMC GoAwN+9IadWc1s7b0apFPUJJJRwov05dhtigaKLLWGvHRZ18PjvniaB3A3E81JS9z32D oOH4p6h72DE095ZEENi/u7jwGaNwIwoQRDT525FUvhGJ/Gz5IrUQpOcHd8K/ebOkeBdb gFO8Lo2+D7qH5VhD3klhK986dsWxrSQ3YXbgxCmUR40sphd7/KURVc4xvE/7julVSGDm nyNpn7aTjcAhxr+BnofN8eBl2NimRfDLIUJbA51G9NZ9TV00SCDn3jj9AKbflvuNOTg4 sN9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ehuk.net header.s=default header.b=emG5t3n5; 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 g74-v6si252814pfe.4.2018.10.04.07.08.10; Thu, 04 Oct 2018 07:08:27 -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=@ehuk.net header.s=default header.b=emG5t3n5; 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 S1727524AbeJDVBY (ORCPT + 99 others); Thu, 4 Oct 2018 17:01:24 -0400 Received: from schatzi.steelbluetech.co.uk ([92.63.139.240]:24203 "EHLO schatzi.steelbluetech.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727394AbeJDVBY (ORCPT ); Thu, 4 Oct 2018 17:01:24 -0400 Received: from [10.0.5.25] (tv.ehuk.net [10.0.5.25]) by schatzi.steelbluetech.co.uk (Postfix) with ESMTP id 69019BFD68; Thu, 4 Oct 2018 15:07:54 +0100 (BST) DKIM-Filter: OpenDKIM Filter v2.10.3 schatzi.steelbluetech.co.uk 69019BFD68 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ehuk.net; s=default; t=1538662074; bh=/+jd7c8Be2Q66V7cUgTmMjbwu+tWkf/S98vILRYWLys=; h=Subject:To:Cc:References:From:Reply-To:Date:In-Reply-To:From; b=emG5t3n5yllVTOuwD2O4iQm+lgSvCjnsQV6uGKYRB0igl4TKX4hlxZbtmdGPlGViA 7BR96qPkXrEQEFtm0MxE9Y/Ky/Ymvpr6dsCehTyiZW7HJjlKXvPV6BA19k807hjAEn EsQVY9BjX/zMiZmzKdaBdtuk8ldmMOgQtTfsJ7SM= Subject: Re: [PATCH] bcache: add separate workqueue for journal_write to avoid deadlock To: Coly Li Cc: guoju , kent.overstreet@gmail.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, s.priebe@profihost.ag References: <1538055919-5757-1-git-send-email-fangguoju@gmail.com> <9b1abe65-c6f5-77b4-290e-e6af21723cfc@ehuk.net> From: Eddie Chapman Reply-To: Eddie Chapman Message-ID: <17ea92fa-a07b-2391-aba3-377382c63d9b@ehuk.net> Date: Thu, 4 Oct 2018 15:07:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/09/18 03:32, Coly Li wrote: > > On 9/27/18 11:53 PM, Eddie Chapman wrote: >> On 27/09/18 16:23, Coly Li wrote: >>> >>> On 9/27/18 9:45 PM, guoju wrote: >>>> After write SSD completed, bcache schedule journal_write work to >>>> system_wq, that is a public workqueue in system, without WQ_MEM_RECLAIM>>>> flag. system_wq is also a bound wq, and there may be no idle kworker on >>>> current processor. Creating a new kworker may unfortunately need to >>>> reclaim memory first, by shrinking cache and slab used by vfs, which >>>> depends on bcache device. That's a deadlock. >>>> >>>> This patch create a new workqueue for journal_write with WQ_MEM_RECLAIM >>>> flag. It's rescuer thread will work to avoid the deadlock. >>>> >>>> Signed-off-by: guoju >>> >>> Nice catch, this fix is quite important. I will try to submit to Jens >>> ASAP. >>> >>> Thanks. >>> >>> Coly Li >> >> Once this goes into 4.19, would this be a candidate for backporting to >> any stable kernels, or does it only fix something introduced in this >> cycle? >> > This bug exists in upstream for quite long time, it should be applied to > all stable kernels which it can be applied. And it is Cced to > stable@vger.kernel.org already. > > Coly Li Thanks Coly! :-) Just to let you know, I applied this (and couple of other cherry picks) to a couple of 4.14 boxes last night, so far so good, running without issues. However, this one needed this recent commit upstream as a pre-requisite: 16c1fdf4cfd6c0091e59b93ec2cb7e99973f8244 bcache: do not assign in if condition in bcache_init() in order to be able to apply it. This is because the context of the second hunk for drivers/md/bcache/super.c (in this journal_write workqueue patch) contains code added by that commit 16c1fdf4cfd6c0091e59b93ec2cb7e99973f8244. So I guess either 16c1fdf4cfd6c0091e59b93ec2cb7e99973f8244 also needs tagging for stable, or perhaps a backport of this journal_write workqueue will have to be created for earlier kernels, with different context for that hunk? Eddie