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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38B4FC433F5 for ; Mon, 18 Apr 2022 06:59:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 859988D0002; Mon, 18 Apr 2022 02:59:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 808626B009B; Mon, 18 Apr 2022 02:59:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D0B88D0002; Mon, 18 Apr 2022 02:59:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 5AA746B009A for ; Mon, 18 Apr 2022 02:59:39 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2761F2383B for ; Mon, 18 Apr 2022 06:59:39 +0000 (UTC) X-FDA: 79369099278.15.78E1130 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf22.hostedemail.com (Postfix) with ESMTP id D217FC0003 for ; Mon, 18 Apr 2022 06:59:37 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Khd8g086qzgYrS; Mon, 18 Apr 2022 14:59:31 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Apr 2022 14:59:34 +0800 Subject: Re: [PATCH 09/10] MM: submit multipage write for SWP_FS_OPS swap-space To: NeilBrown CC: Christoph Hellwig , David Howells , , , , Andrew Morton References: <164859751830.29473.5309689752169286816.stgit@noble.brown> <164859778128.29473.5191868522654408537.stgit@noble.brown> From: Miaohe Lin Message-ID: <033ccf1a-c6b5-fd77-0ad0-4915ff07bc15@huawei.com> Date: Mon, 18 Apr 2022 14:59:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <164859778128.29473.5191868522654408537.stgit@noble.brown> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D217FC0003 X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: pumu78agqsf7ph6x3tynkq8dcr6scb7s X-HE-Tag: 1650265177-56810 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022/3/30 7:49, NeilBrown wrote: > swap_writepage() is given one page at a time, but may be called repeatedly > in succession. > For block-device swapspace, the blk_plug functionality allows the > multiple pages to be combined together at lower layers. > That cannot be used for SWP_FS_OPS as blk_plug may not exist - it is > only active when CONFIG_BLOCK=y. Consequently all swap reads over NFS > are single page reads. > > With this patch we pass a pointer-to-pointer via the wbc. > swap_writepage can store state between calls - much like the pointer > passed explicitly to swap_readpage. After calling swap_writepage() some > number of times, the state will be passed to swap_write_unplug() which > can submit the combined request. > > Reviewed-by: Christoph Hellwig > Signed-off-by: NeilBrown ... > > static int swap_writepage_fs(struct page *page, struct writeback_control *wbc) > { > - struct swap_iocb *sio; > + struct swap_iocb *sio = NULL; > struct swap_info_struct *sis = page_swap_info(page); > struct file *swap_file = sis->swap_file; > - struct address_space *mapping = swap_file->f_mapping; > - struct iov_iter from; > - int ret; > + loff_t pos = page_file_offset(page); > > set_page_writeback(page); > unlock_page(page); > - sio = mempool_alloc(sio_pool, GFP_NOIO); > - init_sync_kiocb(&sio->iocb, swap_file); > - sio->iocb.ki_complete = sio_write_complete; > - sio->iocb.ki_pos = page_file_offset(page); > - sio->bvec[0].bv_page = page; > - sio->bvec[0].bv_len = PAGE_SIZE; > - sio->bvec[0].bv_offset = 0; > - iov_iter_bvec(&from, WRITE, &sio->bvec[0], 1, PAGE_SIZE); > - ret = mapping->a_ops->swap_rw(&sio->iocb, &from); > - if (ret != -EIOCBQUEUED) > - sio_write_complete(&sio->iocb, ret); > - return ret; > + if (wbc->swap_plug) > + sio = *wbc->swap_plug; > + if (sio) { > + if (sio->iocb.ki_filp != swap_file || > + sio->iocb.ki_pos + sio->pages * PAGE_SIZE != pos) { > + swap_write_unplug(sio); > + sio = NULL; > + } > + } > + if (!sio) { > + sio = mempool_alloc(sio_pool, GFP_NOIO); > + init_sync_kiocb(&sio->iocb, swap_file); > + sio->iocb.ki_complete = sio_write_complete; > + sio->iocb.ki_pos = pos; > + sio->pages = 0; > + } > + sio->bvec[sio->pages].bv_page = page; > + sio->bvec[sio->pages].bv_len = PAGE_SIZE; Many thanks for your patch. And sorry for late responding and newbie question. Does swap_writepage_fs support transhuge page now? We could come across transhuge page here. But bv_len == PAGE_SIZE and pages == 1 is assumed here. Do we need something like below: sio->bvec[sio->pages].bv_len = thp_size(page); sio->pages += thp_nr_pages(page); Thanks! :) > + sio->bvec[sio->pages].bv_offset = 0; ... > . >