Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3985226imm; Tue, 29 May 2018 18:51:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKzzmoV0yFU3o/TxLlYKQNGQmVFEGjp0Y32er5MQC6bwsCnvHV3Ifo4WK730fYnr80cQ8oB X-Received: by 2002:a63:ad08:: with SMTP id g8-v6mr636582pgf.74.1527645091916; Tue, 29 May 2018 18:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527645091; cv=none; d=google.com; s=arc-20160816; b=DNlV2tIDTaumHEG5xVLRHWegMriV/4ElNKlm2cnMpDRFk9MfAG3aBAKL1B+w/MF36w D/DxX0o/iFF7yeRs6R+K6OFrouiYpnr1Wu7Ak6KnzQEG7OEVWnfGh401bqUBt08EjE8l PO0b5tCf1gjv5LWOGfyk2eM6Th0Ep2vjatJ1YhS3o4yw7ecz3R5sXYVpjxpegxO1FpGF P7RwrnE4jWzaQGlnsy+p0ru+9/VAe2FrqTwO6mEeV35N3wtiTdfsoCeLHhvFsPni96Gq 7lcBXlD5GDncWo8qicBCs02/qKiyYHo+4+LW5E0KO7JqSU32NMzhtqcm1AhhFPhQRien lVEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature:arc-authentication-results; bh=rk6L67amihLasV7Rgdo4882G4UKqGuhDiwGTfBOscvU=; b=BsMgza7v8Z98wAX9DK2K1jZdF2wQVuPc7yCYVDPHMHhEJhwUOU32Wp0fO0xRT/8A1K K/SErnzDQ036lIHz8nYza0I1rBjuTn65XU4SGmZJKI1/eWJfNHewXDv/9rL2mkSgVAoK vUxWa+31Tz0VrJ0nSfeVoI3SsEDRQbowV8eSRQxG7ywh+qL17/kSW6Txc0duJv6dda5R 4SPNYD7Z56F/QsiPYzzAQCuzegHQfDeOLud9cFazPphSPexmBaY4NO+iZWMr+mVMTzby V+4NzvtfHex1WCaNe5lmI+Za7UEMwCTODlNJBlymut1TRmm4PeaUhaPVpFImP2nolnjT cFcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bLaXBBg8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id b18-v6si18480190pgs.668.2018.05.29.18.51.18; Tue, 29 May 2018 18:51:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bLaXBBg8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S968625AbeE3Bui (ORCPT + 99 others); Tue, 29 May 2018 21:50:38 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:39386 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968432AbeE3Bug (ORCPT ); Tue, 29 May 2018 21:50:36 -0400 Received: by mail-pg0-f67.google.com with SMTP id w12-v6so6175138pgc.6 for ; Tue, 29 May 2018 18:50:36 -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=rk6L67amihLasV7Rgdo4882G4UKqGuhDiwGTfBOscvU=; b=bLaXBBg8UQ8O14lMJwwdClS5O3Ronkg9wjJMEgMKq6nTU9InGuR/UkCddeTyJSiP7n qf1wPl/hVZ6SNz3ApNE2sqA6uKrAy5BVObtEN5np7Yx2BDc1pOUIIenfWwDPk4Xq4NoN WFC/6q4omx2O3lLPbdzARcBrcUZOUuOxpADLjPBS3GG6iZlqXzzFrKhq/qYTNsGLGxp4 PbIk7sP7YRf/Hm+PWGfvPVkCMsy+GNFFOl49QRducmzkm9AvIA/ZC/6usMrML3fVK1Vl 7fD3q3YxEfKGK3ldZ9JvFLt67UR/ti8sGRgXgAnkhSUIKBA33dSbk6iYhko22ByTMO+/ PIuQ== 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=rk6L67amihLasV7Rgdo4882G4UKqGuhDiwGTfBOscvU=; b=GoFE7aqzhVnKF4YrOp3PM5JowECpczVFzjqC72YIYAwWv1ulPF8dQyqmG9gsiojyPa dfvcCDNWXTVwUvV8XLEy7S+2fPtIPciX8Msb8tKqBiur79RRZmBhNi3CyAVlGbgenExF pvXeIWp7k4Ay1jpxs/+Z3Wa4Ek8n2ApAs3zx2xQPgQN/760SLo75OlwIUsW+APYCx2JP jUb4hPSOQDN03Ba5Jc72i2Cw/T19hSV1W24L3mW25baqNbYxfnOLs18poAlH19YTKNvd utsE/HxEDj+cO7nDKYYySLrtn+9+ivT3SXoa8hFcjRyZ1aHzn0YAcCurpcG9S++YB8zT O2sw== X-Gm-Message-State: ALKqPwdNIDjN+kjGh+n36qzrmmmkGqrLsxK0sRt0WyGucEQ5eIvbD3Bw tvPkEs7XM1NjBgLE7s4tv3u2Nw== X-Received: by 2002:a62:3f4f:: with SMTP id m76-v6mr797923pfa.109.1527645035363; Tue, 29 May 2018 18:50:35 -0700 (PDT) Received: from [100.112.72.59] ([104.133.9.107]) by smtp.gmail.com with ESMTPSA id a23-v6sm14093953pgd.85.2018.05.29.18.50.34 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 18:50:34 -0700 (PDT) Date: Tue, 29 May 2018 18:50:22 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Konstantin Khlebnikov , "Kirill A. Shutemov" , Nicholas Piggin , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm/huge_memory.c: __split_huge_page() use atomic ClearPageDirty() Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Swapping load on huge=always tmpfs (with khugepaged tuned up to be very eager, but I'm not sure that is relevant) soon hung uninterruptibly, waiting for page lock in shmem_getpage_gfp()'s find_lock_entry(), most often when "cp -a" was trying to write to a smallish file. Debug showed that the page in question was not locked, and page->mapping NULL by now, but page->index consistent with having been in a huge page before. Reproduced in minutes on a 4.15 kernel, even with 4.17's 605ca5ede764 ("mm/huge_memory.c: reorder operations in __split_huge_page_tail()") added in; but took hours to reproduce on a 4.17 kernel (no idea why). The culprit proved to be the __ClearPageDirty() on tails beyond i_size in __split_huge_page(): the non-atomic __bitoperation may have been safe when 4.8's baa355fd3314 ("thp: file pages support for split_huge_page()") introduced it, but liable to erase PageWaiters after 4.10's 62906027091f ("mm: add PageWaiters indicating tasks are waiting for a page bit"). Fixes: 62906027091f ("mm: add PageWaiters indicating tasks are waiting for a page bit") Signed-off-by: Hugh Dickins --- It's not a 4.17-rc regression that this fixes, so no great need to slip this into 4.17 at the last moment - though it makes a good companion to Konstantin's 605ca5ede764. I think they both should go to stable, but since Konstantin's already went into rc1 without that tag, we shall have to recommend Konstantin's to GregKH out-of-band. mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 4.17-rc7/mm/huge_memory.c 2018-04-26 10:48:36.019288258 -0700 +++ linux/mm/huge_memory.c 2018-05-29 18:14:52.095512715 -0700 @@ -2431,7 +2431,7 @@ static void __split_huge_page(struct pag __split_huge_page_tail(head, i, lruvec, list); /* Some pages can be beyond i_size: drop them from page cache */ if (head[i].index >= end) { - __ClearPageDirty(head + i); + ClearPageDirty(head + i); __delete_from_page_cache(head + i, NULL); if (IS_ENABLED(CONFIG_SHMEM) && PageSwapBacked(head)) shmem_uncharge(head->mapping->host, 1);