From patchwork Sat Nov 30 16:12:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seiji Nishikawa X-Patchwork-Id: 13895596 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 1F26CE7716C for ; Thu, 5 Dec 2024 15:34:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 534AD6B012D; Thu, 5 Dec 2024 10:19:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B99066B0144; Thu, 5 Dec 2024 10:19:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 928BE6B013F; Thu, 5 Dec 2024 10:19:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 427426B0085 for ; Sat, 30 Nov 2024 11:12:55 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C34F81A08F5 for ; Sat, 30 Nov 2024 16:12:54 +0000 (UTC) X-FDA: 82843254396.20.14C2195 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 5781F18001A for ; Sat, 30 Nov 2024 16:12:43 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z4lC0DWv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of snishika@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=snishika@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732983164; a=rsa-sha256; cv=none; b=BMAV2rry47bvaThlYfqrniWMEM1EslvqFuKZi9AmylF2td28Su6jqSttiMLFujhkZ9J4ZO SglozEXJCqqUKlr/WJCF5FUJas8Hd80JCTaxYngl6vjQlHopdgeILztNuqM1WuMqfHLK+3 mtZ8jVbXJgXXRcUvPrevZNTpFyQHRV4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Z4lC0DWv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of snishika@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=snishika@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732983164; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=REyeVoRX10hydiXMzUjbEHtT4HCsZjLURReys2nYjK0=; b=TD+ouE4jx9f57VUsMFoYxyd895sZrrsqxsD92uxeEvRbRurq166yJATBFTunP6oYf460nm M+k3Irhy7bOxt613r7mztKiWzfaxBQKdgn8ekpR9/9uz731Cqtpjyz3jRC9zLaaWmUKav6 pWSUztI19w+dUxlv92HphhVjxDEJ5+A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732983172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=REyeVoRX10hydiXMzUjbEHtT4HCsZjLURReys2nYjK0=; b=Z4lC0DWvKfv0duKvAvhQGSN2Moe8vWADQ8kQEBSXtdM/OusvPqD/HRFb8cPHm/7l+7ZZfl Gx9539/ywkEkJHGKRZkExyTy3wa42d81xhenv6PJ5Q0BGamMnJ1nku6LdeEL20DGtA7TAw pHx+dyp4NMiPuE7WLMuk4lSgtJeioCI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-i5hcru3xOe25Lp_c-5LywA-1; Sat, 30 Nov 2024 11:12:49 -0500 X-MC-Unique: i5hcru3xOe25Lp_c-5LywA-1 X-Mimecast-MFC-AGG-ID: i5hcru3xOe25Lp_c-5LywA Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 93A461955F43; Sat, 30 Nov 2024 16:12:47 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.64.33]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5326C1956089; Sat, 30 Nov 2024 16:12:45 +0000 (UTC) From: Seiji Nishikawa To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, mgorman@techsingularity.net, snishika@redhat.com Subject: [PATCH] mm: vmscan: account for free pages to prevent infinite Loop in throttle_direct_reclaim() Date: Sun, 1 Dec 2024 01:12:34 +0900 Message-ID: <20241130161236.433747-2-snishika@redhat.com> In-Reply-To: <20241130161236.433747-1-snishika@redhat.com> References: <20241129043936.316481-1-snishika@redhat.com> <20241130161236.433747-1-snishika@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5781F18001A X-Stat-Signature: iq1eisn6c1h1ch9euzp6rb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A0xxiUDNO8vetsYpD22q+n+ojgK3KHufkF7cG9SOzw+QGTXzq/DGvMOTyLn3jn2OdtHsKwq3GkSLaeoq9/Izqz3D4eA9ap4AsQJcge4AA6jz0ht5PlAp6DuIO+0EAyZtHfIaIRES1KBrq23e8ziaEcnlAkRjhErHWTM4JrIrUgKRRFQvkklPOArumUYbxae1zkire53bWlufi6HIRr5DbMtii+5EYA/TKFy7b02v17frUhOPdayL+MP4Q5MuOC6fUqmrz5iLs9gvX5pPrUfNPF3sMhMEHSQbRWjwJ4qER6JGaVMRw00ei+YKoLzEqVa9mQhEC24pzQZRsKhdXfbaiGywH7ooBtO2dsKio3wyVLjLA== 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: List-Subscribe: List-Unsubscribe: The kernel hangs due to a task stuck in throttle_direct_reclaim(), caused by a node being incorrectly deemed balanced despite pressure in certain zones, such as ZONE_NORMAL. This issue arises from zone_reclaimable_pages() returning 0 for zones without reclaimable file- backed or anonymous pages, causing zones like ZONE_DMA32 with sufficient free pages to be skipped. The lack of swap or reclaimable pages results in ZONE_DMA32 being ignored during reclaim, masking pressure in other zones. Consequently, pgdat->kswapd_failures remains 0 in balance_pgdat(), preventing fallback mechanisms in allow_direct_reclaim() from being triggered, leading to an infinite loop in throttle_direct_reclaim(). This patch modifies zone_reclaimable_pages() to account for free pages (NR_FREE_PAGES) when no other reclaimable pages exist. This ensures zones with sufficient free pages are not skipped, enabling proper balancing and reclaim behavior. Signed-off-by: Seiji Nishikawa --- mm/vmscan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 76378bc257e3..fb6b4056dcce 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -374,7 +374,14 @@ unsigned long zone_reclaimable_pages(struct zone *zone) if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL)) nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) + zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON); - + /* + * If there are no reclaimable file-backed or anonymous pages, + * ensure zones with sufficient free pages are not skipped. + * This prevents zones like DMA32 from being ignored in reclaim + * scenarios where they can still help alleviate memory pressure. + */ + if (nr == 0) + nr = zone_page_state_snapshot(zone, NR_FREE_PAGES); return nr; }