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 X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43F76C433B4 for ; Thu, 22 Apr 2021 01:18:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CDBD761435 for ; Thu, 22 Apr 2021 01:18:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDBD761435 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3FA776B006E; Wed, 21 Apr 2021 21:18:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BD086B0070; Wed, 21 Apr 2021 21:18:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FE266B0071; Wed, 21 Apr 2021 21:18:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 005206B006E for ; Wed, 21 Apr 2021 21:18:04 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A88071801751B for ; Thu, 22 Apr 2021 01:18:04 +0000 (UTC) X-FDA: 78058241688.37.0316AE0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id DDE9EA00039C for ; Thu, 22 Apr 2021 01:18:01 +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=+y6x2KmR9DmMzgd0umtxzcK+z2fQYDMGZRmfOOmeeOk=; b=Q2bBEcMjl6hxoF++IHEUTUHMg5 S/EbsDe3Cmp4JGvsvBpRVn56BGW//MdYalQ7MSo3oTEuqUYY5zvHiz9vwLTTlD61OgbO5xak4KBSr rrbRjOb6SSNoTCwvzc3VmMJTMbE78D3RnmCwRrvwbR2XhnRQ4TPq6V6Vp6Gymlsu/Qb/DcqkUxlFA Ofvef2GT2PyTMhk8VRwCzEqtoxBYAQWdzyt/negf/nShmy6+E4do8X/tdaDJ5edQe6XjYvQh2fduh zAbym0tbkph7tdoxD5F6DR+Zk8UFH1Z5I9aHewiT522mk5ycWKIoSCIE/ME9dhefUG3dwdPmUpePE Jw1+iaYg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lZNxH-00HGun-AD; Thu, 22 Apr 2021 01:16:41 +0000 Date: Thu, 22 Apr 2021 02:16:31 +0100 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , William Kucharski , Christoph Hellwig , Jan Kara , Dave Chinner , Johannes Weiner , "Kirill A. Shutemov" , Yang Shi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 2/2] mm/filemap: fix mapping_seek_hole_data on THP & 32-bit Message-ID: <20210422011631.GL3596236@casper.infradead.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: sxwi33cb6kosb49pnwat8x3u1ekba383 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DDE9EA00039C Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619054281-173038 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, Apr 21, 2021 at 05:39:14PM -0700, Hugh Dickins wrote: > No problem on 64-bit without huge pages, but xfstests generic/285 > and other SEEK_HOLE/SEEK_DATA tests have regressed on huge tmpfs, > and on 32-bit architectures, with the new mapping_seek_hole_data(). > Several different bugs turned out to need fixing. > > u64 casts added to stop unfortunate sign-extension when shifting > (and let's use shifts throughout, rather than mixed with * and /). That confuses me. loff_t is a signed long long, but it can't be negative (... right?) So how does casting it to an u64 before dividing by PAGE_SIZE help? > Use round_up() when advancing pos, to stop assuming that pos was > already THP-aligned when advancing it by THP-size. (But I believe > this use of round_up() assumes that any THP must be THP-aligned: > true while tmpfs enforces that alignment, and is the only fs with > FS_THP_SUPPORT; but might need to be generalized in the future? > If I try to generalize it right now, I'm sure to get it wrong!) No generalisation needed in future. Folios must be naturally aligned within a file. > @@ -2681,7 +2681,8 @@ loff_t mapping_seek_hole_data(struct add > > rcu_read_lock(); > while ((page = find_get_entry(&xas, max, XA_PRESENT))) { > - loff_t pos = xas.xa_index * PAGE_SIZE; > + loff_t pos = (u64)xas.xa_index << PAGE_SHIFT; > + unsigned int seek_size; I've been preferring size_t for 'number of bytes in a page' because I'm sure somebody is going to want a page larger than 2GB in the next ten years.