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 2FA75C433EF for ; Mon, 6 Jun 2022 01:10:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B6C08D0003; Sun, 5 Jun 2022 21:10:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 669238D0002; Sun, 5 Jun 2022 21:10:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52BA78D0003; Sun, 5 Jun 2022 21:10:11 -0400 (EDT) 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 42E258D0002 for ; Sun, 5 Jun 2022 21:10:11 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F0F6234FA4 for ; Mon, 6 Jun 2022 01:10:10 +0000 (UTC) X-FDA: 79546029780.10.3E1840B Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id EC24EC0070 for ; Mon, 6 Jun 2022 01:09:26 +0000 (UTC) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LGb2r0h3XzgYch; Mon, 6 Jun 2022 09:08:20 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 6 Jun 2022 09:10:06 +0800 Received: from [10.174.176.73] (10.174.176.73) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 6 Jun 2022 09:10:05 +0800 Subject: Re: [PATCH -next] mm/filemap: fix that first page is not mark accessed in filemap_read() To: Matthew Wilcox CC: , , , , , , References: <20220602082129.2805890-1-yukuai3@huawei.com> From: Yu Kuai Message-ID: Date: Mon, 6 Jun 2022 09:10:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.73] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EC24EC0070 X-Stat-Signature: c7pne54tzzusupppatgt3tdgu71dc7m6 Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of yukuai3@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukuai3@huawei.com X-HE-Tag: 1654477766-366550 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000474, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022/06/03 2:30, Matthew Wilcox wrote: > On Thu, Jun 02, 2022 at 04:21:29PM +0800, Yu Kuai wrote: >> In filemap_read(), 'ra->prev_pos' is set to 'iocb->ki_pos + copied', >> while it should be 'iocb->ki_ops'. > > Can you walk me through your reasoning which leads you to believe that > it should be ki_pos instead of ki_pos + copied? As I understand it, > prev_pos is the end of the previous read, not the beginning of the > previous read. Hi, Matthew The main reason is the following judgement in flemap_read(): if (iocb->ki_pos >> PAGE_SHIFT != -> current page ra->prev_pos >> PAGE_SHIFT) -> previous page folio_mark_accessed(fbatch.folios[0]); Which means if current page is the same as previous page, don't mark page accessed. However, prev_pos is set to 'ki_pos + copied' during last read, which will cause 'prev_pos >> PAGE_SHIFT' to be current page instead of previous page. I was thinking that if prev_pos is set to the begining of the previous read, 'prev_pos >> PAGE_SHIFT' will be previous page as expected. Set to the end of previous read is ok, however, I think the caculation of previous page should be '(prev_pos - 1) >> PAGE_SHIFT' instead. > > For consequence, >> folio_mark_accessed() will not be called for 'fbatch.folios[0]' since >> 'iocb->ki_pos' is always equal to 'ra->prev_pos'. > > I don't follow this, but maybe I'm just being slow. I mssing a condition here: Under small io sequential read, folio_mark_accessed() will not be called for 'fbatch.folios[0]' since 'iocb->ki_pos' is always equal to 'ra->prev_pos'. Thanks, Kuai > > . >