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 CBFA3C28B2B for ; Wed, 17 Aug 2022 15:31:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 349E86B0073; Wed, 17 Aug 2022 11:31:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D2E66B0074; Wed, 17 Aug 2022 11:31:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 173A18D0001; Wed, 17 Aug 2022 11:31:05 -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 018396B0073 for ; Wed, 17 Aug 2022 11:31:04 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CC873C15C2 for ; Wed, 17 Aug 2022 15:31:04 +0000 (UTC) X-FDA: 79809472848.30.36F0E7A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id BA518401C6 for ; Wed, 17 Aug 2022 15:31:03 +0000 (UTC) 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=xjF2dRJwFCHabLautL7vUkzPczlUuGRC5hw2s/8u9fs=; b=BZCn+BEmdt4YalsavwMnIXmtb3 qcZPuN9KoeN6UkrNTfX6WGeRSRC6Dz0tEK2Bp2SJLxlswObHU1UXpxes38fGhBg2ll5nXfY8CwOyH z7A2kE803VX9GhqakDG6ZPAWjwcVH+1DnFL3/fNEV6QPk6g9QxaglrweEW6K47MnzRdDG0ypPUkTT iplFVabjM0b2VsdpNE0t+73NvRyPAphX4wYO4Q6nvxskM3T+ibpa5Bjv/GwKUFarNMIbQxtHb076J ZeB+RVf/PjpbB+m/9A3Fpnrfvb0G7UY+RtTI8HiaLiXUqpkpnU0Oa5EJzUeWX8m/jqat5ckVUeMpp Ntb9Z6Hw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOL0U-008MPO-A2; Wed, 17 Aug 2022 15:30:58 +0000 Date: Wed, 17 Aug 2022 16:30:58 +0100 From: Matthew Wilcox To: Andrew Morton Cc: Guixin Liu , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Kent Overstreet Subject: Re: [RFC PATCH] mm/filemap.c: fix the timing of asignment of prev_pos Message-ID: References: <1660744317-8183-1-git-send-email-kanie@linux.alibaba.com> <20220817081657.5e8332cec593621fccfacf93@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220817081657.5e8332cec593621fccfacf93@linux-foundation.org> ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BZCn+BEm; spf=none (imf17.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=1660750263; a=rsa-sha256; cv=none; b=WcxCrhNhJi3UvVoH2KvMtEvYlEkiWWNIfdvPFZ1U082b/nv52SQMT4mJq/trCbXzIzcQUA rCvbek3CnCBwQ8tZ2CcBqUJwjlK6lgccsmZXtPcesYsS8mLG5fwxq9i5qAGiG9ZO1L2ZN/ 0W7iYj0/0OhQjJMUtQgal1vc/pe/fuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660750263; 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=xjF2dRJwFCHabLautL7vUkzPczlUuGRC5hw2s/8u9fs=; b=G3Ujub0+YFH7qwqTG0F43v6cwQzRJt9ob853ehAvf7Jz7yytFyTs+QH30/8qi/EOaNu0ml mlCgCbzMo/bSQBvJewzcbYJolfXEUCkskLfJee3EOcQWTbaoOT4rXV5gxyHa3wW8KyvvLv bXAbJUDWGTYjROX2oT2xotve+Bh8h3Y= Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BZCn+BEm; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: qhodfbaphner53fj97dw3f6zptxptaqo X-Rspamd-Queue-Id: BA518401C6 X-HE-Tag: 1660750263-907398 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000081, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Aug 17, 2022 at 08:16:57AM -0700, Andrew Morton wrote: > On Wed, 17 Aug 2022 21:51:57 +0800 Guixin Liu wrote: > > > The prev_pos should be assigned before the iocb->ki_pos is incremented, > > so that the prev_pos is the exact location of the last visit. > > > > Fixes: 06c0444290cec ("mm/filemap.c: generic_file_buffered_read() now > > uses find_get_pages_contig") > > Signed-off-by: Guixin Liu > > > > --- > > Hi guys, > > When I`m running repetitive 4k read io which has same offset, > > I find that access to folio_mark_accessed is inevitable in the > > read process, the reason is that the prev_pos is assigned after the > > iocb->ki_pos is incremented, so that the prev_pos is always not equal > > to the position currently visited. > > Is this a bug that needs fixing? > > It looks wrong to me and it does appear that 06c0444290cecf0 did this > unintentionally. That commit was the start of a problem, but I think I restored the original behaviour in 5ccc944dce3d. You were part of that discussion back in June: https://lore.kernel.org/linux-mm/20220602082129.2805890-1-yukuai3@huawei.com/