From nobody Sun Feb 8 16:12:05 2026 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20DCC20C038; Sun, 28 Dec 2025 06:53:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766904794; cv=none; b=FJf6FsRXXhnShTathWTfWsRzZhllzH6v6eGys84gCxEg9OnqHxcww13afwGvGJl6MjvEZPwA8MFB90xCwg45VFpcpdpUXGN1+JRn1H1oydZNOUVXjLcNbzoGUTYs6RGNZQ20+JXSo84IK8VuGkbuyZWSJmMU+qV+GJnQ4WxYGDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766904794; c=relaxed/simple; bh=QyJKcZWZzIr5OBRewmp42DQ52mvy6s4cD9ET/rApj9w=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=OfAp05yf57b24x22XTIKnSZyVApEQRXVoHYMOrTN6Lm3NSqKHzrA8fNDLbenOTVeapyysQrpwgiuaNob0hYPDebf3JiX1ZqBhyZVC3xf6XK7vH341slsSF7iHDlCunx7HBSJ8ErD8w3eRSf+/SeSatiQpYOeYnqzUFv4vaQ+Glc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=AGy2lDMB; arc=none smtp.client-ip=113.46.200.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="AGy2lDMB" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=CsiiI3n4AiioFw/9mrBaWMr/S7a+JwFXsrQPd5xKcqA=; b=AGy2lDMBDi0OkHyAIoO83g7oBkorKe+6VY+b+c1kdmj5sIvAcOHvHwHJrBamR8hp01Sa8hlOL adteAUuKLUn36POsl8zEwpudCXKKXejyLCwHGFB+/0Yt7UbYXs+kBW8uP5IyWiUPKcJ0hOsSG+z L5XYt8hqUU/D6fEmqDJgwV4= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4df92b0WnwzRhRb; Sun, 28 Dec 2025 14:49:59 +0800 (CST) Received: from kwepemj100016.china.huawei.com (unknown [7.202.194.10]) by mail.maildlp.com (Postfix) with ESMTPS id A5E3A4056C; Sun, 28 Dec 2025 14:53:08 +0800 (CST) Received: from huawei.com (10.50.85.135) by kwepemj100016.china.huawei.com (7.202.194.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Sun, 28 Dec 2025 14:53:08 +0800 From: Wupeng Ma To: , , CC: , , Subject: [PATCH] ring-buffer: Avoid softlockup in ring_buffer_resize() during memory free Date: Sun, 28 Dec 2025 14:50:07 +0800 Message-ID: <20251228065008.2396573-1-mawupeng1@huawei.com> X-Mailer: git-send-email 2.43.0 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 X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemj100016.china.huawei.com (7.202.194.10) Content-Type: text/plain; charset="utf-8" When user resize all trace ring buffer through file 'buffer_size_kb', then in ring_buffer_resize(), kernel allocates buffer pages for each cpu in a loop. If the kernel preemption model is PREEMPT_NONE and there are many cpus and there are many buffer pages to be freed, it may not give up cpu for a long time and finally cause a softlockup. To avoid it, call cond_resched() after each cpu buffer free as Commit f6bd2c92488c ("ring-buffer: Avoid softlockup in ring_buffer_resize()") does. Detailed call trace as follow: rcu: INFO: rcu_sched self-detected stall on CPU rcu: 24-....: (14837 ticks this GP) idle=3D521c/1/0x4000000000000000 sof= tirq=3D230597/230597 fqs=3D5329 rcu: (t=3D15004 jiffies g=3D26003221 q=3D211022 ncpus=3D96) CPU: 24 UID: 0 PID: 11253 Comm: bash Kdump: loaded Tainted: G = EL 6.18.2+ #278 NONE pc : arch_local_irq_restore+0x8/0x20 arch_local_irq_restore+0x8/0x20 (P) free_frozen_page_commit+0x28c/0x3b0 __free_frozen_pages+0x1c0/0x678 ___free_pages+0xc0/0xe0 free_pages+0x3c/0x50 ring_buffer_resize.part.0+0x6a8/0x880 ring_buffer_resize+0x3c/0x58 __tracing_resize_ring_buffer.part.0+0x34/0xd8 tracing_resize_ring_buffer+0x8c/0xd0 tracing_entries_write+0x74/0xd8 vfs_write+0xcc/0x288 ksys_write+0x74/0x118 __arm64_sys_write+0x24/0x38 Signed-off-by: Wupeng Ma Acked-by: Masami Hiramatsu (Google) --- kernel/trace/ring_buffer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index afcd3747264d2..3ba08fc1b7d05 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -3121,6 +3121,8 @@ int ring_buffer_resize(struct trace_buffer *buffer, u= nsigned long size, list) { list_del_init(&bpage->list); free_buffer_page(bpage); + + cond_resched(); } } out_err_unlock: --=20 2.43.0