From patchwork Thu Sep 5 06:21:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Li X-Patchwork-Id: 13791761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A2F4CD4F54 for ; Thu, 5 Sep 2024 06:21:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34C286B03B8; Thu, 5 Sep 2024 02:21:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D5466B03B9; Thu, 5 Sep 2024 02:21:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19D326B03BA; Thu, 5 Sep 2024 02:21:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EB29E6B03B8 for ; Thu, 5 Sep 2024 02:21:13 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9FDDF40991 for ; Thu, 5 Sep 2024 06:21:13 +0000 (UTC) X-FDA: 82529687226.15.D1834DA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 03CFB20005 for ; Thu, 5 Sep 2024 06:21:11 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JK3f94ab; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725517200; a=rsa-sha256; cv=none; b=pqtLW0YnM9pNK0r1eXIYOaiAG57/MLRAM9+Saw2FU5kE1CXM+xXmx4GVB0fAqAKKU0idZ1 Sf8KMxQYVfBmx7Rl+t8HXi5nrpDdpOz8Oyu0u5Jbt/n6CL1FI8O8Al5u/Q8QPSMVJs0XBu BzMCL1/QOdrkz+FO1rCJO9oZrPdnbwE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JK3f94ab; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725517200; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=9mipq5x3lcWe18aJdeCcZYJG8EEh2Jt93Aw7ZOEoMi4=; b=COcHSCQRUCdGWcbW9nRQI3A6PNImqap5F8nDWCfONNxYPRHdS4Hhm4d507eTJlDnDfR65A B1c5Jq7F9DoKijJjMOLkZ9jUvWsv2eQbq9cIgC80lIeSHNO1gdQ7MG3jOfHdyPMopD2x0q 1G0hMYwGEBqD9R9DPRcgHUiuHCh/B9o= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DC1F25C55E1; Thu, 5 Sep 2024 06:21:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B9DEC4CEC4; Thu, 5 Sep 2024 06:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725517268; bh=9G4uSfBJSYvJhSJCNBznlu05STrgif4WeJtvaeHYwnc=; h=From:Date:Subject:To:Cc:From; b=JK3f94abeR/I2GZxc1EEOZA8jRB5GpzhuZW1jUqfHeZUQFBH+5elVYmkTUkwSZUbB vEy1kRGIWVsxs3qDn76TSaYVujt9Ywr7KbHNU9VFCF87y+Dff916B4xWNjV/oHwrRi 4Hf4XRf8APHTgggRhzHUMKNYj2dF8GVEVnirLq5H7A3csnVom5M3vcCCHtXTkDka/z mJTHco564npzEKReeQflovZ/jbIyLeF24hJIP8o/xjMGsPYcv0qvMA23/x84wocaVt uxOn7AdXn+beSIQLKnXf6yke/1T64Hfd+twtI28Vj49J6SFleiwDXL+lm988JLV3+d iKOofR5/GQ8/Q== From: Chris Li Date: Wed, 04 Sep 2024 23:21:06 -0700 Subject: [PATCH] mm: vmscan.c: fix OOM on swap stress test MIME-Version: 1.0 Message-Id: <20240904-lru-flag-v1-1-36638d6a524c@kernel.org> X-B4-Tracking: v=1; b=H4sIANFN2WYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDSwMT3ZyiUt20nMR0XaPENKM0S1NTcxODVCWg8oKi1LTMCrBR0bG1tQC z1AvvWgAAAA== To: Andrew Morton , yangge Cc: Yu Zhao , David Hildenbrand , Hugh Dickins , baolin.wang@linux.alibaba.com, Kairui Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Li X-Mailer: b4 0.13.0 X-Rspamd-Queue-Id: 03CFB20005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: q4dzs1qamz4e4mxfsw6m5x5d834pfsc4 X-HE-Tag: 1725517271-271435 X-HE-Meta: U2FsdGVkX18FsOYI69FftzikRhsbvC9iWUQkKuTKw7LCXrLjggD5dWXrspKBo8scNRrHlaCjSR142rV0uyVaAh3dy9QXxsFwrSbE0XNlrePXNd3bc0uq+gfqmSYoxrlEWjJHYbwJKFValKxCG1QzOG2rj0YOz0UCroI6fwSe/Kk4FXD4XyznryhI04SuwLc0C2FpDJogkCkVEKBQn3Tb18M4DFtnhvCMtK0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, 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: List-Subscribe: List-Unsubscribe: I found a regression on mm-unstable during my swap stress test, using tmpfs to compile linux. The test OOM very soon after the make spawns many cc processes. It bisects down to this change: 33dfe9204f29b415bbc0abb1a50642d1ba94f5e9 (mm/gup: clear the LRU flag of a page before adding to LRU batch) Yu Zhao propose the fix: "I think this is one of the potential side effects -- Huge mentioned earlier about isolate_lru_folios():" I test that with it the swap stress test no longer OOM. Link: https://lore.kernel.org/r/CAOUHufYi9h0kz5uW3LHHS3ZrVwEq-kKp8S6N-MZUmErNAXoXmw@mail.gmail.com/ Fixes: 33dfe9204f29 ("mm/gup: clear the LRU flag of a page before adding to LRU batch") Suggested-by: Yu Zhao Suggested-by: Hugh Dickins Tested-by: Chris Li Signed-off-by: Chris Li --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 756ca36d643324d028b325a170e73e392b9590cd change-id: 20240904-lru-flag-2af2f955740e Best regards, diff --git a/mm/vmscan.c b/mm/vmscan.c index a9b6a8196f95..96abf4a52382 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4323,7 +4323,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, struct scan_c } /* ineligible */ - if (zone > sc->reclaim_idx) { + if (!folio_test_lru(folio) || zone > sc->reclaim_idx) { gen = folio_inc_gen(lruvec, folio, false); list_move_tail(&folio->lru, &lrugen->folios[gen][type][zone]); return true;