Received: by 2002:a25:d80d:0:0:0:0:0 with SMTP id p13csp230663ybg; Sat, 23 May 2020 12:23:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG4wVWZaw3zkzwojXpNyksAAnKWsZDr90/BMEE5HEMpfPIOztWDK2Z4fE64ritDaZezsXG X-Received: by 2002:a17:906:41a:: with SMTP id d26mr13611547eja.217.1590261783877; Sat, 23 May 2020 12:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590261783; cv=none; d=google.com; s=arc-20160816; b=PDXXAE652UisufJhXpctvWwQ7E8Dn4/98zThXZdtlFddcSxT38vpd8Atq2YfPLN1F9 xQkK5ajonWXHdecx0KLEGYrgNP1VuW1HODtK27SmEbR+cI5TH63TEvGsKYKTNMV28htP x4/fAdSsnleoesIzY+pKXduxqNRJKY3GENl4mkYk3BXGL9hVQKCByhKq6WKJdH/AdW44 6MeiwWQydf2LUMK3dciQVXTJqr56grIfuNR8sXNMQ83EH5i0JlxKZiv2xeK1KvTfXOoA BMPVM6RwUlHO5A5vEcWNlCcW5WZmEAnNAoerz6JCtRP43EZorAdsr4nhrMM1n27eT/VW 2H6A== 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:references:cc:to:from:subject:dkim-signature; bh=hA9QPDx7hlE3ND4DwWRlDMJ19Frvrmq/H2EqY+eNJ64=; b=TURzL9x7LtKkpdEeQ1RYPNhHIwiOzzwZ8rRjypLoRzNqO26yN132fG/FOIDIahMq0t tma+8a6qxR1qfHX5lkJ1HY8R7KBL2mdQMUHUREKKhN1sROLNVPbjSjUjxyLm6DeVH2f2 6rM6H3k6C/4nEet/+zfAroRX5Hd/PVnKATpHbS28EYdIf1e/hi3vMc75Hk6BIG4tgczI MxIcy0eR3tnH6zHv/1aDB42scMdCbe1Xf0vdd0YglG9hXKsPQgw3NbhEkiG1bFVQhhje fEI8Q8swF+OedqYMwAKTv5c/6E/OJ8zLYMxf29hTD5QWLhz06k0mKKXZnquXxqx1R6jG 2V5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=0q+YU9P9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb25si6598661edb.142.2020.05.23.12.22.39; Sat, 23 May 2020 12:23:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=0q+YU9P9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387536AbgEWTUq (ORCPT + 99 others); Sat, 23 May 2020 15:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbgEWTUq (ORCPT ); Sat, 23 May 2020 15:20:46 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16A90C08C5C0 for ; Sat, 23 May 2020 12:20:45 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id u22so5754242plq.12 for ; Sat, 23 May 2020 12:20:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=hA9QPDx7hlE3ND4DwWRlDMJ19Frvrmq/H2EqY+eNJ64=; b=0q+YU9P9GK7f7corz/MS41QLym929QjELiRrpW8MG8nwgFwcsxsqzCbNyC7laJ1+PF glJphrkI1udiLmwSzBkbGBRq+UPe73XZoD2mvtEOZ4ia2S44JuxRfUumeDe4yb98XkRZ P5yD3lBb+VKq6WVq34r3Ou4D6u7gizH6e7wDh7/5gwBjIVCkJ5KgFhS+c6pf7/vrEzJy AkgSLIH8Z/r7HU6xk2xehOVbOp05rjgCDx4olsrirOGmqMR80ofSNU686R2TjN7Rhvct fjYmAUM0vHO1N3eVEB+5PPKJmsdd0ligK7RL/JZb1osl2D7+Z2ZNcRhTw69SNr8BEkjg r9Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hA9QPDx7hlE3ND4DwWRlDMJ19Frvrmq/H2EqY+eNJ64=; b=llYVGq1cdLtTkFUj0CyeKzSspJ3HwSuc69wOFaliOxFRnfjcrnd7qFdXc7xi6NNYqJ 1Ls0yXRfNWdZVFhFvfbS09gO6Xvrv/+amhW8GNpBCaWzmOiAgUGiSg0hd8xraiprKIzw jez7110vhAnJkZROyZV213TbCZYGe7mcQHRhGodA7tLBSzMZ6zMyfaQgnCHnZYt+B3bh Byzc7Cd8yOvpdBLjP6mg1v+Jt7/TwgAvWwa6lBhPP6cVr8nFz4hpurM8zDSYluc7yrGd lHWgeBvQ1Fm1SWsbfMtwUIfzH4w60zs91paoqkV1PMIXVojU/LJ1c+FnYaKvPJSjMZ7/ ysZw== X-Gm-Message-State: AOAM5337KBEBtr55ZJ8N0CU5iVUQrk3eo7HTEBqovwlBNFxw+TMEcdda a9NOUZGXWpL+H7zyfE0N4BYF2vnjmCLKIg== X-Received: by 2002:a17:90a:8545:: with SMTP id a5mr11496077pjw.200.1590261644246; Sat, 23 May 2020 12:20:44 -0700 (PDT) Received: from ?IPv6:2605:e000:100e:8c61:c94:a67a:9209:cf5f? ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 202sm2033541pfv.155.2020.05.23.12.20.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 May 2020 12:20:43 -0700 (PDT) Subject: Re: [PATCHSET v2 0/12] Add support for async buffered reads From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20200523185755.8494-1-axboe@kernel.dk> Message-ID: <2b42c0c3-5d3c-e381-4193-83cb3f971399@kernel.dk> Date: Sat, 23 May 2020 13:20:42 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org And this one is v3, obviously, not v2... On 5/23/20 12:57 PM, Jens Axboe wrote: > We technically support this already through io_uring, but it's > implemented with a thread backend to support cases where we would > block. This isn't ideal. > > After a few prep patches, the core of this patchset is adding support > for async callbacks on page unlock. With this primitive, we can simply > retry the IO operation. With io_uring, this works a lot like poll based > retry for files that support it. If a page is currently locked and > needed, -EIOCBQUEUED is returned with a callback armed. The callers > callback is responsible for restarting the operation. > > With this callback primitive, we can add support for > generic_file_buffered_read(), which is what most file systems end up > using for buffered reads. XFS/ext4/btrfs/bdev is wired up, but probably > trivial to add more. > > The file flags support for this by setting FMODE_BUF_RASYNC, similar > to what we do for FMODE_NOWAIT. Open to suggestions here if this is > the preferred method or not. > > In terms of results, I wrote a small test app that randomly reads 4G > of data in 4K chunks from a file hosted by ext4. The app uses a queue > depth of 32. If you want to test yourself, you can just use buffered=1 > with ioengine=io_uring with fio. No application changes are needed to > use the more optimized buffered async read. > > preadv for comparison: > real 1m13.821s > user 0m0.558s > sys 0m11.125s > CPU ~13% > > Mainline: > real 0m12.054s > user 0m0.111s > sys 0m5.659s > CPU ~32% + ~50% == ~82% > > This patchset: > real 0m9.283s > user 0m0.147s > sys 0m4.619s > CPU ~52% > > The CPU numbers are just a rough estimate. For the mainline io_uring > run, this includes the app itself and all the threads doing IO on its > behalf (32% for the app, ~1.6% per worker and 32 of them). Context > switch rate is much smaller with the patchset, since we only have the > one task performing IO. > > The goal here is efficiency. Async thread offload adds latency, and > it also adds noticable overhead on items such as adding pages to the > page cache. By allowing proper async buffered read support, we don't > have X threads hammering on the same inode page cache, we have just > the single app actually doing IO. > > Been beating on this and it's solid for me, and I'm now pretty happy > with how it all turned out. Not aware of any missing bits/pieces or > code cleanups that need doing. > > Series can also be found here: > > https://git.kernel.dk/cgit/linux-block/log/?h=async-buffered.3 > > or pull from: > > git://git.kernel.dk/linux-block async-buffered.3 > > fs/block_dev.c | 2 +- > fs/btrfs/file.c | 2 +- > fs/ext4/file.c | 2 +- > fs/io_uring.c | 99 ++++++++++++++++++++++++++++++++++ > fs/xfs/xfs_file.c | 2 +- > include/linux/blk_types.h | 3 +- > include/linux/fs.h | 5 ++ > include/linux/pagemap.h | 64 ++++++++++++++++++++++ > mm/filemap.c | 111 ++++++++++++++++++++++++-------------- > 9 files changed, 245 insertions(+), 45 deletions(-) > > Changes since v2: > - Get rid of unnecessary wait_page_async struct, just use wait_page_async > - Add another prep handler, adding wake_page_match() > - Use wake_page_match() in both callers > Changes since v1: > - Fix an issue with inline page locking > - Fix a potential race with __wait_on_page_locked_async() > - Fix a hang related to not setting page_match, thus missing a wakeup > -- Jens Axboe