From nobody Sun Feb 8 02:26:43 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C2A92868B0 for ; Mon, 5 Jan 2026 13:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767619978; cv=none; b=rh3Hi3sB63TXiRe1KtyPSZjkzZzPAC1AA3PHJHlUZ5OJjhvj2KlXtrfo/wSJR/7Ae4uMvhty4qKQOF5OM2GQ6EykF35TCiUzJmFetL9ZHYYF+E0xufjM1QIEmsnC3CwjAC/Nj3DlwRvQZlNxj3sjrER+3BwNmzknoUpLR0EeaAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767619978; c=relaxed/simple; bh=zNhuuv1O1JyWxH5wrp2bqbeHqOFNyPGLHohNN3FixUw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=CiFk1iQVAQjiGw3XwPZF7kbnn8M99fPdD8IZUAtHXZcaR6xwUqAkxFSMAvRwvaqOAuSrcLLo6eFwpq49VI42xHeJ8YC9zCFr3JfFb53X+tYOp1wQaS6BGTWISQnfcmIpub4sJH4/h9DXAz5tlxIL2nfCX0FTd6KCegyaXyTkytQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GXlGbOyh; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GXlGbOyh" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-7b22ffa2a88so13017605b3a.1 for ; Mon, 05 Jan 2026 05:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767619977; x=1768224777; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=oJm6OiRS9K3PqeaDgMDkLMzyrlgeIiwTpzJ3FbroMYM=; b=GXlGbOyhLrbXatmaFMlYsIvBYaCl3YVoA75c+y6acc97BVfE6zm1577b8nlL5eQhUQ uOA0vrL2qnXDIy1BW7Xr2IRZjmamUPWbLzIYjneA4GkKJYK+ar0DIiZkIRm4x74CKtIu QVQfT9eVDKnfdXYeaYZrd7F8vgxLMHi0UbFpGiCOuec5+UC4wk0NGVFgUr0dtfAxoLPZ r/mHfxK560V3SeaNX1B1TMTlTVceBJk/VFH/R6Ld7MYRfcfWP+joRdu8wWhsAYLOEzyJ ZYY/AzPnHFSoGdP78wnejiclGUP+arVCzqfOB5mKr50MSJX+Ip5JkG107PYLAzzkG0eX cAUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767619977; x=1768224777; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=oJm6OiRS9K3PqeaDgMDkLMzyrlgeIiwTpzJ3FbroMYM=; b=Lnb9mDV/D/zt6XAax4jEt+mDyrSuU7Fl+hMBSb7ua0o9Rm6rDEmOWjuAo07nVBdvQ7 HjWPz+m6V1kUpEspz9oKyGRtcAG/lwgF0dTxjm0ELirWKuXdET/aYdlSprXS53J0FJux IJFMSH6k0k2bG/9zNKWT8vg8hLpHxaW5MTZBInRsDoBhKLKFqedhTbjrqh7qf11zuETR HQ0bH47ZiZPvZpb9tDJWgS3YoJydNoPVYemmXQKj4f6KGzoV4+czgC/b/CD1KWqisyuo BRavrEZPTJuGG+TszngADndr9VKjnPFNagHp+LU9ETos69K/+0R48BzXEIkWo1hPXApr KTcg== X-Forwarded-Encrypted: i=1; AJvYcCXyR+Fx7ocAf3W+a8puzoZPRQWtyvRn2LkMRwyaeUWUBEyQ/q4hK/w+5EiV/R7LwhlpPvCclKQrWiWN0pk=@vger.kernel.org X-Gm-Message-State: AOJu0YxyhWUFuQ5O1VbMKb7gdQF0S+6K04vK/duBkftJwTH7kvoqlGNL 2td73diO7DHhgsG1QptS1tKDp9YgCq6X9E3dTYtC1SvuPABeziKy1yCw X-Gm-Gg: AY/fxX4T2Gb51HFhmuBCSO5rjqbjuosupDLhAySuGKyEzCHVZJ8KBMMi26rLxbDl1lm 9KJHIHOsTUGwmwk7gfMmIrHd78bAMGvrMiNas5rDokEDdGJtVVgBklAUYsyxYdxASYm8BnVL9u6 vNZ7izKU3J0WZPkCS8VpHsQF047MlTfzLBR0tOdqPeu0YW/M6043M1xW4vmZLQ9VAUYF42O+kn1 cANaiVkf9omyazIX2XmJFNbantC9d7xsyq+YPaeI9KrxhuFRgOKKfvhqiMMVCw2Sh6Q2O8sAz57 ekSO82YVRWfrQGAtLu+YL/4g2BuH3L17dwqxctuj7scppiKtRh6ryElC4R0ftqA66OdJFEM1hYV nRmBUkStdbVDHca4wrP8+JsqzHCmF10VtntA2NYDHHOsfaggwU9c6Yid04n43CvK54dh5NRqBGk bNQYzj2z4IHI/zmFthKGGvex0Die2owwRMpmhOOWj1uWneJY31e4HDoEN7LKRRgE9RZSc= X-Google-Smtp-Source: AGHT+IFcfxyiX7l4rPQkTcK0i562jckqNjZwoBg+p1wVoO/k/BzFfOrlmw0VrclwAigZJSDfdEyimA== X-Received: by 2002:a05:6a00:ab0a:b0:7e8:4471:ae60 with SMTP id d2e1a72fcca58-7ff67456c07mr40295975b3a.44.1767619976607; Mon, 05 Jan 2026 05:32:56 -0800 (PST) Received: from suhua-virtual-machine.localdomain ([43.224.245.234]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e0a19d8sm48306894b3a.42.2026.01.05.05.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 05:32:56 -0800 (PST) From: Hua Su To: akpm@linux-foundation.org, vbabka@suse.cz, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, suhua.tanke@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hua Su Subject: [PATCH] mm: fix execution order in alloc_contig_range_noprof Date: Mon, 5 Jan 2026 21:32:50 +0800 Message-Id: <20260105133250.763076-1-suhua.tanke@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix the execution order issue in alloc_contig_range_noprof where drain_all_pages was called after start_isolate_page_range, which may be lead to race conditions. Based on community patches commit ec6e8c7e0314 ("mm, page_alloc: disable pcplists during memory offline") and commit d479960e44f27 ("mm: disable LRU pagevec during the migration temporarily"), we disable pcplists and LRU cache before page isolation to ensure no pages are left in per-cpu lists during isolation. Signed-off-by: Hua Su Signed-off-by: Hua Su --- mm/page_alloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6a47443c48ff..d08f929ca64c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6815,8 +6815,6 @@ static int __alloc_contig_migrate_range(struct compac= t_control *cc, .reason =3D MR_CONTIG_RANGE, }; =20 - lru_cache_disable(); - while (pfn < end || !list_empty(&cc->migratepages)) { if (fatal_signal_pending(current)) { ret =3D -EINTR; @@ -6850,7 +6848,6 @@ static int __alloc_contig_migrate_range(struct compac= t_control *cc, break; } =20 - lru_cache_enable(); if (ret < 0) { if (!(cc->gfp_mask & __GFP_NOWARN) && ret =3D=3D -EBUSY) alloc_contig_dump_pages(&cc->migratepages); @@ -6973,6 +6970,9 @@ int alloc_contig_range_noprof(unsigned long start, un= signed long end, if (__alloc_contig_verify_gfp_mask(gfp_mask, (gfp_t *)&cc.gfp_mask)) return -EINVAL; =20 + zone_pcp_disable(cc.zone); + lru_cache_disable(); + /* * What we do here is we mark all pageblocks in range as * MIGRATE_ISOLATE. Because pageblock and max order pages may @@ -6998,8 +6998,6 @@ int alloc_contig_range_noprof(unsigned long start, un= signed long end, if (ret) goto done; =20 - drain_all_pages(cc.zone); - /* * In case of -EBUSY, we'd like to know which page causes problem. * So, just fall through. test_pages_isolated() has a tracepoint @@ -7076,6 +7074,8 @@ int alloc_contig_range_noprof(unsigned long start, un= signed long end, start, end, outer_start, outer_end); } done: + lru_cache_enable(); + zone_pcp_enable(cc.zone); undo_isolate_page_range(start, end); return ret; } --=20 2.34.1