Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7718718ioo; Fri, 3 Jun 2022 11:59:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLZmYdovAZF3rCntVAh2eahXkNEaYlb2Hsrz1NHp5fZBRx5AHd96DSNXXhnDmQKvsyu4rV X-Received: by 2002:a05:6402:3482:b0:42d:e063:7c1d with SMTP id v2-20020a056402348200b0042de0637c1dmr12542550edc.40.1654282781360; Fri, 03 Jun 2022 11:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654282781; cv=none; d=google.com; s=arc-20160816; b=NSeOfw3G8Ycsy/fhX5RKg5UPSKaR7HVkaERbJIlqtiAyAFWGzoXqJfGtjGCORaANrY bTjHdqx7NAiDL2gdtJQCkv1Bzpu5nsKt2Opk34WAlQCPfnNZq+skdgEoUD5j6frx8Kcl SYtPSeox9wdN8eEIvY4+e/xfl2bUIC8NvI/dl4RhGWvM9d47kGIqQI8CKjT/wJmA1pz3 doRFKnZA5CWYZsEF2AJ7+eE45tX1I14OI6O8KZM1nYOBlrKC6sPhIMNG9Y1KOw2ERzk2 oOi3/kATh7IxM5Km8/gU3RQVh9xYWSr5jPJehFpuNedIc+gOGDWkliCd63884mKqtId2 9TUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=ccW9O603lDuGqsKU/x3fpqBU4KZeJccXslpvNCfaor4=; b=LiAtVGe4cp9KBqjwt+4ey91Rvtqp69GCa8rwkuXElwL5Q0BV9OhFG1yvI7JYDHIvJF nOmYAqi6/IUMPUOmJU8TneuMjpxfcdB2h7Nspdk2bybq5VADbm1H+3CX5oP7bpg7C+k1 S6AgY5BijLlpjNust7rA+tvAb0yvWauIaac0C7gj/VlWGh/o+lL5AZNYmITNCKeZTqsG cbtuqRtI4Y/JPAZwpSNBFMpW1kqoig1XtkA1E5aepKB6rDivBoxtt9b8dM/rhE/9mgJ/ VukYpymZoJdWuxXLMAgKBfAIVI9RsxgwIRqxoiG1VGjy4IQ4gSlcI9NLThB7SkRBvdgq N4mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rmgQBUY6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a170906794600b007031f4e9894si8681625ejo.776.2022.06.03.11.59.15; Fri, 03 Jun 2022 11:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rmgQBUY6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244430AbiFCMyc (ORCPT + 99 others); Fri, 3 Jun 2022 08:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbiFCMya (ORCPT ); Fri, 3 Jun 2022 08:54:30 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD9636E08 for ; Fri, 3 Jun 2022 05:54:28 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220603125423euoutp0182e7cca1d8cf5fa5319cec91eafeffc7~1HX2Efzog1440814408euoutp01C for ; Fri, 3 Jun 2022 12:54:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220603125423euoutp0182e7cca1d8cf5fa5319cec91eafeffc7~1HX2Efzog1440814408euoutp01C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1654260863; bh=ccW9O603lDuGqsKU/x3fpqBU4KZeJccXslpvNCfaor4=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=rmgQBUY6N7xskEZcRqw2yaBTF9LJcwOU2lWIJzO5SOdTSK3ifCtVsXM2fOeJAqOBP tnLAfKQ+jnw3oQs8+X+8WssbKW+3NwQuHky1QOK0C1kY5CwEey1v2W61xyMk9CFPGk 9j7RqW4nnX7RmfXJZZs1elEV+Ed4W9z1HTDO98s4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220603125422eucas1p1aaf212c4e94fa3aacb5a98a5b8257ba0~1HX1ptMRT0068000680eucas1p1W; Fri, 3 Jun 2022 12:54:22 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 71.18.10067.E740A926; Fri, 3 Jun 2022 13:54:22 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220603125421eucas1p17da286a3e7f2d4759aa4c7639dd62f75~1HX1FChv-0107801078eucas1p1G; Fri, 3 Jun 2022 12:54:21 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220603125421eusmtrp256cf7b3873dfa5f427dac42ea9fb59f3~1HX1EH_av0625406254eusmtrp2u; Fri, 3 Jun 2022 12:54:21 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-24-629a047e5f7c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F5.98.09095.D740A926; Fri, 3 Jun 2022 13:54:21 +0100 (BST) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220603125421eusmtip24f45cf71d8b5f6e60954a841ef9535e4~1HX0UkGeM0882208822eusmtip2B; Fri, 3 Jun 2022 12:54:21 +0000 (GMT) Message-ID: Date: Fri, 3 Jun 2022 14:54:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v4 3/3] squashfs: implement readahead Content-Language: en-US To: Hsin-Yi Wang , Phillip Lougher , Matthew Wilcox , Xiongwei Song Cc: Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , Andrew Morton , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org From: Marek Szyprowski In-Reply-To: <20220601103922.1338320-4-hsinyi@chromium.org> Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7djPc7p1LLOSDM5ukbOYs34Nm8WmQ2/Y LCa0bme2uLxrDpvFvTX/WS06Vt5jtTjas5nN4uqueovfP4Din3a9Z7W49u4Mm8X3B5uZHHg8 ZjdcZPFoOfKW1WPzCi2PTZ8msXucmPGbxWP3gs9MHlO+Pmf2+LxJzmP9lq1MAZxRXDYpqTmZ ZalF+nYJXBmNDz8xFrxXr1j2XKGBcZN8FyMnh4SAiUT7hU3sILaQwApGiUdTcroYuYDsL4wS cxpbmCGcz4wSHTfXssB03O3Zyw6RWM4oMXvOOhYI5yOjxKp968CqeAXsJG6ePsIIYrMIqEjc P/+LHSIuKHFy5hOwGlGBJ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yx7 rtDAuEm+i5GTQ0LAROJuz152EFtIYCmjxPZ70hBxGYmT0xpYIWxhiT/Xuti6GLmAat4zSlxd uY8ZJMErYCdx8/QRRhCbRUBF4v75X+wQcUGJkzOfsIDYogJJEvP2rgarERawlHiwazlYL7OA uMStJ/OZQIaKCKxilFi9cwYrROIOk8T1BmaIi7IlOjq/gdlsAoYSXW9BruDk4BSwlnj7/x07 RL2ZRNfWLkYIW15i+9s5zBMYhWYhuWMWkn2zkLTMQtKygJFlFaNIamlxbnpusaFecWJucWle ul5yfu4mRmAkbzv2c/MOxnmvPuodYmTiYDzEKMHBrCTCWzZvZpIQb0piZVVqUX58UWlOavEh RlNgYExklhJNzgemkrySeEMzA1NDEzNLA1NLM2MlcV7Pgo5EIYH0xJLU7NTUgtQimD4mDk6p BqY9VXsa1Fs/vFN5syKGz2z/9Wj/KpuIQpfgm1ecl3/LK15z7nPauqdvOaK5ZjOdn/bZq/h1 x1kHFtHgJxU1VyQdnPs6w7ZIrq2eHXX6eOdb9vkPDhlNZZjql33298Rbv8KW6P4S3GS4KpBH tHiR0B3j5e1lIQbVyteYg0+mOfk+fqF/3P7CLK/Q9ZNO1Dy4yVEyQaZzO9tlwxXXf/lvX2+h dnTbEy7xsnmPqlSv3WlMSCw90OJzpMnkWommrgrDszs7Hj/YcXqKhd7OwNvup47MdF6yYZHW zc0XrZmuBdx4r9BZJR11KTY10F/O3LOtwaLJdTqz1Z3r7fqbX/p7Bzb8O8K4fsOPC1kaJwVm T7JSYinOSDTUYi4qTgQAzrgXF20DAAA= X-CMS-MailID: 20220603125421eucas1p17da286a3e7f2d4759aa4c7639dd62f75 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220603125421eucas1p17da286a3e7f2d4759aa4c7639dd62f75 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220603125421eucas1p17da286a3e7f2d4759aa4c7639dd62f75 References: <20220601103922.1338320-1-hsinyi@chromium.org> <20220601103922.1338320-4-hsinyi@chromium.org> X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 01.06.2022 12:39, 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 or not enough in a > 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 > --- This patch landed recently in linux-next as commit 95f7a26191de ("squashfs: implement readahead"). I've noticed that it causes serious issues on my test systems (various ARM 32bit and 64bit based boards). The easiest way to observe is udev timeout 'waiting for /dev to be fully populated' and prolonged booting time. I'm using squashfs for deploying kernel modules via initrd. Reverting aeefca9dfae7 & 95f7a26191deon on top of the next-20220603 fixes the issue. Let me know how I can help debugging this issue. There is no hurry though, because the next week I will be on holidays. > v3->v4: Fix a few variable type and their locations. > 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 | 97 +++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 96 insertions(+), 1 deletion(-) > > diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c > index a8e495d8eb86..df7ad4b3e99c 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,101 @@ 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) || > + nr_pages < max_pages) > + 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; > + > + 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++) > + 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 > }; Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland