Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5668483rwr; Mon, 1 May 2023 09:04:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CW8/bd7KXbKS9JTHHHQjOmKX+ATFLbMX9YbmXcNV9/NEP9De0gedVRKxZBZN4x7GsgvZd X-Received: by 2002:a17:902:f683:b0:1a6:9762:6eed with SMTP id l3-20020a170902f68300b001a697626eedmr19331934plg.22.1682957052977; Mon, 01 May 2023 09:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682957052; cv=none; d=google.com; s=arc-20160816; b=INn57XPdueozfr7jeM5HsNDNKvdWlQUeHxFLPMV+maanL+Xqy7/klCeGs1CLJ0lGNR ZRjS203Y8jvlIN6bx31S7x8yJ8pT1gUjUeIpMN+LdqIuV4gMmR77ud8VNuLT0ymLhRJ0 OzjgTh4koqBM7zrvzo3uYNXH75vi+gBoV67ksxBuA9meRD1f2KH9qX3gL6JhmRntLP7I oJQIdTIwI5q9Mp7WP2vq4pmnXcVmF2LepyvRh8HYB9Oat9IhpES5+xwuaGHjHKrBpIda mL08bDo4jwIiMMgkcxb6fuH0AHcMjCOfieupZH0LsO0Ep0Lb/eFRZxyxPW80u0T6s6mC 74yA== 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:content-language:cc:to:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=5bPsp2g0VrYtWLji3rbRewaAYsdPIfyZMtsPhsv1sbI=; b=PZmHpEcGcFaLs1GXT6KI/30Ft/kloofiZjgQZexm7+1ms3ch+TwFuD/mf+gHcDNwBl 0ws4eMU3lEsq3FKplcJhhI1UNugSveAoYxspk8sSTwWqPAGsZmHf2dh2ppZlKiMvSD70 bhY8FyViV3UQS8z8MFHMnRz3YEfCTyBGmA76C4AoD0DsEhdIPLHJAAy2joQz5a3cehaj n3LIDhFGQsb+0z8ldts1e9c2prGQUcUdBeuWoUS8/Ns94tY7e8P3CCniJzwWH9oB4FNl 6qOaW5XfbUKfidWyK+/Ozg6dgSWBSQDSjbX9QO3iuLnXyFWzeY+0F8bOrTeNMjIhakxT kLcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="tTmKA/fe"; 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 f4-20020a170902684400b00199200945a3si28540749pln.74.2023.05.01.09.03.55; Mon, 01 May 2023 09:04:12 -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="tTmKA/fe"; 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 S232518AbjEAQBD (ORCPT + 99 others); Mon, 1 May 2023 12:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232442AbjEAQBB (ORCPT ); Mon, 1 May 2023 12:01:01 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ADFC10C6 for ; Mon, 1 May 2023 09:00:58 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230501160056euoutp01317b1ba6bdef14caf2a0d0e553072a60~bEFgIcoAL2917829178euoutp01J for ; Mon, 1 May 2023 16:00:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230501160056euoutp01317b1ba6bdef14caf2a0d0e553072a60~bEFgIcoAL2917829178euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1682956856; bh=5bPsp2g0VrYtWLji3rbRewaAYsdPIfyZMtsPhsv1sbI=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=tTmKA/fekwc01cr/2d+EY/ip/WsHT2VkebkpLF/wmjaXpP6VDG7AoZcIvEpdwmcVl nLB7Yc6yol6Rp/hwvPo6Q0o1CkN0fBQxHZMQVEKRsF0TeXJnLxIhUvR+Fbi2juXpRj KEELYea7KK1YllEWzdM6c3+dWNJc7WmwPxdcnC6g= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230501160054eucas1p2215c8b65b65a2b6e83d32e9760f172f7~bEFe6oP7k1454814548eucas1p2I; Mon, 1 May 2023 16:00:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id FC.98.42423.632EF446; Mon, 1 May 2023 17:00:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230501160054eucas1p13f970393e34ba354e9cc0f8d4d730873~bEFehod0e1104711047eucas1p1l; Mon, 1 May 2023 16:00:54 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230501160054eusmtrp26dd77538775ce6d394c1cc85cf621753~bEFefz-OM1544915449eusmtrp2I; Mon, 1 May 2023 16:00:54 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-07-644fe236b3c6 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E6.CB.14344.632EF446; Mon, 1 May 2023 17:00:54 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230501160054eusmtip26faf98cd3d8de1b1aebc0c3abf9fa111~bEFeTEYl01679116791eusmtip2z; Mon, 1 May 2023 16:00:54 +0000 (GMT) Received: from [106.110.32.65] (106.110.32.65) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 1 May 2023 17:00:52 +0100 Message-ID: <6dcf69ee-21cd-ae06-c250-e991652989ac@samsung.com> Date: Mon, 1 May 2023 18:00:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 17/17] fs: add CONFIG_BUFFER_HEAD To: Matthew Wilcox , Luis Chamberlain CC: Christoph Hellwig , Daniel Gomez , Jens Axboe , Miklos Szeredi , "Darrick J. Wong" , Andrew Morton , David Howells , , , , , , , , , , Content-Language: en-US From: Pankaj Raghav In-Reply-To: Content-Transfer-Encoding: 7bit X-Originating-IP: [106.110.32.65] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGKsWRmVeSWpSXmKPExsWy7djP87pmj/xTDC49VLOYs34Nm8Xqu/1s Fh9uTmKyOLn6MZvFu6bfLBaXn/BZrFx9lMli7y1ti5nz7rBZXFrkbrFn70mg1K45bBb31vxn tbhw4DSrxa4/O9gtbkx4ymjxbPdGZovfP+awOQh5bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeL x+4Fn5k8dt9sY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+2vvAdNXusg49qZ6HH2b/ Ub02a+dnl3YlluKMREMt5qLiRAAR06BPsQMAAA== X-CMS-MailID: 20230501160054eucas1p13f970393e34ba354e9cc0f8d4d730873 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20230501154622eucas1p2d9dea99a75a8b2ccc347fc6e8ca7decb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230501154622eucas1p2d9dea99a75a8b2ccc347fc6e8ca7decb References: <20230424054926.26927-1-hch@lst.de> <20230424054926.26927-18-hch@lst.de> X-Spam-Status: No, score=-8.7 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 >> No but the only place to add that would be in the block cache. Adding >> that alone to the block cache doesn't fix the issue. The below patch >> however does get us by. > > That's "working around the error", not fixing it ... probably the same > root cause as your other errors; at least I'm not diving into them until > the obvious one is fixed. > >> >From my readings it does't seem like readahead_folio() should always >> return non-NULL, and also I couldn't easily verify the math is right. > > readahead_folio() always returns non-NULL. That's guaranteed by how > page_cache_ra_unbounded() and page_cache_ra_order() work. It allocates > folios, until it can't (already-present folio, ENOMEM, EOF, max batch > size) and then calls the filesystem to make those folios uptodate, > telling it how many folios it put in the page cache, where they start. > > Hm. The fact that it's coming from page_cache_ra_unbounded() makes > me wonder if you updated this line: > > folio = filemap_alloc_folio(gfp_mask, 0); > > without updating this line: > > ractl->_nr_pages++; > > This is actually number of pages, not number of folios, so needs to be > ractl->_nr_pages += 1 << order; > I already had a patch which did the following: ractl->_nr_pages += folio_nr_pages(folio); but the variable `i` in the loop was not updated properly (assumption of zero order folio). This now fixes the crash: @@ -210,7 +210,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, unsigned long index = readahead_index(ractl); gfp_t gfp_mask = readahead_gfp_mask(mapping); unsigned long i; - + int order = 0; /* * Partway through the readahead operation, we will have added * locked pages to the page cache, but will not yet have submitted @@ -223,6 +223,9 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, */ unsigned int nofs = memalloc_nofs_save(); + if (mapping->host->i_blkbits > PAGE_SHIFT) + order = mapping->host->i_blkbits - PAGE_SHIFT; + filemap_invalidate_lock_shared(mapping); /* * Preallocate as many pages as we will need. @@ -245,7 +248,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, continue; } - folio = filemap_alloc_folio(gfp_mask, 0); + folio = filemap_alloc_folio(gfp_mask, order); if (!folio) break; if (filemap_add_folio(mapping, folio, index + i, @@ -259,7 +262,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, if (i == nr_to_read - lookahead_size) folio_set_readahead(folio); ractl->_workingset |= folio_test_workingset(folio); - ractl->_nr_pages++; + ractl->_nr_pages += folio_nr_pages(folio); + i += folio_nr_pages(folio) - 1; } > various other parts of page_cache_ra_unbounded() need to be examined > carefully for assumptions of order-0; it's never been used for that > before. all the large folio work has concentrated on > page_cache_ra_order() As you have noted here, this needs to be examined more carefully. Even though the patches fix the crash, fio with verify option fails (i.e write and read are not giving the same output). I think it is better to send an RFC patch series on top of Christoph's work with optional BUFFER_HEAD to iron out some core issues/bugs.