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=-19.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL 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 8652BC433ED for ; Thu, 22 Apr 2021 05:55:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 233AE61417 for ; Thu, 22 Apr 2021 05:55:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 233AE61417 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 99FB56B006C; Thu, 22 Apr 2021 01:55:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94EC16B006E; Thu, 22 Apr 2021 01:55:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C80E6B0070; Thu, 22 Apr 2021 01:55:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 5F0FE6B006C for ; Thu, 22 Apr 2021 01:55:52 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 120738248047 for ; Thu, 22 Apr 2021 05:55:52 +0000 (UTC) X-FDA: 78058941744.06.7DD4B46 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by imf19.hostedemail.com (Postfix) with ESMTP id BF6D690009F6 for ; Thu, 22 Apr 2021 05:55:27 +0000 (UTC) Received: by mail-qk1-f175.google.com with SMTP id v7so17198328qkj.13 for ; Wed, 21 Apr 2021 22:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=Yd2gs0ulaQk3ryBAG/T9ZY2Wi9SgLd9cQYKXihYv8FY=; b=qgLnNEFAyhsCr5cTqAilhCCR88xu+Lo0ZCHkoYuo9qoV9qF5+bl0g2GDlTmSFyksax ac+CqrVtJ4ALOfyvVhbTdPiah0c0VuiBGi8wYRpGPinVYsDjJbXJE5s//i9QIYjdeYdU LM0uyBCx6cLA8P4esZfCYogttHX/0pJrFcX9MeLotQzuNT4H7z7XqntpI2jcW//5pxdq 3jWYc4yiEbbY365WjsxyBm81g2fUS35RYgRJRARaOalJlPngmh2neZzzi4sa0NUbmRUj F50jwME1yvUTFGtN9FO4UmbErfRtmFuW77Q9nsSBUeJGvk9mVMXDyipPC9PhhiGmcRu9 xEKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=Yd2gs0ulaQk3ryBAG/T9ZY2Wi9SgLd9cQYKXihYv8FY=; b=CwQhJhYBR7wGgO8OLar4DoTMtf/HktgLOsPe4mQlF6ydXg/UG3Ll++D3ZOGyefCbWT vk03FZA06gkBwdqMNWTQxu1O0wimlcNwfydOx7VCkSXEnVkdgN8FHO+6QFXm8WHSIzBg ntRVWNG9QZ7vXJwrx4dLaQzISBYY5sqjCMgaizrMQtDAJaSZ7Hic9kMbtjXrbivK1gDc /gDcGOIvCpsmTUp+DnXRdrHVhD1obJgryDpNpBEZ/fzfuwOMLNfDdCoFzDT5HzP6gM+D FpOQJU9DbIi7vxnSBejE/j3K22IPqZsxkEMbHWJ+F7f4kj4oUt6Mv4K31YXk9NgFi+4k U7OA== X-Gm-Message-State: AOAM5335rUKDJsJ+2CC49NumhYkOI+JlpsfSpX/DOGfOLpzdbepKKIiv +dOMD4xIvkCfQExK2moOQKnlnQ== X-Google-Smtp-Source: ABdhPJwTn+aHqXWQgw/QpAWr54vJAvqSR/wNms5ahjY3dZ7KwzD9PAegW91quU4DGMZ0H997GGZ9kQ== X-Received: by 2002:a05:620a:4143:: with SMTP id k3mr1849181qko.497.1619070950786; Wed, 21 Apr 2021 22:55:50 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id i21sm1505944qtr.94.2021.04.21.22.55.49 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 21 Apr 2021 22:55:50 -0700 (PDT) Date: Wed, 21 Apr 2021 22:55:37 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Matthew Wilcox cc: Hugh Dickins , 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 In-Reply-To: <20210422011631.GL3596236@casper.infradead.org> Message-ID: References: <20210422011631.GL3596236@casper.infradead.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BF6D690009F6 X-Stat-Signature: ma6e7jhrwoczugza9ukjrw3puiaees4u Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=mail-qk1-f175.google.com; client-ip=209.85.222.175 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619070927-196774 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 Thu, 22 Apr 2021, Matthew Wilcox wrote: > 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? That is a good question. Sprinkling u64s was the first thing I tried, and I'd swear that it made a good difference at the time; but perhaps that was all down to just the one on xas.xa_index << PAGE_SHIFT. Or is it possible that one of the other bugs led to a negative loff_t, and the casts got better behaviour out of that? Doubtful. What I certainly recall from yesterday was leaving out one (which?) of the casts as unnecessary, and wasting quite a bit of time until I put it back in. Did I really choose precisely the only one necessary? Taking most of them out did give me good quick runs just now: I'll go over them again and try full runs on all machines. You'll think me crazy, but yesterday's experience leaves me reluctant to change without full testing - but agree it's not good to leave ignorant magic in. > > > 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. Thanks for the info: I did search around in your various patch series from last October, and failed to find a decider there: I imagined that when you started on compound pages for more efficient I/O, there would be no necessity to align them (whereas huge pmd mappings of shared files make the alignment important). Anyway, assuming natural alignment is easiest - but it's remarkable how few places need to rely on it. > > > @@ -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. Ah, there I was simply following what the author of seek_page_size() had chosen, and I think that's the right thing to do in today's tree: let's see who that author was... hmm, someone called Matthew Wilcox :)