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 DAC91C433EF for ; Mon, 9 May 2022 12:44:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 382296B0071; Mon, 9 May 2022 08:44:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30A556B0073; Mon, 9 May 2022 08:44:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A9A66B0074; Mon, 9 May 2022 08:44:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0C34E6B0071 for ; Mon, 9 May 2022 08:44:14 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CC8AC30593 for ; Mon, 9 May 2022 12:44:13 +0000 (UTC) X-FDA: 79446172386.24.6D15F4E Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf03.hostedemail.com (Postfix) with ESMTP id 0620C2008C for ; Mon, 9 May 2022 12:44:05 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id l11-20020a17090a49cb00b001d923a9ca99so12695162pjm.1 for ; Mon, 09 May 2022 05:44:13 -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=eC0RMdr4sr80NtqXByW27oEckXzItp2H+rCND678K8k=; b=K13hOML1ZrQ/e9a16HYVLqvUWoWidKiPNDnUO63gGwcHZg1PMOhhiuqbiew50aHuL9 Em9ce9sk+KHVHrFwFiS8YxK5J5Ag77bxqiPrYdFbtRW8X3RJN+XPsL9yrZo4SS+l8AF1 6oOY7rdVG6eMEa/inmUalJstcJcFKEJ644Ywxf1sKib+06OtKVBQnYa2ZV5kCSh8okoh sGmOh/50OVecP03lIzBraOiT0LMIrsacRjlQv7NKstB0rzMLQLzjJvvwW6YEQPsoXwf1 3/7lqxujibd1EotM3JV3gpAO3EcaV34bAN+f/ItrMnlG2VVlHRw3UycMgB3GmJVbzS5S nmcQ== 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=eC0RMdr4sr80NtqXByW27oEckXzItp2H+rCND678K8k=; b=57bnBFVrz542ZhsdaSFm/epxTeGClNOTL1L1PrHiTLjO7XWdpvHhNl5XLkrqYB6Plo Q5ure1vjohU7O5UypND5qNB0G7iyalnQ0KLfDk6zK+d5DyWkuKj3NVssQ5oifvcpll15 kV3S1Ms6S3hDxxyhVQj3K7KL8r56bq4m54Ulr+5sf814z5RKUHyyCKbWd5zImYNo9s/0 t3P3vgX2NSHR3WjEj72diF62JCmZQeHmGxE/2GdK6E93kDUB7Jg96absKdpiyfUi2rlc GCC0Ql4zMnyhRVm5S9f+oCYXKdDaKwpBNJRPFn+9lpvFpJh5X4zjUeddicpBoH6S254p Y5PQ== X-Gm-Message-State: AOAM530HkCn1fPb2pWutnheS4pxd5JAXlTYb085BhrrZLvI3cv8JfDJe mxN9N/9ZUXbK5iizoHXd1HqBtzwZ5iZSqZ8ZJd8= X-Google-Smtp-Source: ABdhPJzQbzVdQDIk3e5heORo/g8aR0o8/0bTe28s9gtH11DL3NgT5AzIuhlExLYqaKFv1BJLwO3t2AnlIlTDR4m2Wdc= X-Received: by 2002:a17:90a:343:b0:1cb:234a:a975 with SMTP id 3-20020a17090a034300b001cb234aa975mr26352663pjf.83.1652100252272; Mon, 09 May 2022 05:44:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Xiongwei Song Date: Mon, 9 May 2022 20:43:45 +0800 Message-ID: Subject: Re: squashfs performance regression and readahea To: Hsin-Yi Wang Cc: Matthew Wilcox , "Song, Xiongwei" , "phillip@squashfs.org.uk" , "linux-mm@kvack.org" , "squashfs-devel@lists.sourceforge.net" Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=K13hOML1; spf=pass (imf03.hostedemail.com: domain of sxwjean@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=sxwjean@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0620C2008C X-Stat-Signature: nqmab8gt9gtnu3ijtj9d6otjjd384r46 X-HE-Tag: 1652100245-140985 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: Hi Hsin-Yi and Matthew, With the patch from the attachment on linux 5.10, ran the command as I mentioned earlier, got the results below: 1:40.65 (1m + 40.65s) 1:10.12 1:11.10 1:11.47 1:11.59 1:11.94 1:11.86 1:12.04 1:12.21 1:12.06 The performance has improved obviously, but compared to linux 4.18, the performance is not so good. Moreover, I wanted to test on linux 5.18. But I think I should revert 9eec1d897139 ("squashfs: provide backing_dev_info in order to disable read-ahead"), right? Otherwise, the patch doesn't work? Regards, Xiongwei On Mon, May 9, 2022 at 3:11 PM Hsin-Yi Wang wrote: > > On Mon, May 9, 2022 at 3:05 PM Hsin-Yi Wang wrote: > > > > On Mon, May 9, 2022 at 12:45 AM Matthew Wilcox wrote: > > > > > > On Sun, May 08, 2022 at 02:46:40PM +0000, Song, Xiongwei wrote: > > > > I am facing a performance regression on squashfs. There are many squashfs > > > > partitions on our board. I am doing the operations below on 90 squashfs > > > > partitions: > > > > > > Hi Xiongwei. Thanks for the report. Hsin-Ye and I have been working on > > > this problem off-list. Hsin-Ye, could you send the latest version? > > > > Hi Matthew, > > > > This is the patch of the latest version. Since it's just being > > reviewed halfway done, I posted the patch here, or should I send it to > > the list directly? > > > The indent seems broken when I pasted it here. Resend in the attachment. > > > Thanks > > > > From 03558dcaab93ed3c32498eb70c7f2b1382b218d6 Mon Sep 17 00:00:00 2001 > > From: Hsin-Yi Wang > > Date: Sun, 10 Oct 2021 21:22:25 +0800 > > Subject: [PATCH] squashfs: implement readahead > > > > 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. > > - current batch of pages isn't in the same datablock or not enough in a > > datablock. > > Otherwise pages will be marked as uptodate. The unhandled pages will be > > updated by readpage later. > > > > Signed-off-by: Hsin-Yi Wang > > --- > > fs/squashfs/file.c | 72 +++++++++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 71 insertions(+), 1 deletion(-) > > > > diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c > > index 89d492916dea..20ec48cf97c5 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 > > @@ -494,7 +495,76 @@ static int squashfs_readpage(struct file *file, > > struct page *page) > > 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; > > + size_t shift = msblk->block_log - PAGE_SHIFT; > > + loff_t req_end = readahead_pos(ractl) + readahead_length(ractl); > > + 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; > > + u64 block = 0; > > + int bsize, res, i, index; > > + int file_end = i_size_read(inode) >> msblk->block_log; > > + int max_pages = 1UL << shift; > > + > > + readahead_expand(ractl, start, (len | mask) + 1); > > + > > + if (readahead_pos(ractl) + readahead_length(ractl) < req_end) > > + return; > > + > > + nr_pages = readahead_count(ractl); > > + pages = kmalloc_array(nr_pages, sizeof(void *), GFP_KERNEL); > > + if (!pages) > > + return; > > + > > + actor = squashfs_page_actor_init_special(pages, nr_pages, 0); > > + if (!actor) > > + goto out; > > + > > + for (;;) { > > + nr_pages = __readahead_batch(ractl, pages, max_pages); > > + if (!nr_pages) > > + break; > > + > > + if (readahead_pos(ractl) >= i_size_read(inode) || > > + file_end == 0 || nr_pages < max_pages) > > + goto skip_pages; > > + > > + index = pages[0]->index >> shift; > > + bsize = read_blocklist(inode, index, &block); > > + res = squashfs_read_data(inode->i_sb, block, bsize, NULL, > > + actor); > > + > > + if (res >=0 && (pages[nr_pages - 1]->index >> shift) == index) > > + for (i = 0; i < nr_pages; i++) > > + SetPageUptodate(pages[i]); > > + > > + for (i = 0; i < nr_pages; i++) { > > + unlock_page(pages[i]); > > + put_page(pages[i]); > > + } > > + } > > + > > + kfree(actor); > > + 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 = { > > - .readpage = squashfs_readpage > > + .readpage = squashfs_readpage, > > + .readahead = squashfs_readahead > > }; > > -- > > 2.31.0