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 1C15EC25B08 for ; Wed, 17 Aug 2022 15:17:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 085C38D0002; Wed, 17 Aug 2022 11:17:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 035476B0074; Wed, 17 Aug 2022 11:17:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E66028D0002; Wed, 17 Aug 2022 11:17:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D7CF06B0073 for ; Wed, 17 Aug 2022 11:17:02 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ABED214157A for ; Wed, 17 Aug 2022 15:17:02 +0000 (UTC) X-FDA: 79809437484.10.50960D9 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf03.hostedemail.com (Postfix) with ESMTP id F32182004F for ; Wed, 17 Aug 2022 15:17:01 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 25A46B81DED; Wed, 17 Aug 2022 15:17:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADFB1C433D6; Wed, 17 Aug 2022 15:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1660749418; bh=bvyIzZJrRa0bm3MH19GN/vBsiy/w3mR0xQi5d0Eecok=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fz6z0mdUDidus0UBEQuLMFF9undb497YyoXteTH+zr7rQFFrA+zzafteY6foWTcMR 4yEfvAVwEu273CEHonTWw9ZYaA94lLX7YlP3MbBuNoYBTTlECm5C/DkgKbM9UZ45zn NGkQS87KP4cBHiqgOFqEuh0SdGOuOD/Nqot7S0FU= Date: Wed, 17 Aug 2022 08:16:57 -0700 From: Andrew Morton To: Guixin Liu Cc: willy@infradead.org, 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: <20220817081657.5e8332cec593621fccfacf93@linux-foundation.org> In-Reply-To: <1660744317-8183-1-git-send-email-kanie@linux.alibaba.com> References: <1660744317-8183-1-git-send-email-kanie@linux.alibaba.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660749422; a=rsa-sha256; cv=none; b=Oa05lhTXWFM7qEQTWceOdqmCBffnMLfqX8U6TLllXSeokpvSbpPQtQpb/l/Ji6bnOVey3N mr/4zkVkAHwQYy//tBV6+ze+PsrnQFMh0bhfpaZtn7eCO+Qctoh+CxgNYDv+l/xhdIUfSa mNBPaUdoYAcCZUslcaAyZRZAMoPT6ko= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=fz6z0mdU; dmarc=none; spf=pass (imf03.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660749422; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w5GCSofqXeowMcRecr60fHI0eLCfbQiGuqqFcp0CEnQ=; b=mR+PTGN6IFwQFnFuUyyBPaYC8z5LZqhit6UZvhtN5WKULHejkihcZdARNr22S2Ufp5LyJV BEQDY2teSe6WEBIm7lfORAcvOJdAzBIssfQ6keiezyxghzG3ECcULF2IcMPSfhdTK0Frey VlBDdSioIDVyvjX4hyJvYklO98Bl0dI= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: F32182004F X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=fz6z0mdU; dmarc=none; spf=pass (imf03.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: 88ysgunma44rmca1achrhauwu3nbe988 X-HE-Tag: 1660749421-657176 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, 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. > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -2703,8 +2703,8 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, > copied = copy_folio_to_iter(folio, offset, bytes, iter); > > already_read += copied; > - iocb->ki_pos += copied; > ra->prev_pos = iocb->ki_pos; > + iocb->ki_pos += copied; > > if (copied < bytes) { > error = -EFAULT; So we significantly messed up pagecache page aging and nobody noticed for nearly two years. What does this tell us :( I'd be interested if anyone can demonstrate runtime effects from this change. If yes then I'll add cc:stable. If no then I'll ask why we even bothered.