Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp211889imm; Thu, 27 Sep 2018 19:32:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62BOvZ4L1dCeJuWpjumY6ag4TbxlwI2TgZNzNoaLmlMiSIOzMJngQpktnAloPp2TYf5B2Lr X-Received: by 2002:a62:85cb:: with SMTP id m72-v6mr6277338pfk.173.1538101935715; Thu, 27 Sep 2018 19:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538101935; cv=none; d=google.com; s=arc-20160816; b=gm+IHucAh8SYrYwTuBUriA7oeA5DQVjvZXz4U9ArRb6x2iok6GNGsaJqYTRclUNCNi Vk8kvmzWlkaYrn3UNib73nIf3v01LZuRPjbM5e+bcxc0eWgrnYNuTdJfbndMY2sWKV29 8rpEfGz+FR9yfDfsb47Ib6HhhmhCItP724yUcFMzAlgwDAFuq1r2Gf2omsVm//QKZG0e ZNfCOLlp+9z3UFzspOGxJ0VviQ+9I5c2sfDaXRi+qkZHJqaXoy2G7wnhs5PUVGFhDvvr SeuQRdJqi9627LgKfDPao67+iGlGRwrtAmxDBg+rCw3GNyiEayIYFhFfeG53K9V32OfX JWSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=eFNzgBa9hWGvsHwvBIaOn5DtKJ6GQIE96A8YrTt/fd8=; b=nZXydAaSpUoCxiq5T4Lcy/eQD913a0nxQOhvLChW+FaILv3/5bnWkPki86BVgqD7iH sbigtD7IU5WjySl/PA+T8ZH5Mh7Ki/L1bIjTOvp/NOrxl9xRgG+20Eozd1XsUEQ60EvV lh70FN+Hxf9KV31+yUdLbnwBP+HWuDERkIGCtUNWRDRt+yXmXBfdBLoDoAbLiSHIUF7F ZW4AxDf35C/vduoF5ZUw7VAsiyk1j3/79oiq4WElP3UE3uh1424BRYx4rZ6FySAK0A31 KqkqlUNtG8fnlM4oghRWN9sZKA2iN2fFAHzBjeE7fV9bFIcYYF88F2v97gt44bd3a3NL o09w== 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 d9-v6si3632889pfk.166.2018.09.27.19.31.59; Thu, 27 Sep 2018 19:32:15 -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 S1728298AbeI1IxB (ORCPT + 99 others); Fri, 28 Sep 2018 04:53:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:36188 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727361AbeI1IxB (ORCPT ); Fri, 28 Sep 2018 04:53:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6CEFEAE12; Fri, 28 Sep 2018 02:31:35 +0000 (UTC) Subject: Re: [PATCH] bcache: add separate workqueue for journal_write to avoid deadlock To: Stefan Priebe - Profihost AG Cc: Eddie Chapman , guoju , kent.overstreet@gmail.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org References: <1538055919-5757-1-git-send-email-fangguoju@gmail.com> <9b1abe65-c6f5-77b4-290e-e6af21723cfc@ehuk.net> <2C0DE6F7-624B-49B6-9788-BA0A8E7DA25C@profihost.ag> From: Coly Li Message-ID: Date: Fri, 28 Sep 2018 10:31:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <2C0DE6F7-624B-49B6-9788-BA0A8E7DA25C@profihost.ag> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stefan, This bug was triggered by following condition: 1, few system memory available to allocate 2, journal delayed its operations to system_wq, which needs to allocate memory to execute. 3, Due to lack of memory, kernel starts to reclaim system memory, and trigger writeback to file system on top of bcache device 4, the memory writeback I/O hitting bcache device via upper layer file system, requiring more bcache journal operations 5, a loop-blocking issue happens in bcache journal If your system is under heavy memory pressure, this deadlock may also happens in your environment. Anyway, this is a patch I suggest to apply because it fix a real deadlock which is probably happens when system memory is exhausted. Thanks. Coly Li On 9/28/18 1:16 AM, Stefan Priebe - Profihost AG wrote: > Hi Coly, > > is this the deadlock I reported some weeks ago? > > Greets, > Stefan > > Excuse my typo sent from my mobile phone. > > Am 27.09.2018 um 17:53 schrieb Eddie Chapman >: > >> 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? >> >> thanks, >> Eddie