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 B64D2C4708D for ; Wed, 4 Jan 2023 14:36:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BA938E0003; Wed, 4 Jan 2023 09:36:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3446C8E0001; Wed, 4 Jan 2023 09:36:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 215268E0003; Wed, 4 Jan 2023 09:36:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0CD288E0001 for ; Wed, 4 Jan 2023 09:36:26 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C65CE1A0C45 for ; Wed, 4 Jan 2023 14:36:25 +0000 (UTC) X-FDA: 80317367130.29.6A2BA2A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 03BA1A000E for ; Wed, 4 Jan 2023 14:36:22 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="pKnH/xHw"; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672842984; a=rsa-sha256; cv=none; b=4iGojD8ppYGN6Fdv6ciF1hQLqrAsmpbmjJm3ybW6HAdVayL8N5tvuPfwAhcZW/btR42o4o B8en9p7UR4NAakSaJhIOSiEB6bq3Xj5yKNf9ZKwz1jtpEJj21X2rxCT4Zz9Xg0Zd5H8gFp cZgs6kDjioHPvrJEoR2i1NBD33vCa34= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="pKnH/xHw"; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672842984; 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=QHnWJx9+mbeV4moLLlTd7s3x2Qm+/U2GwtkrSTjYFc8=; b=5g/GDe6R18xpzp10jARr/+Yhgr1tveBeuz4lXXBHi7skCaXw/kwAjsAA/YTCPQ0PERu9yW ayeKF9ET7uuC0xopT+8lKiWa/qbEucBlsABFP2ycf4d16yeVAyYVt5W6z7vKVValdFWmJq 3oYJaMEM+dr0rIjcwzmpj2AP2CCRMfk= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=QHnWJx9+mbeV4moLLlTd7s3x2Qm+/U2GwtkrSTjYFc8=; b=pKnH/xHwYTX6XoSUdXv9a6E/Ij EBvp1gIUuvItVhLsQKvmww8drzlnWjXinjwcvmvaMV2NueVgvzP1CgxyF3N6iMFS2y1GomMiIdhaG +1fjY8S5RFv0FBH6Wcry0ftUUwi+tOxK9QUgLiQkW+yxvoWkMxTf9+75ohLUsvzzxx3TaUjifoJAG swsIHn4wjvMEADFQyNTqhN3rXqhvSp4YShrmjfvPmL0GBfjKi+xfNlhBXKoJfJSf1NpdWo0qszY5W kEuDHIWq/aFccixteNgJczXMNdpRxZVuux4BU8KoqAYQ9t4hbynJxdVwswrTPcohmoyWXiD0Vxy0L XXHKOpAQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pD4sT-00F7WX-PC; Wed, 04 Jan 2023 14:36:25 +0000 Date: Wed, 4 Jan 2023 14:36:25 +0000 From: Matthew Wilcox To: coolqyj@163.com Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, qian@ddn.com Subject: Re: [PATCH] mm/filemap: fix page end in filemap_get_read_batch Message-ID: References: <20230104032124.72483-1-coolqyj@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230104032124.72483-1-coolqyj@163.com> X-Rspam-User: X-Rspamd-Queue-Id: 03BA1A000E X-Rspamd-Server: rspam01 X-Stat-Signature: npyyciyz4gdsfskss7e1ixhrdhmtakor X-HE-Tag: 1672842982-803219 X-HE-Meta: U2FsdGVkX1+GdxlYOKVLVIu9dObCy0W3cTrr+i80Y3LuZyJCYPwULSKavB6S4uGam2YUBBAapd6Qv6K22b3Ek6dJNim840exQYnTXULzd2MZLw2E5thmh4/4pA30/fAX3ude5Q1ZOkdjnhIVTygncXHnLB3qMBqzgaCBbxmGS2gWyCjX3SqL1E7xAeeva9844x6BUi20B9jzstwFiF3cN3umq0KxPPja26uMFr6J7+e72Kuhcoxe5i+CyotoDfjLiY0Y9tazs3jyMj8uDBv+Wj+j9PKcAxj6X93zJX6GEHqLJq0eIQtRX39yYGf22/wIBiqXihyPEg/q393vcz6srh24oYPGUzPOQYLpzeCNozkk9pWxPvoQx3K54E8KS7XPoPJuiooETNwV+hKQTwIBcXSV/XCeN45mMGacocRZN4wyZAtkEEANOfUWvdhV76gx57WpcF8aEf8Ipu1OmsRDexfacZfJbPF4fAAg8LNisccrfCw0c0h1NJ//YvpllmCgDG0hdHXLisyCCI5qbbwEMYuBykFVuYrQFPudNCsr7bZB/E32eT+Ji62grDKV3IMgGR+c26A/F+qtNRgg+agL7RLUsaGfewaIRv0eJ6RE1iboKX4a61rTjd8EgUtXReoAj8OcL38YTCwBZvyKor6RHnfCcEW/xfZZOsF4lwbyh1R/8r1WsLFoftxEDGlsJYhG1P5kFo+Y8egkFUvgAK2VdxlpoBlkHRDPiWWQOR8LSuKycdb+eOc9yrVCp/hJOeuYkCS3B3LT7COKtIZYzyAIIIoiCONgk6ELvXWb91KqJlZDV9gUpenJjS5KmcFsHunKd8pnwF7mKnUS/e8rEgEfQP17t3DO7gNcYdGghYbg/8k1WoSff2u6MYIVPnLCTE7xkpguGz/Il5NKeaOhvqv3at2NCUNpVK4MLT7/Fm1SOCMaSKpNXGuEiDAU219xHVlWPVYbFghEsRXc/ViDbyI vZ/LUBDN 93ceFhk7ha9hPMb8= 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 Wed, Jan 04, 2023 at 11:21:24AM +0800, coolqyj@163.com wrote: > From: Qian Yingjin > > I was running traces of the read code against an RAID storage > system to understand why read requests were being misaligned > against the underlying RAID strips. I found that the page end > offset calculation in filemap_get_read_batch() was off by one. > > When a read is submitted with end offset 1048575, then it > calculates the end page for read of 256 when it should be 255. > "last_index" is the index of the page beyond the end of the read > and it should be skipped when get a batch of pages for read in > @filemap_get_read_batch(). > > The below simple patch fixes the problem. This code was introduced > in kernel 5.12. Thanks for diagnosing & sending a patch. However, I'd really prefer to work in terms of 'max' instead of 'last_index' in that function. Would this work for you? +++ b/mm/filemap.c @@ -2595,13 +2595,13 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, if (fatal_signal_pending(current)) return -EINTR; - filemap_get_read_batch(mapping, index, last_index, fbatch); + filemap_get_read_batch(mapping, index, last_index - 1, fbatch); if (!folio_batch_count(fbatch)) { if (iocb->ki_flags & IOCB_NOIO) return -EAGAIN; page_cache_sync_readahead(mapping, ra, filp, index, last_index - index); - filemap_get_read_batch(mapping, index, last_index, fbatch); + filemap_get_read_batch(mapping, index, last_index - 1, fbatch); } if (!folio_batch_count(fbatch)) { if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ))