[kernel][dlog] Logically remove zx_log_record_t rollout field

zx_log_record_t's rollout field is not used. Rename the field to
unused. A future CL will replace the field with a sequence ID that can
be used to calculate the number of dropped messages.

Bug: 69290
Change-Id: Ieaa0bd85667fb9ad5d23849ae79c516a71954264
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/484620
Commit-Queue: Nick Maniscalco <maniscalco@google.com>
Reviewed-by: Miguel Flores <miguelfrde@google.com>
Reviewed-by: Christopher Johnson <crjohns@google.com>
Reviewed-by: Tyler Mandry <tmandry@google.com>
diff --git a/docs/reference/syscalls/debuglog_read.md b/docs/reference/syscalls/debuglog_read.md
index 56d5dff..76b1f48 100644
--- a/docs/reference/syscalls/debuglog_read.md
+++ b/docs/reference/syscalls/debuglog_read.md
@@ -34,7 +34,7 @@
 
 ```c
 typedef struct zx_log_record {
-  uint32_t rollout;
+  uint32_t unused;
   uint16_t datalen;
   uint8_t severity;
   uint8_t flags;
@@ -49,10 +49,6 @@
 
 | Field       | Description                                                    |
 | ----------- | -------------------------------------------------------------- |
-| *rollout*   | Number of bytes of log messages (including headers) dropped    |
-:             : since the last call to `zx_debuglog_read` on this object. The  :
-:             : kernel will drop the oldest log messages when its internal     :
-:             : buffer becomes full.                                           :
 | *datalen*   | Number of bytes of data in the *data* field.                   |
 | *severity*  | Severity of this log message. Standard severity levels are     |
 :             : defined in the header `zircon/syscalls/log.h`.                 :
diff --git a/src/diagnostics/archivist/src/fuzzer.rs b/src/diagnostics/archivist/src/fuzzer.rs
index 2057754..5fc1711 100644
--- a/src/diagnostics/archivist/src/fuzzer.rs
+++ b/src/diagnostics/archivist/src/fuzzer.rs
@@ -21,7 +21,7 @@
 
 impl Arbitrary for RandomLogRecord {
     fn arbitrary(u: &mut Unstructured<'_>) -> Result<Self> {
-        let rollout = u32::arbitrary(u)?;
+        let unused = u32::arbitrary(u)?;
         let datalen = u16::arbitrary(u)?;
         let severity = u8::arbitrary(u)?;
         let flags = u8::arbitrary(u)?;
@@ -35,7 +35,7 @@
         u.fill_buffer(&mut partial)?;
 
         Ok(RandomLogRecord(zx::sys::zx_log_record_t {
-            rollout,
+            unused,
             datalen,
             severity,
             flags,
diff --git a/src/diagnostics/archivist/src/logs/testing.rs b/src/diagnostics/archivist/src/logs/testing.rs
index 7f0f779..d1b2c09 100644
--- a/src/diagnostics/archivist/src/logs/testing.rs
+++ b/src/diagnostics/archivist/src/logs/testing.rs
@@ -487,7 +487,7 @@
     pub fn new(log_data: &[u8]) -> Self {
         let mut rec = zx::sys::zx_log_record_t::default();
         let len = rec.data.len().min(log_data.len());
-        rec.rollout = 0;
+        rec.unused = 0;
         rec.datalen = len as u16;
         rec.flags = TEST_KLOG_FLAGS;
         rec.timestamp = TEST_KLOG_TIMESTAMP;
diff --git a/src/lib/zircon/rust/fuchsia-zircon-types/src/lib.rs b/src/lib/zircon/rust/fuchsia-zircon-types/src/lib.rs
index 7744781..6b9fe7d 100644
--- a/src/lib/zircon/rust/fuchsia-zircon-types/src/lib.rs
+++ b/src/lib/zircon/rust/fuchsia-zircon-types/src/lib.rs
@@ -1228,7 +1228,7 @@
     #[repr(C)]
     #[derive(Debug, Copy, Clone, Eq, PartialEq)]
     pub struct <zx_log_record_t> {
-        pub rollout: u32,
+        pub unused: u32,
         pub datalen: u16,
         pub severity: u8,
         pub flags: u8,
@@ -1244,7 +1244,7 @@
 impl Default for zx_log_record_t {
     fn default() -> zx_log_record_t {
         zx_log_record_t {
-            rollout: 0,
+            unused: 0,
             datalen: 0,
             severity: 0,
             flags: 0,
diff --git a/zircon/kernel/lib/debuglog/debuglog.cc b/zircon/kernel/lib/debuglog/debuglog.cc
index c3e7a812..d5b0c26 100644
--- a/zircon/kernel/lib/debuglog/debuglog.cc
+++ b/zircon/kernel/lib/debuglog/debuglog.cc
@@ -228,14 +228,12 @@
     Guard<SpinLock, IrqSave> guard{&log->lock};
 
     size_t rtail = tail_;
-    uint32_t rolled_out = 0;
 
     // If the read-tail is not within the range of log-tail..log-head
     // this reader has been lapped by a writer and we reset our read-tail
     // to the current log-tail.
     //
     if ((log->head - log->tail) < (log->head - rtail)) {
-      rolled_out = static_cast<uint32_t>(log->tail - rtail);
       rtail = log->tail;
     }
 
@@ -255,7 +253,7 @@
         memcpy(record, record_start, fifospace);
         memcpy(reinterpret_cast<char*>(record) + fifospace, log->data, actual - fifospace);
       }
-      record->hdr.preamble = rolled_out;
+      record->hdr.preamble = 0;
 
       *_actual = actual;
       status = ZX_OK;
diff --git a/zircon/kernel/lib/debuglog/debuglog_tests.cc b/zircon/kernel/lib/debuglog/debuglog_tests.cc
index 81c044b..173af89 100644
--- a/zircon/kernel/lib/debuglog/debuglog_tests.cc
+++ b/zircon/kernel/lib/debuglog/debuglog_tests.cc
@@ -119,7 +119,8 @@
   END_TEST;
 }
 
-bool log_reader_rollout() {
+// Write to the log, exceeding its capacity and see that data is lost.
+bool log_reader_dataloss() {
   BEGIN_TEST;
 
   fbl::AllocChecker ac;
@@ -165,11 +166,7 @@
     num_read++;
     ASSERT_EQ(sizeof(dlog_header) + sizeof(msg), got);
     EXPECT_EQ(DEBUGLOG_WARNING, rec.hdr.severity);
-    if (num_read == 1) {
-      EXPECT_EQ(sizeof(dlog_header_t) + sizeof(msg), rec.hdr.preamble);
-    } else {
-      EXPECT_EQ(0u, rec.hdr.preamble);
-    }
+    EXPECT_EQ(0u, rec.hdr.preamble);
     EXPECT_EQ(0, rec.hdr.flags);
     EXPECT_EQ(ZX_KOID_INVALID, rec.hdr.pid);
     EXPECT_NE(ZX_KOID_INVALID, rec.hdr.tid);
@@ -236,6 +233,6 @@
 DEBUGLOG_UNITTEST(log_format)
 DEBUGLOG_UNITTEST(log_wrap)
 DEBUGLOG_UNITTEST(log_reader_read)
-DEBUGLOG_UNITTEST(log_reader_rollout)
+DEBUGLOG_UNITTEST(log_reader_dataloss)
 DEBUGLOG_UNITTEST(shutdown)
 UNITTEST_END_TESTCASE(debuglog_tests, "debuglog_tests", "Debuglog test")
diff --git a/zircon/kernel/lib/debuglog/include/lib/debuglog.h b/zircon/kernel/lib/debuglog/include/lib/debuglog.h
index 783472f..b4a884d 100644
--- a/zircon/kernel/lib/debuglog/include/lib/debuglog.h
+++ b/zircon/kernel/lib/debuglog/include/lib/debuglog.h
@@ -73,11 +73,7 @@
   // (|DLOG_HDR_READLEN|) and the record's size when padded out to live in the
   // FIFO (|DLOG_HDR_FIFOLEN|).
   //
-  // After being read out of a debuglog, the |preamble| field contains the
-  // number of bytes (across both headers and messages) that were dropped from
-  // the log since the last message was read. Note, this is a 32-bit value so if
-  // approximately 4GB of data is written in between two read operations, data
-  // loss may go undetected.
+  // After being read out of a debuglog, the |preamble| field is 0.
   uint32_t preamble;
   uint16_t datalen;
   uint8_t severity;
diff --git a/zircon/system/public/zircon/syscalls/log.h b/zircon/system/public/zircon/syscalls/log.h
index 0f72348..a60649e 100644
--- a/zircon/system/public/zircon/syscalls/log.h
+++ b/zircon/system/public/zircon/syscalls/log.h
@@ -11,7 +11,7 @@
 
 // Defines and structures for zx_log_*()
 typedef struct zx_log_record {
-  uint32_t rollout;
+  uint32_t unused;
   uint16_t datalen;
   uint8_t severity;
   uint8_t flags;