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 B9883C433EF for ; Fri, 10 Jun 2022 01:32:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 100FD6B00D2; Thu, 9 Jun 2022 21:32:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B09F6B00D3; Thu, 9 Jun 2022 21:32:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E93628D0064; Thu, 9 Jun 2022 21:32:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DA63F6B00D2 for ; Thu, 9 Jun 2022 21:32:48 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A805321745 for ; Fri, 10 Jun 2022 01:32:48 +0000 (UTC) X-FDA: 79560602016.23.E5CC60B Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf02.hostedemail.com (Postfix) with ESMTP id 4FE3380068 for ; Fri, 10 Jun 2022 01:32:48 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id s135so7791947pgs.10 for ; Thu, 09 Jun 2022 18:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eMc32X/LG6Z8TwD+zNHEh+hFbaMCmqWi0/o54N9U4X0=; b=V/T2/cF72+nZ5rzDzZ9B3IznZY7IG20V9kaZ9Bt3L1B5jSrEMVpwGF8ipKZN9BvJX5 CnSip0HuZzrHxWPj4sI61mF+f2qVcd/MSiF7wZDBKTMiyPTM8P8HC8MSl7uAA2K3gJAb GGPNj38ifWROv2uwLLspF5+tVZqmmNqF9Kj/3vlnS5vsvXXEFZK6jenDpgAFRliQo1g0 kwQ0Xy14y9vjvgPk1vMUvmKEbf12YbGgu8szSpbe3nUIJAKpCkDqr0axx2gjwOUA+/Gg Bd8hPgGKJpBzAmFKMtaNeY4VfYcyf1ndUjjHeByx8KFNZ+d7KrCS6JQaIuCSGhlYhUok I7hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eMc32X/LG6Z8TwD+zNHEh+hFbaMCmqWi0/o54N9U4X0=; b=5RxRFKFGfxWooERzv4F7kXbbXMxPc3thubGuba5jmBk+goWTrfOxxlhOn44F1NKRaO HMARzw9ekyI0bQG6mj1VgoPZILu1+85xZb99xM+ULI+g7tpbNIeTJ54Mqm235N/onc1M HW81RlE4NgK9Zb3g4fQ5xpgTE3PHmjcGzUdLhLA2r6DVSI7JdJdZZP5n2pdCyRLg9Ykc 4Xt3hjrsYWbXWwrCgSO+yP+XAzyo4TDxV+tqobD+1sgXcIm0TdBFz7snKI4SirLvw+Al gjMeQ13rn7tprDJbCv502+DvSEZwlfVTC2LIWqxMfo3H+s8zhuAhRDfSzjpYafj9dPcd Wp1Q== X-Gm-Message-State: AOAM533Pd7Ehs4+wEXq7Z1x3QIUfOdtC4z7z0nJh/7XqUocRiyyDPK2f QRRYG6Dmkd4YKTYrAap6tL3PPydfwgSVANRWNmg= X-Google-Smtp-Source: ABdhPJyWOfiIYYBpWqc7ZGe4OsOZkgBiTFudIrtQXr8cV4X0A9BvDpZl48t2iM7nJs27JrfHaHZoOjHSS+I/hlUeV9Y= X-Received: by 2002:a65:5504:0:b0:3fb:ac7a:ac1e with SMTP id f4-20020a655504000000b003fbac7aac1emr37635913pgr.476.1654824767177; Thu, 09 Jun 2022 18:32:47 -0700 (PDT) MIME-Version: 1.0 References: <20220606150305.1883410-1-hsinyi@chromium.org> <20220606150305.1883410-4-hsinyi@chromium.org> In-Reply-To: From: Xiongwei Song Date: Fri, 10 Jun 2022 09:32:20 +0800 Message-ID: Subject: Re: [PATCH v5 3/3] squashfs: implement readahead To: Hsin-Yi Wang Cc: Phillip Lougher , Matthew Wilcox , Xiongwei Song , Marek Szyprowski , Andrew Morton , Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654824768; a=rsa-sha256; cv=none; b=SwWSycLoEBSrN86ytc4TuX5d1ZQv2AWZNY6jj5BIu22FlrjM7YPbYTTi+8LHFOaji3u+EZ yxolJo5GnvSQqGuUwBMJnKoPPPjQSvRl3dFwStJde7lHHavs8LGyREa+hbGqKMv3/bvqNq OU2K+FA379MJg1Ei6I8CyeVTIgOY8dE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654824768; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eMc32X/LG6Z8TwD+zNHEh+hFbaMCmqWi0/o54N9U4X0=; b=EzQXbQkC05wLsuVpU2zDTVYqzVRJav0n/95i8E9xyvcpvT3sLFcbRDz4YcbY1Qp7uPiHwv XafnYisklJQDNeaj/dLDvusS8EINIunMw2TxyR3iXxJnYS3wR3Wo9sOFQvRATtBhPwTW61 jI+I9giqe2MA4vaRkQnC5LixSk0hjAc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="V/T2/cF7"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of sxwjean@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=sxwjean@gmail.com Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="V/T2/cF7"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of sxwjean@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=sxwjean@gmail.com X-Stat-Signature: naxk67875nakiz887xy64mjmeawydnmq X-Rspamd-Queue-Id: 4FE3380068 X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1654824768-312644 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 Thu, Jun 9, 2022 at 10:46 PM Xiongwei Song wrote: > > This version is bad for my test. I ran the test below > "for cnt in $(seq 0 9); do echo 3 > /proc/sys/vm/drop_caches; echo > "Loop ${cnt}:"; time -v find /software/test[0-9][0-9] | xargs -P 24 -i > cat {} > /dev/null 2>/dev/null; echo ""; done" > in 90 partitions. > > With 9eec1d897139 reverted: Sorry, it's with readahead enabled in linux 5.10. Regards, Xiongwei > 1:06.18 (1m + 6.18s) > 1:05.65 > 1:06.34 > 1:06.88 > 1:06.52 > 1:06.78 > 1:06.61 > 1:06.99 > 1:06.60 > 1:06.79 > > With this version: > 2:36.85 (2m + 36.85s) > 2:28.89 > 1:43.46 > 1:41.50 > 1:42.75 > 1:43.46 > 1:43.67 > 1:44.41 > 1:44.91 > 1:45.44 > > Any thoughts? > > Regards, > Xiongwei > > On Mon, Jun 6, 2022 at 11:03 PM Hsin-Yi Wang wrote: > > > > Implement readahead callback for squashfs. It will read datablocks > > which cover pages in readahead request. For a few cases it will > > not mark page as uptodate, including: > > - file end is 0. > > - zero filled blocks. > > - current batch of pages isn't in the same datablock. > > - decompressor error. > > Otherwise pages will be marked as uptodate. The unhandled pages will be > > updated by readpage later. > > > > Suggested-by: Matthew Wilcox > > Signed-off-by: Hsin-Yi Wang > > Reported-by: Matthew Wilcox > > Reported-by: Phillip Lougher > > Reported-by: Xiongwei Song > > Reported-by: Marek Szyprowski > > Reported-by: Andrew Morton > > --- > > v4->v5: > > - Handle short file cases reported by Marek and Matthew. > > - Fix checkpatch error reported by Andrew. > > > > v4: https://lore.kernel.org/lkml/20220601103922.1338320-4-hsinyi@chromium.org/ > > v3: https://lore.kernel.org/lkml/20220523065909.883444-4-hsinyi@chromium.org/ > > v2: https://lore.kernel.org/lkml/20220517082650.2005840-4-hsinyi@chromium.org/ > > v1: https://lore.kernel.org/lkml/20220516105100.1412740-3-hsinyi@chromium.org/ > > --- > > fs/squashfs/file.c | 124 ++++++++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 123 insertions(+), 1 deletion(-) > > > > diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c > > index a8e495d8eb86..fbd096cd15f4 100644 > > --- a/fs/squashfs/file.c > > +++ b/fs/squashfs/file.c > > @@ -39,6 +39,7 @@ > > #include "squashfs_fs_sb.h" > > #include "squashfs_fs_i.h" > > #include "squashfs.h" > > +#include "page_actor.h" > > > > /* > > * Locate cache slot in range [offset, index] for specified inode. If > > @@ -495,7 +496,128 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) > > return 0; > > } > > > > +static void squashfs_readahead(struct readahead_control *ractl) > > +{ > > + struct inode *inode = ractl->mapping->host; > > + struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; > > + size_t mask = (1UL << msblk->block_log) - 1; > > + unsigned short shift = msblk->block_log - PAGE_SHIFT; > > + loff_t start = readahead_pos(ractl) & ~mask; > > + size_t len = readahead_length(ractl) + readahead_pos(ractl) - start; > > + struct squashfs_page_actor *actor; > > + unsigned int nr_pages = 0; > > + struct page **pages; > > + int i, file_end = i_size_read(inode) >> msblk->block_log; > > + unsigned int max_pages = 1UL << shift; > > + > > + readahead_expand(ractl, start, (len | mask) + 1); > > + > > + if (file_end == 0) > > + return; > > + > > + pages = kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL); > > + if (!pages) > > + return; > > + > > + actor = squashfs_page_actor_init_special(pages, max_pages, 0); > > + if (!actor) > > + goto out; > > + > > + for (;;) { > > + pgoff_t index; > > + int res, bsize; > > + u64 block = 0; > > + unsigned int expected; > > + > > + nr_pages = __readahead_batch(ractl, pages, max_pages); > > + if (!nr_pages) > > + break; > > + > > + if (readahead_pos(ractl) >= i_size_read(inode)) > > + goto skip_pages; > > + > > + index = pages[0]->index >> shift; > > + if ((pages[nr_pages - 1]->index >> shift) != index) > > + goto skip_pages; > > + > > + expected = index == file_end ? > > + (i_size_read(inode) & (msblk->block_size - 1)) : > > + msblk->block_size; > > + > > + bsize = read_blocklist(inode, index, &block); > > + if (bsize == 0) > > + goto skip_pages; > > + > > + if (nr_pages < max_pages) { > > + struct squashfs_cache_entry *buffer; > > + unsigned int block_mask = max_pages - 1; > > + int offset = pages[0]->index - (pages[0]->index & ~block_mask); > > + > > + buffer = squashfs_get_datablock(inode->i_sb, block, > > + bsize); > > + if (buffer->error) { > > + squashfs_cache_put(buffer); > > + goto skip_pages; > > + } > > + > > + expected -= offset * PAGE_SIZE; > > + for (i = 0; i < nr_pages && expected > 0; i++, > > + expected -= PAGE_SIZE, offset++) { > > + int avail = min_t(int, expected, PAGE_SIZE); > > + > > + squashfs_fill_page(pages[i], buffer, > > + offset * PAGE_SIZE, avail); > > + unlock_page(pages[i]); > > + } > > + > > + squashfs_cache_put(buffer); > > + continue; > > + } > > + > > + res = squashfs_read_data(inode->i_sb, block, bsize, NULL, > > + actor); > > + > > + if (res == expected) { > > + int bytes; > > + > > + /* Last page may have trailing bytes not filled */ > > + bytes = res % PAGE_SIZE; > > + if (bytes) { > > + void *pageaddr; > > + > > + pageaddr = kmap_atomic(pages[nr_pages - 1]); > > + memset(pageaddr + bytes, 0, PAGE_SIZE - bytes); > > + kunmap_atomic(pageaddr); > > + } > > + > > + for (i = 0; i < nr_pages; i++) { > > + flush_dcache_page(pages[i]); > > + SetPageUptodate(pages[i]); > > + } > > + } > > + > > + for (i = 0; i < nr_pages; i++) { > > + unlock_page(pages[i]); > > + put_page(pages[i]); > > + } > > + } > > + > > + kfree(actor); > > + kfree(pages); > > + return; > > + > > +skip_pages: > > + for (i = 0; i < nr_pages; i++) { > > + unlock_page(pages[i]); > > + put_page(pages[i]); > > + } > > + > > + kfree(actor); > > +out: > > + kfree(pages); > > +} > > > > const struct address_space_operations squashfs_aops = { > > - .read_folio = squashfs_read_folio > > + .read_folio = squashfs_read_folio, > > + .readahead = squashfs_readahead > > }; > > -- > > 2.36.1.255.ge46751e96f-goog > > > >