From patchwork Sat Nov 30 16:43:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seiji Nishikawa X-Patchwork-Id: 13895591 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 670A6E7716D for ; Thu, 5 Dec 2024 15:33:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 623F06B0116; Thu, 5 Dec 2024 10:19:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A872F6B00F2; Thu, 5 Dec 2024 10:19:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77A5E6B0115; Thu, 5 Dec 2024 10:19:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5D3E96B007B for ; Sat, 30 Nov 2024 11:44:01 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C5B591C6C99 for ; Sat, 30 Nov 2024 16:44:00 +0000 (UTC) X-FDA: 82843333356.28.6DE67F1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 3E1E94000E for ; Sat, 30 Nov 2024 16:43:49 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E5Exxgld; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of snishika@redhat.com designates 170.10.129.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=1732985034; 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=s0o/pcTqmpAd9rYOVs9bkAhvHl4tPwQAa3iEqzyH6Qy19Pe63vRAqdzk1iyuyJsQIldL/d TUSAgxq+PavcchyRTGXRM+mAbC/t5rrDh6tFi5IjVDH/QJOZFGQUuXljTjK506ZVPsaRt2 ikJ3bPWUKf4DqwBpsAZN2SNXhPVhkyc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732985034; a=rsa-sha256; cv=none; b=hbUeIqRDil5tJUs19zSFetqVLz5AjYfSSUJDuBQMpa0ydNKzRnFWmp6V+eq1iAodAhlVip AC+ctefYszGemLdh2w25p0kkCPRSU21+V3Ua++/T/Yf+Gl2SOy62ZNPgaikVUAmu+TjoWD 9DTcXKVccxm4lTzUpbTgE0t/Vy6WqkQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E5Exxgld; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of snishika@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=snishika@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732985038; 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=E5ExxgldYJByfGQRLIKa9MfoJNuaA+L97Cz5QlZ6P33EoCqu7afkP7LG/pxZRT6LWop5o8 jWOBxGkXQun6SvCOqDdAtOqrUCOuE8RQ14bwA2rKXu2h9/4dpfNu8MJfrvd2oR4SjH78oR mQQEXgoHflLvZe2PAwFsqs6kc635R10= 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-479-w16SiC6vPDm7_bQ2fuvIDQ-1; Sat, 30 Nov 2024 11:43:56 -0500 X-MC-Unique: w16SiC6vPDm7_bQ2fuvIDQ-1 X-Mimecast-MFC-AGG-ID: w16SiC6vPDm7_bQ2fuvIDQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 94F99195608C; Sat, 30 Nov 2024 16:43:55 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.64.33]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6DD97300018D; Sat, 30 Nov 2024 16:43:53 +0000 (UTC) From: Seiji Nishikawa To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: 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:43:46 +0900 Message-ID: <20241130164346.436469-2-snishika@redhat.com> In-Reply-To: <20241130164346.436469-1-snishika@redhat.com> References: <20241130164346.436469-1-snishika@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Stat-Signature: iq1eisn6c1h1ch9euzp6rb5gtdk9ntkh X-Rspamd-Queue-Id: 3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62mS/y3OLGxRVZCTYaEltvs+W0nxGJgL1ZwPpyEwpvzBtBtOddvT3VwrgOFmKfKDlwKvWmORwO8WDL/ZeAuln+oGjqna4MDounoDK/eukXeha002UFNBlb/V52QwdGMemX5vUDPQVUTLCaVg//9zmmrUNbhqO0wARAj1xPxZDpYCKxCT9z2KRYHwlNdnQqJ1L5lkV9Q3Av2z5MGscHrLJ4/o8RPIX7c6igUWU4ahNy6WnjDh4CZ6FtIGQ0IWnwxZEsBmRMdTctbtKuNvZAXQIMrgIJsjqk4nEdz6zWLjgSfgSUjaOrun/8+ohWPSpZkb9jSu6632EsJ0X7HxXwm0rCEMBftEVTvuXqAEw+l3HefEY06M7DJ2chw5J1+PAT5wx9ZQH7HiA== 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; }