From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93ADCC2B9F7 for ; Mon, 24 May 2021 15:34:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74EE16143F for ; Mon, 24 May 2021 15:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233754AbhEXPfm (ORCPT ); Mon, 24 May 2021 11:35:42 -0400 Received: from verein.lst.de ([213.95.11.211]:55288 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233654AbhEXPeR (ORCPT ); Mon, 24 May 2021 11:34:17 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 57D6667373; Mon, 24 May 2021 17:32:47 +0200 (CEST) Date: Mon, 24 May 2021 17:32:47 +0200 From: Christoph Hellwig To: Ming Lei Cc: Christoph Hellwig , Brian Foster , "Darrick J. Wong" , Dave Chinner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: iomap: writeback ioend/bio allocation deadlock risk Message-ID: <20210524153247.GA6041@lst.de> References: <20210521071727.GA11473@lst.de> <20210521073547.GA11955@lst.de> <20210521083635.GA15311@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, May 21, 2021 at 04:54:45PM +0800, Ming Lei wrote: > On Fri, May 21, 2021 at 10:36:35AM +0200, Christoph Hellwig wrote: > > On Fri, May 21, 2021 at 04:35:03PM +0800, Ming Lei wrote: > > > Just wondering why the ioend isn't submitted out after it becomes full? > > > > block layer plugging? Although failing bio allocations will kick that, > > so that is not a deadlock risk. > > These ioends are just added to one list stored on local stack variable(submit_list), Yes. But only until the code finished iterating over a page. The worst case number of bios for a page is PAGE_SIZE / SECTOR_SIZE, and the bio_set is side to handle that comfortably. > how can block layer plugging observe & submit them out? It can't. I was talking about the high-level plug that is held over multiple pages. At that point the bios are submitted to the block layer already, but they might be held in a plug. And looking at the bio_alloc_bioset code we don't actually flush a plug at the moment in that case. Something like the patch below would do that: diff --git a/block/bio.c b/block/bio.c index 44205dfb6b60..5b9d2f4d7c08 100644 --- a/block/bio.c +++ b/block/bio.c @@ -432,6 +432,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned short nr_iovecs, p = mempool_alloc(&bs->bio_pool, gfp_mask); if (!p && gfp_mask != saved_gfp) { + blk_schedule_flush_plug(current); punt_bios_to_rescuer(bs); gfp_mask = saved_gfp; p = mempool_alloc(&bs->bio_pool, gfp_mask);