All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,shikemeng@huaweicloud.com,nphamcs@gmail.com,kasong@tencent.com,chrisl@kernel.org,baoquan.he@linux.dev,baohua@kernel.org,youngjun.park@lge.com,akpm@linux-foundation.org
Subject: [merged mm-stable] mm-swap-clarify-unreachable-cond_resched-in-swap_reclaim_full_clusters.patch removed from -mm tree
Date: Thu, 06 Aug 2026 19:00:19 -0700	[thread overview]
Message-ID: <20260807020020.066AD1F00A3D@smtp.kernel.org> (raw)


The quilt patch titled
     Subject: mm/swap: clarify unreachable cond_resched() in swap_reclaim_full_clusters
has been removed from the -mm tree.  Its filename was
     mm-swap-clarify-unreachable-cond_resched-in-swap_reclaim_full_clusters.patch

This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Youngjun Park <youngjun.park@lge.com>
Subject: mm/swap: clarify unreachable cond_resched() in swap_reclaim_full_clusters
Date: Mon, 13 Jul 2026 13:50:14 +0900

Commit 66366d291f66 ("mm/swap: add cond_resched() in
swap_reclaim_full_clusters to prevent softlockup") added cond_resched() to
prevent soft lockups during heavy swap reclaim.

Currently, there are two call sites for this function:
1. swap_reclaim_work(): called with force=true in a workqueue context.
2. cluster_alloc_swap_entry(): called with force=false, holding a
   local_lock and potentially a global cluster spinlock (atomic context).

In the second case, calling cond_resched() would normally cause a
"scheduling while atomic" bug.  However, it is currently safe because when
force=false, 'to_scan' is initialized to 1.  The loop decrements it to 0
and breaks before ever reaching cond_resched().

This implicit dependency is hard to notice and recently triggered a false
positive in AI Sashiko review.

Add a comment to explicitly clarify that cond_resched() is unreachable in
atomic contexts.  This improves readability and prevents future misuse if
the loop logic or 'to_scan' initialization is modified.

Link: https://sashiko.dev/#/patchset/20260713025644.170839-1-youngjun.park@lge.com?part=4
Link: https://lore.kernel.org/20260713045014.219653-1-youngjun.park@lge.com
Signed-off-by: Youngjun Park <youngjun.park@lge.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Barry Song <baohua@kernel.org>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/swapfile.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/mm/swapfile.c~mm-swap-clarify-unreachable-cond_resched-in-swap_reclaim_full_clusters
+++ a/mm/swapfile.c
@@ -1072,6 +1072,12 @@ static void swap_reclaim_full_clusters(s
 		swap_cluster_unlock(ci);
 		if (to_scan <= 0)
 			break;
+
+		/*
+		 * When 'force' is false, 'to_scan' is initialized to 1.
+		 * The loop breaks above, making this cond_resched() unreachable
+		 * in atomic contexts.
+		 */
 		cond_resched();
 	}
 }
_

Patches currently in -mm which might be from youngjun.park@lge.com are



                 reply	other threads:[~2026-08-07  2:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260807020020.066AD1F00A3D@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baoquan.he@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=kasong@tencent.com \
    --cc=mm-commits@vger.kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=youngjun.park@lge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.