From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 76AE233B6CB for ; Fri, 29 May 2026 13:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780060917; cv=none; b=XGCMv4WH/GE1P8h94xcm7QzCBImJdMxKuQN8WImsXpLbmwtjffQJjzSKBxN1YmWVNEEM3+PYRtKbA6RpjOdoWjOHYS8uyrJTMgx09pSPVq/AudQnOeFc7rW8epNcq+5innDiwpKoQMd5SvFbyUp2vLzBJzXhDSDiZ1eNQnJcWEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780060917; c=relaxed/simple; bh=x+o/DOLZlj7Bwmu0EoamwBQaf6CHwB47o9OMscTjeJs=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=RIbI5Md0stbT6GTzCdipopJIAf7sqwYHdDTp7sHOSAVjf+uAM1eh6UnnmSHOfG3haw1n738utsFdT7LaTu5XVudneeOL0vGII3dm86QJ97sPSDYwsad8OolAmxhgg8c5/2UD2MKhy/XUNPunkmP2WOcVU9dYStGpmb9Yv9j6Idw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rbg1cctO; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rbg1cctO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1B501F008A1; Fri, 29 May 2026 13:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780060914; bh=Lp86shnKnsqoyJ3siQmlvokVG/F4xvoHMgWz1Rxtio8=; h=Date:From:To:Cc:Subject:References; b=Rbg1cctO5b1eamk1ayo3rePP+nkqpGtp5fUSoChhAAetB35jRaBaakEesZ69pjyWf tWYJ04BTMpQnXrip5pNpWu0MJnJYS1SV3vJYI747bAtOgagVkw3/AbHQnGlXIwnspi yME/GNcDTo5eT1WyVfakKRfED2VgqvBe5QqVR6971WBY903ZZ/JYV86kHTt+kzjzHK uulux+5fR+1q2P7/9oYjUubQv/VyNuFBDYScaivK8ZBovAPvXDpCtwBsYdL5pZdY3b bV7dyIr0C89MNO7wksJ4Gmou6gbdHT92lVjzT9JSLBgH05sCRh2Oyl4/Hbm1KgAd7A LCQX1VwwdEUlw== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wSxAX-0000000ASV0-3R4k; Fri, 29 May 2026 09:22:33 -0400 Message-ID: <20260529132233.679624644@kernel.org> User-Agent: quilt/0.69 Date: Fri, 29 May 2026 09:22:19 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton Subject: [for-next][PATCH 7/9] ring-buffer: Have dropped subbuffers be persistent across reboots References: <20260529132212.153072686@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Steven Rostedt When the persistent ring buffer detects a corrupted subbuffer, it will zero its size and report dropped pages in the dmesg, then it continues normally. But if a reboot happens without clearing or restarting tracing on the persistent ring buffer, the next boot will show no pages are dropped. If the persistent ring buffer is still the same, then it should still report dropped pages so the user knows that the buffer has missing events. Add the RB_MISSED_EVENTS flag to the commit value of the subbuffer so that the next boot will still show that pages were dropped. Link: https://patch.msgid.link/20260522171051.860780286@kernel.org Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt --- kernel/trace/ring_buffer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index fd4a8dc5484e..db72969aefa9 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -1915,7 +1915,7 @@ static int __rb_validate_buffer(struct buffer_page *bpage, int cpu, * Even after clearing these bits, a commit value greater than the * subbuf_size is considered invalid. */ - tail = rb_data_page_size(dpage); + tail = rb_data_page_commit(dpage); if (tail <= meta->subbuf_size - BUF_PAGE_HDR_SIZE) ret = rb_read_data_buffer(dpage, tail, cpu, &ts, &delta); else @@ -1929,7 +1929,7 @@ static int __rb_validate_buffer(struct buffer_page *bpage, int cpu, */ if (ret < 0 || (prev_ts && prev_ts > ts) || (next_ts && ts > next_ts)) { local_set(&bpage->entries, 0); - local_set(&dpage->commit, 0); + local_set(&dpage->commit, RB_MISSED_EVENTS); dpage->time_stamp = prev_ts ? prev_ts : next_ts; ret = -1; } else { @@ -3451,7 +3451,7 @@ rb_iter_head_event(struct ring_buffer_iter *iter) * is a mb(), which will synchronize with the rmb here. * (see rb_tail_page_update() and __rb_reserve_next()) */ - commit = rb_page_commit(iter_head_page); + commit = rb_page_size(iter_head_page); smp_rmb(); /* An event needs to be at least 8 bytes in size */ @@ -3480,7 +3480,7 @@ rb_iter_head_event(struct ring_buffer_iter *iter) /* Make sure the page didn't change since we read this */ if (iter->page_stamp != iter_head_page->page->time_stamp || - commit > rb_page_commit(iter_head_page)) + commit > rb_page_size(iter_head_page)) goto reset; iter->next_event = iter->head + length; @@ -5651,7 +5651,7 @@ int ring_buffer_iter_empty(struct ring_buffer_iter *iter) * (see rb_tail_page_update()) */ smp_rmb(); - commit = rb_page_commit(commit_page); + commit = rb_page_size(commit_page); /* We want to make sure that the commit page doesn't change */ smp_rmb(); @@ -5844,6 +5844,7 @@ __rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer) */ local_set(&cpu_buffer->reader_page->write, 0); local_set(&cpu_buffer->reader_page->entries, 0); + rb_init_data_page(cpu_buffer->reader_page->page); cpu_buffer->reader_page->real_end = 0; spin: -- 2.53.0