From patchwork Thu Apr 22 00:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12217201 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=-24.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 C72B5C43460 for ; Thu, 22 Apr 2021 00:35:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8674661409 for ; Thu, 22 Apr 2021 00:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343924AbhDVAgB (ORCPT ); Wed, 21 Apr 2021 20:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343930AbhDVAgA (ORCPT ); Wed, 21 Apr 2021 20:36:00 -0400 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E333AC06174A for ; Wed, 21 Apr 2021 17:35:24 -0700 (PDT) Received: by mail-oo1-xc2f.google.com with SMTP id e12-20020a056820060cb02901e94efc049dso4663704oow.9 for ; Wed, 21 Apr 2021 17:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=6Bo/151Dx6SDWNJTYqVzspMT+/EPJItqGJiDq5IFPhE=; b=lZQSVZ93U5rlTaerOyCDp4WG8GDFqrv9GVEloGw69RwcLC0p+ynNriAAKh5cZDNNXx CAsk+uxmxIfAIl7Wsg1oFEbCHaU1TWUHOr3cj2p+741eCW2yUgwyWyzG3UoCAxw/EC1U aAj653CNTXmYfHx4RdS2hgqpaDLUe29SnqfUf+798jlihuK4S1MWHUJRv57Osz46TJU3 Rm5Gq/Dfqq280Hg20VRpEyq9kshF1QKKyaJo7+nc9AzzVgmvqvOImJYlGcQqQtW597zj 8ZZM4vdDmKael5jMXrnDl8FMdarffo0VnJb6CoJQpbA+MRsEwoR8rCa4TQhcbh/hvifp 1arA== 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:message-id:user-agent :mime-version; bh=6Bo/151Dx6SDWNJTYqVzspMT+/EPJItqGJiDq5IFPhE=; b=Mf6nmNJYl94alUwFOw3sVtO7MBStww+l9BfvmXVHcG0K8W7EHedwe36Spu6o9JRJhJ HXtezHmN42CiixRhBh4/nZmMVxjB8MU59tKjxaIw5MLQ2ecaDfRE0o4ojFqzm++tdgTK MQPdGS9Tw/HjjJJQkMfIPcHN7Bi/HQ6yPVp7Bce5R/HdrogPr8gzmbhWIr3s4LCLcJQE tPyj7xGTFl/rkpbjufC5vPSu7km30fRdGb6R5ccbJiPD4TuYBWQ1Jl6kbB87ythGUqam vrEJzGXU6zhJjsYjvWD9Tirbw2ewMZQsBVM+BJqkRnxPs4JcB7fMYRfsuD96zIwVRruM bXJg== X-Gm-Message-State: AOAM5325AwZ/8Te8A8zpr6LIYBV7scHD9cxBh5HbOAf4erqpDRlJqiFX AGw3SK4tnl0ZgpHrlTOwlCq4dA== X-Google-Smtp-Source: ABdhPJwFzhYjOmf19XP6vFVF5ayvGGwv/sOGwQVx1iv6azXxg6h6OiC9H6bNf01WjKJQRw0sJ9zcrg== X-Received: by 2002:a4a:851a:: with SMTP id k26mr395631ooh.27.1619051724106; Wed, 21 Apr 2021 17:35:24 -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 h28sm255325oof.47.2021.04.21.17.35.22 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 21 Apr 2021 17:35:23 -0700 (PDT) Date: Wed, 21 Apr 2021 17:35:11 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Matthew Wilcox , William Kucharski , Christoph Hellwig , Jan Kara , Dave Chinner , Hugh Dickins , Johannes Weiner , "Kirill A. Shutemov" , Yang Shi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 0/2] mm/filemap: fix 5.12-rc regressions Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Andrew, I'm very sorry, this is so late: I thought we had already tested 5.12-rc's mm/filemap changes earlier, but running xfstests on 32-bit huge tmpfs last weekend revealed a hang (fixed in 1/2); then looking closer at test results, found SEEK_HOLE/SEEK_DATA discrepancies that I'd previously assumed benign (surprises there not surprising when huge pages get used) were in fact indicating regressions in the new seek_hole_data implementation (fixed in 2/2). Complicated by xfstests' seek_sanity_test needing some adjustments to work correctly on huge tmpfs; but not yet submitted because I've more to do there. seek_sanity combo patch attached, to allow anyone here to verify the fixes on generic 308 285 286 436 445 448 490 539. Up to you and Matthew whether these are rushed last minute into 5.12, or held over until the merge window, adding "Cc: stable"s. 1/2 mm/filemap: fix find_lock_entries hang on 32-bit THP 2/2 mm/filemap: fix mapping_seek_hole_data on THP & 32-bit mm/filemap.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) Thanks, Hugh xfstests: seek_sanity_test adjustments Huge tmpfs habitually failed generic/285 seek_sanity_test 11.08 and 12.08 because the near-EOF data was written at an offset of 1MiB into the x86_64 2MiB huge page allocated for it, so SEEK_DATA then found an offset 1MiB lower than expected. Work around this by extending that extra 1MiB at EOF to alloc_size in test11() and test12(). Huge tmpfs on i386 without PAE habitually failed generic/490 seek_sanity_test 20.03 and 20.04: because its 4MiB alloc_size, used for bufsz, happens to scrape through the initial filsz EFBIG check, but its overflows fail on those two tests. tmpfs does not use ext[23] triply indirect blocks anyway, so although it's an interesting test, just take the easy way out: clamping to 2MiB, which skips test 20. Surely something cleverer could be done, but it's not worth the math. And while there, renumber second and third 20.03 to 20.04 and 20.05. Adjust seek_sanity_test to carry on after its first failure. Adjust seek_sanity_test to show file offsets in hex not decimal. Temporarily signed off, but to be split into four when posting to fstests@vger.kernel.org; and needs a fifth to fix generic/436 too (which currently passes because of an old stupidity in mm/shmem.c, but will probably need adjustment here once the kernel is fixed). Signed-off-by: Hugh Dickins --- src/seek_sanity_test.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) --- a/src/seek_sanity_test.c +++ b/src/seek_sanity_test.c @@ -207,7 +207,7 @@ static int do_lseek(int testnum, int subtest, int fd, off_t filsz, int origin, ret = !(errno == ENXIO); } else { - x = fprintf(stdout, "%02d.%02d %s expected %lld or %lld, got %lld. ", + x = fprintf(stdout, "%02d.%02d %s expected 0x%llx or 0x%llx, got 0x%llx. ", testnum, subtest, (origin == SEEK_HOLE) ? "SEEK_HOLE" : "SEEK_DATA", (long long)exp, (long long)exp2, (long long)pos); @@ -322,6 +322,9 @@ static int test20(int fd, int testnum) loff_t bufsz, filsz; bufsz = alloc_size; + /* i386 4MiB bufsz passes filsz EFBIG check but too big for 20.3 20.4 */ + if (bufsz > 2*1024*1024) + bufsz = 2*1024*1024; buf = do_malloc(bufsz); if (!buf) goto out; @@ -349,9 +352,9 @@ static int test20(int fd, int testnum) /* Offsets inside ext[23] triply indirect block */ ret += do_lseek(testnum, 3, fd, filsz, SEEK_DATA, (12 + bufsz / 4 + bufsz / 4 * bufsz / 4 + 3 * bufsz / 4 + 5) * bufsz, filsz - bufsz); - ret += do_lseek(testnum, 3, fd, filsz, SEEK_DATA, + ret += do_lseek(testnum, 4, fd, filsz, SEEK_DATA, (12 + bufsz / 4 + 7 * bufsz / 4 * bufsz / 4 + 5 * bufsz / 4) * bufsz, filsz - bufsz); - ret += do_lseek(testnum, 3, fd, filsz, SEEK_DATA, + ret += do_lseek(testnum, 5, fd, filsz, SEEK_DATA, (12 + bufsz / 4 + 8 * bufsz / 4 * bufsz / 4 + bufsz / 4 + 11) * bufsz, filsz - bufsz); out: if (buf) @@ -667,8 +670,13 @@ out: */ static int test12(int fd, int testnum) { + blksize_t extra = 1 << 20; + + /* On huge tmpfs (others?) test needs write before EOF to be aligned */ + if (extra < alloc_size) + extra = alloc_size; return huge_file_test(fd, testnum, - ((long long)alloc_size << 32) + (1 << 20)); + ((long long)alloc_size << 32) + extra); } /* @@ -677,8 +685,13 @@ static int test12(int fd, int testnum) */ static int test11(int fd, int testnum) { + blksize_t extra = 1 << 20; + + /* On huge tmpfs (others?) test needs write before EOF to be aligned */ + if (extra < alloc_size) + extra = alloc_size; return huge_file_test(fd, testnum, - ((long long)alloc_size << 31) + (1 << 20)); + ((long long)alloc_size << 31) + extra); } /* Test an 8G file to check for offset overflows at 1 << 32 */ @@ -1289,9 +1302,7 @@ int main(int argc, char **argv) for (i = 0; i < numtests; ++i) { if (seek_tests[i].test_num >= teststart && seek_tests[i].test_num <= testend) { - ret = run_test(&seek_tests[i]); - if (ret) - break; + ret |= run_test(&seek_tests[i]); } }