From nobody Fri Dec 19 18:27:00 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 18FE0186608; Wed, 4 Sep 2024 23:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725493407; cv=none; b=jYP7zVjzFIIf0Z0o7oZmjrbpf4SILSpcVOmrzbM+FYbFbkHii0xZ4VbP5QqRkUy4VaNDINhr9kqPbQhjETSIx4zuFdHeUOJ5xTuufIwOyxT83YUrxQWKSrWaPXHKm90J4o2bdRZL8benY54YkjBQAJvDFMG2OiZi1xOJYasxbII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725493407; c=relaxed/simple; bh=znbtzMLOJQ9Au5yW8iyqOnvVzKUgjfxf+yVoLIyt3rs=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=llKo+letmCaGILXiaT7cCOQN6vt6tg2/fex/PAYWJ9YNLLlK6yorb67C8Xl9X7BspZO5lghV62EHMKXq09AwGdF4T2seojl65vPGrLBcjptkcrNv3Ak8wMr/gRVUxPcK9Y3/2grpDJSSgXyPT+Kt1G73fuVvmVcVFZ/0y9Glw4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A122BC4CED5; Wed, 4 Sep 2024 23:43:26 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1slzfo-00000005BpP-1c3u; Wed, 04 Sep 2024 19:44:28 -0400 Message-ID: <20240904234428.246209582@goodmis.org> User-Agent: quilt/0.68 Date: Wed, 04 Sep 2024 19:44:16 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Zheng Yejian Subject: [for-linus][PATCH 5/6] tracing: Avoid possible softlockup in tracing_iter_reset() References: <20240904234411.443593140@goodmis.org> 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" From: Zheng Yejian In __tracing_open(), when max latency tracers took place on the cpu, the time start of its buffer would be updated, then event entries with timestamps being earlier than start of the buffer would be skipped (see tracing_iter_reset()). Softlockup will occur if the kernel is non-preemptible and too many entries were skipped in the loop that reset every cpu buffer, so add cond_resched() to avoid it. Cc: stable@vger.kernel.org Fixes: 2f26ebd549b9a ("tracing: use timestamp to determine start of latency= traces") Link: https://lore.kernel.org/20240827124654.3817443-1-zhengyejian@huaweicl= oud.com Suggested-by: Steven Rostedt Signed-off-by: Zheng Yejian Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ebe7ce2f5f4a..edf6bc817aa1 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3958,6 +3958,8 @@ void tracing_iter_reset(struct trace_iterator *iter, = int cpu) break; entries++; ring_buffer_iter_advance(buf_iter); + /* This could be a big loop */ + cond_resched(); } =20 per_cpu_ptr(iter->array_buffer->data, cpu)->skipped_entries =3D entries; --=20 2.43.0