From patchwork Tue Aug 8 12:49:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 9888077 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 6D78A60352 for ; Tue, 8 Aug 2017 12:50:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E2D6287C6 for ; Tue, 8 Aug 2017 12:50:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5332C287D6; Tue, 8 Aug 2017 12:50: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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EFF87287C6 for ; Tue, 8 Aug 2017 12:50:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1DDB121E0C2F2; Tue, 8 Aug 2017 05:47:52 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 42BD2209589FC for ; Tue, 8 Aug 2017 05:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GejeBTQt7MDqT77cp/6yShn3O5IXGeA2tKKIJX29tn4=; b=WyykDagrUZ1LKyZmWnhJ4XkiE V560KlA1miDLVfcXW98c+taRIhWqRk9Y9fvgC3rhTlap5LxK10Hjmuq4ImWqTMLpg2NfAUrVo5hpL VN4g/D2yuu9g6xUkkaqAlt30NbOpVFCBH+ffAo4X0uJPsagZZN+Y9/8ecB07VfDnVLkb86/MI3Hmt 55hmmC4Ige+bu0oJDOx0am4gqLU3UnsTr91xBkSdy61rrAOxtchRFoCX0zZ38mM8CIJFhR0wzTtgM 2tITyl7/Bxe0XsxlMJ0eEm8A4d5aKySjXIkuoU4S11QeFYg3kaucUH50hZVTR2jK3Zg+65+GIv2r7 Sh4/eOVtw==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1df3xP-0003kV-P9; Tue, 08 Aug 2017 12:49:59 +0000 Date: Tue, 8 Aug 2017 05:49:59 -0700 From: Matthew Wilcox To: Minchan Kim Subject: Re: [PATCH v1 2/6] fs: use on-stack-bio if backing device has BDI_CAP_SYNC capability Message-ID: <20170808124959.GB31390@bombadil.infradead.org> References: <1502175024-28338-1-git-send-email-minchan@kernel.org> <1502175024-28338-3-git-send-email-minchan@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1502175024-28338-3-git-send-email-minchan@kernel.org> User-Agent: Mutt/1.8.0 (2017-02-23) X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Axboe , jack@suse.cz, linux-nvdimm@lists.01.org, Dave Chinner , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-mm@kvack.org, kernel-team , seungho1.park@lge.com, "karam . lee" , Andrew Morton Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Aug 08, 2017 at 03:50:20PM +0900, Minchan Kim wrote: > There is no need to use dynamic bio allocation for BDI_CAP_SYNC > devices. They can with on-stack-bio without concern about waiting > bio allocation from mempool under heavy memory pressure. This seems ... more complex than necessary? Why not simply do this: diff --git a/fs/mpage.c b/fs/mpage.c index baff8f820c29..6db6bf5131ed 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -157,6 +157,8 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, unsigned page_block; unsigned first_hole = blocks_per_page; struct block_device *bdev = NULL; + struct bio sbio; + struct bio_vec sbvec; int length; int fully_mapped = 1; unsigned nblocks; @@ -281,10 +283,17 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, page)) goto out; } - bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), + if (bdi_cap_synchronous_io(inode_to_bdi(inode))) { + bio = &sbio; + bio_init(bio, &sbvec, nr_pages); + sbio.bi_bdev = bdev; + sbio.bi_iter.bi_sector = blocks[0] << (blkbits - 9); + } else { + bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), min_t(int, nr_pages, BIO_MAX_PAGES), gfp); - if (bio == NULL) - goto confused; + if (bio == NULL) + goto confused; + } } length = first_hole << blkbits; @@ -301,6 +310,8 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, else *last_block_in_bio = blocks[blocks_per_page - 1]; out: + if (bio == &sbio) + bio = mpage_bio_submit(REQ_OP_READ, 0, bio); return bio; confused: