Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp60443pxy; Wed, 21 Apr 2021 18:30:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDQg3koUWaHlIOiRdiE+DRd2zgo/pwnOyM/k9y7bD2H0jWfXWMyHdGm8xDKSFkBn+njbqj X-Received: by 2002:a17:90b:2355:: with SMTP id ms21mr14436863pjb.226.1619055046135; Wed, 21 Apr 2021 18:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619055046; cv=none; d=google.com; s=arc-20160816; b=qdMXXuhlHNuGGcZOGwdqE++7YbXp8Uv6EAwvQZNOrYuqy0F5dgDSawXkCkmJ+m3lnW NPeFOeOHsV1Hgu4G4TMHdgyk//BxiM0Tm4VzzEyRirWbF+/fHKKRYIYqUXYALBd7BBvM q4b9zpfAsWeuOJ1vdNGU+toE5ZnbIZML16Hz9BjRNZbQgNygEn1bJSK8+4LiSdYoei3w 7Fi29rzflAVRl1/Ty4Du02bP1/4MM0wJocmtvrCI/XSMuIKpC/g0NQ/w9KCsjSTyogb5 w4VED71rcIpp0ndShSP3rAGz3wyMWgwfDQzD0uHP7GwNyieJb9R2Uyt2JXNpqjAwpK83 e1WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=zQ3oRqFEaYwUupWBz0Ob+9p/m78IpqRSVRzOwl1NExU=; b=ZkQPdfp+4V8vhNKJoW3GdmjgzIZnizzKMD1iY15DeteOkw1mt2oGmFuI7olXed0E1Y P5+NV5cYnI4wx3/QterkNmtdpwpvL8Dn6i2aZcojQErHXdABTzgvL5mAZQ1iCi7HQO5t 0mIfHA6DlEVQDRGdqWsL4Rt7F/nOmn44N+iU98N8iABF6Jz5TAPKqaNILFefbP1JODDJ v4j2Tfo6WZWUOA5far6JnG10okG5mjQS9kFMWwIP1Yg4i9KewM/US/5mX0STR0ZTA5te b2vBo/1dRwryN8kGsfOqkYpHFK0DVL/oUfVtKoDMa+szmNNLPqsBu+RFcffxaLxCsy0F LUzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YA4YGWCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n19si1339363pgv.400.2021.04.21.18.30.34; Wed, 21 Apr 2021 18:30:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YA4YGWCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234856AbhDVAiM (ORCPT + 99 others); Wed, 21 Apr 2021 20:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343905AbhDVAiM (ORCPT ); Wed, 21 Apr 2021 20:38:12 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB811C06138A for ; Wed, 21 Apr 2021 17:37:36 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id 66so5220212qkf.2 for ; Wed, 21 Apr 2021 17:37:36 -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=zQ3oRqFEaYwUupWBz0Ob+9p/m78IpqRSVRzOwl1NExU=; b=YA4YGWCqTJFmMsrOHxlI/UdbFCODBETZ0PKicjaq8W+MO7k74dvfKTRVJ5blFY7Bat i4hOjfxV+MY28sfBh7CZQ2S4mSLZcTJzzwU5phkRvU0O95Qp8gQvGugTxKyjvJOTEZ/4 vYnaIZGmMbA1ipt0DA1S73cMSVJRkDXPuK3n2oFOkJI7QjXuQVL9NNaBxfT3GSKYDU1h THOWkOTIgOZnvrWCMm3JEH/LYbRfEoVLD6GZib4mLzDzIvE8WRoIKI7csn9sKv8qET9b wuHpi3aE4SL8MkROICgmJxe7MRbe0q72Zyp7h8cUbriKNb5YqtAekLueCKKnBVBzNGPt AV/A== 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=zQ3oRqFEaYwUupWBz0Ob+9p/m78IpqRSVRzOwl1NExU=; b=f67f1AnZD8WqT9jSZYDwcDFaURSB+uQgCGvrgqpkhW/cGFJCOxSP8ZNL5dCAAPdpSn /13jjRg5acm0ENYyWDqxRv/VZXTs4JfpltB3dAgMKzIC8YYpOi3DdCIht9CjbCWXQBeB 8PYxcZVKcEJ0ywPyE2K+rxPo0721/s+qW1BsVSF5Djjh39pIf7kbv/sQ4MTan87uOodY xSFDQk1c6xmbqbp+h7Ubo6fKsVdIcsLo9QYOfOJ0OzYU0k+m498C6BE35/zz4+9OWBhG yuqKgQuzA3GOZSX9oj9L2d3/pSd+NBIxLKDVtvr03VQxQQvOuMlRIJwUsUNSZfH2rtZM TWHA== X-Gm-Message-State: AOAM531v4A3aBMEOPp+Ny0Uos9i3f3Hr3L2D27euEoeGrs3Fr4DqfdPJ wXkcTy1uRdr9+EReLRJ53j66vg== X-Received: by 2002:a37:8bc1:: with SMTP id n184mr1021888qkd.268.1619051855892; Wed, 21 Apr 2021 17:37:35 -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 h65sm933294qkc.128.2021.04.21.17.37.34 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 21 Apr 2021 17:37:35 -0700 (PDT) Date: Wed, 21 Apr 2021 17:37:33 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Hugh Dickins , Matthew Wilcox , 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: [PATCH 1/2] mm/filemap: fix find_lock_entries hang on 32-bit THP In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No problem on 64-bit, or without huge pages, but xfstests generic/308 hung uninterruptibly on 32-bit huge tmpfs. Since 4.13's 0cc3b0ec23ce ("Clarify (and fix) MAX_LFS_FILESIZE macros"), MAX_LFS_FILESIZE is only a PAGE_SIZE away from wrapping 32-bit xa_index to 0, so the new find_lock_entries() has to be extra careful when handling a THP. Fixes: 5c211ba29deb ("mm: add and use find_lock_entries") Signed-off-by: Hugh Dickins --- mm/filemap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- 5.12-rc8/mm/filemap.c 2021-02-26 19:42:39.812156085 -0800 +++ linux/mm/filemap.c 2021-04-20 23:20:20.509464440 -0700 @@ -1969,8 +1969,14 @@ unlock: put: put_page(page); next: - if (!xa_is_value(page) && PageTransHuge(page)) - xas_set(&xas, page->index + thp_nr_pages(page)); + if (!xa_is_value(page) && PageTransHuge(page)) { + unsigned int nr_pages = thp_nr_pages(page); + + /* Final THP may cross MAX_LFS_FILESIZE on 32-bit */ + xas_set(&xas, page->index + nr_pages); + if (xas.xa_index < nr_pages) + break; + } } rcu_read_unlock();