From patchwork Wed Dec 25 06:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MengEn Sun X-Patchwork-Id: 13920625 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 9D488E7718D for ; Wed, 25 Dec 2024 06:26:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 972056B007B; Wed, 25 Dec 2024 01:26:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F9ED6B0083; Wed, 25 Dec 2024 01:26:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79A866B0085; Wed, 25 Dec 2024 01:26:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5A82E6B007B for ; Wed, 25 Dec 2024 01:26:09 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 83474C0493 for ; Wed, 25 Dec 2024 06:26:07 +0000 (UTC) X-FDA: 82932495198.24.1AE8D56 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf05.hostedemail.com (Postfix) with ESMTP id DC9D9100008 for ; Wed, 25 Dec 2024 06:24:48 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ZQMdz8JO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of mengensun88@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=mengensun88@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735107947; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=eRQuS4JI88qqmEpxGEHBR6wX+ww2CsA2C0TVL39rISI=; b=BN+H6LUu817KMKxXNIhecPs2PAgYkUswtMjxRqlTXXGJR65aQ7h/nc7B03rkpHP60P5+Tv HnIHbd5tTyKJHp/APT5hjEgKlGRsmBKvgTmnbznfbhfD4EciBsd87Brg+dKtM+ihudU0QC Skt9uj/7HDIQNBsFAlNjpitHZ5gQtGE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735107947; a=rsa-sha256; cv=none; b=kKrPyWerJr95gQ9m0haxi51igNda+yM1Fb2V3zSpZdYJyy8JgprrffAIjvdqgWv34N1HaA hiQJPRI+CxeJvwKAUN+D+MSEL3WyIPP1OE1yGvt+ihLh8y9fKletwA6Bm0scrSoNhhhjMI 3AguazSxFNr+Uh/1YAkdiPd4BwxHab8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ZQMdz8JO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of mengensun88@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=mengensun88@gmail.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2161eb95317so62827925ad.1 for ; Tue, 24 Dec 2024 22:26:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735107964; x=1735712764; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eRQuS4JI88qqmEpxGEHBR6wX+ww2CsA2C0TVL39rISI=; b=ZQMdz8JOmuSC4ajkol8SM5XENfhQUYXWjkchJcV0WcQEO2gCGPhWaP3E+kK+Hn6SaE c325LWTs1ZC/XTTsMX1xozv8eAoj+A+SiPJg3WdFAcGVGjtHHncQSt2wCKBs1chlJHO7 VpIBLLkiX7DGTKbjvu5FthbHQKbhvZB0XZ/By8rjrchjJ0RbMbzSlhiSSQCIxvi7lBkp Ijba2WXKt9rMcRmWmu91lg9dGLmSX5K7hkVI58s0UOvudK+hHL8N+afoYxncq1VW9LJC 6B7wIS0qWzi7EWf/aJtMWmuf07SviqJTJ8fALh7jYwdxBnoCtrix+4Ml0XsuBMIi2dzz kQtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735107964; x=1735712764; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eRQuS4JI88qqmEpxGEHBR6wX+ww2CsA2C0TVL39rISI=; b=IqXgVRl+rgDHf3lLWIXiQFJJ+cKRQrdw3T6xmE4iBnAUW48+eS7jH/zKksTynEU6Iw AwhQnBd1caPgRMaYJYnzoMP97v4SEkJE5WmzkBoeCXHGUBTvzeCNHb+gJ/oYdX2rblmu FDI4g1ZiygMxZpmmHT8Z4/DOlHr8WBvuFscLhI8TW0Xrm+XKMxqGfBTumqMbixnBCiUJ tPAwEmsPfMcv+eAKjhBSH6clhJMP4B44KG0fB6FG468QqVAHzJ9STqDPBBdHAVKMhh5i GyjJUOkGKmGAOC3/0m1xFuUIwGdkgcbUJHG6+AdsFKJM2vkfYpZGebdFWYuTuatf8u95 1qfw== X-Forwarded-Encrypted: i=1; AJvYcCW6rXzcha48lcU1XWWFL1iOlyUuigkm+4KX9HKY26w3v02mIgD4rRemIrZHO/s6ZXcl17SiHCOJIQ==@kvack.org X-Gm-Message-State: AOJu0YzlJkPM/SPp01nOrvwHREFC+w3Hyl8K2Ic0y9Jf8jFttW+6TT/h EeEgqX3TakawvEmQxbY2JDhZJvLmHkIs8Von7ALt6zlXP89aau5Y X-Gm-Gg: ASbGncs0bH++f7Syto53a92JTv4Mr8p+3NauWQtn8GJSmS4VTTbVX8/yeFolWJ1NIA8 ULGMsco9V1o1rQDjSEJmWf0l0ESTX2IFk9LYctTECRUcDHGYpdbSYOg/3K4diCj8ia6oil/itpV G1M2T7onaU3KWpoASeHdaTUg70MnrS7uEtQSaWSWD/G8603S66xhBYjGDTzDUQ6HLiVI7wOaPxT pvcPGB0M9AFT3Cad8Yy6j8MGov3ARtbiraovGmo3foo4TkNWPAfykEWNuuSPf9Rug== X-Google-Smtp-Source: AGHT+IFq08CZ0KFXpWRBPJvXClxrQWK+C0suk9KUOkYENlyigUh8kuLl/6x4b8PxdBi2niN7BuaKuA== X-Received: by 2002:a17:902:ce86:b0:216:2f7f:ff69 with SMTP id d9443c01a7336-219e6e894c8mr216426025ad.5.1735107964229; Tue, 24 Dec 2024 22:26:04 -0800 (PST) Received: from localhost.localdomain ([43.153.70.29]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2db9ca30asm9177265a91.1.2024.12.24.22.26.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Dec 2024 22:26:03 -0800 (PST) From: mengensun88@gmail.com X-Google-Original-From: mengensun@tencent.com To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: alexjlzheng@tencent.com, MengEn Sun Subject: [PATCH] mm/page_alloc: add cond_resched in __drain_all_pages() Date: Wed, 25 Dec 2024 14:26:01 +0800 Message-Id: <1735107961-9938-1-git-send-email-mengensun@tencent.com> X-Mailer: git-send-email 1.8.3.1 X-Stat-Signature: nr43moiskyyk9iuwysfqdxtjh7ox7nqx X-Rspamd-Queue-Id: DC9D9100008 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1735107888-689871 X-HE-Meta: U2FsdGVkX18qZIpG97ymHU0WPiFIIq+hRJMvvtaojIgwQ5VIJ1ZlxE86wHJxZd4pK/TxsMa3eBmlzTEgC2R+ZODAxR1MLiHYBzn5K0G72NtDSyKVf//hjfHfBNNylw2Rt4M8RVSlho2Ehd355TaWKxPbtUwwNbZib6Zdta+DaRS0d9xI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krBzydsNyGD/tsGpXC9o0Shp/pF68M47mJo/PXKby3U5kfWO8HnOB99h3GH6tzoeIm7O1jdgMJgdloWl34kUiCJnPLdGxiPnDIxrptK/JPnS8tLCvEhDjtw X-Bogosity: Ham, tests=bogofilter, spamicity=0.259406, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: MengEn Sun Since version v5.19-rc7, draining remote per-CPU pools (PCP) no longer relies on workqueues; instead, the current CPU is responsible for draining the PCPs of all CPUs. However, due to the lack of scheduling points in the __drain_all_pages function, this can lead to soft locks in some extreme cases. We observed the following soft-lockup stack on a 64-core, 223GB machine during testing: watchdog: BUG: soft lockup - CPU#29 stuck for 23s! [stress-ng-vm] RIP: 0010:native_queued_spin_lock_slowpath+0x5b/0x1c0 _raw_spin_lock drain_pages_zone drain_pages drain_all_pages __alloc_pages_slowpath __alloc_pages_nodemask alloc_pages_vma do_huge_pmd_anonymous_page handle_mm_fault Fixes: <443c2accd1b66> ("mm/page_alloc: remotely drain per-cpu lists") Reviewed-by: JinLiang Zheng Signed-off-by: MengEn Sun --- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c6c7bb3ea71b..d05b32ec1e40 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2487,6 +2487,7 @@ static void __drain_all_pages(struct zone *zone, bool force_all_cpus) drain_pages_zone(cpu, zone); else drain_pages(cpu); + cond_resched(); } mutex_unlock(&pcpu_drain_mutex);