Lines Matching +full:record +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0
14 * --------------
20 * the record and logical positions specifying where in the other
26 * string of the record.
32 * --------------
37 * essential meta data to track the data of a printk record using
48 * A writer is modifying the record.
51 * The record and all its data are written. A writer can reopen the
56 * The record and all its data are complete and available for reading. A
60 * The record exists, but its text and/or meta data may no longer be
63 * Querying the @state_var of a record requires providing the ID of the
86 * When a writer calls the commit function prb_commit(), record data is
88 * reopen that record, claiming exclusive access (as with prb_reserve()), and
89 * modify that record. When finished, the writer must again commit the record.
91 * In order for a record to be made available to readers (and also become
92 * recyclable for writers), it must be finalized. A finalized record cannot be
93 * reopened and can never become "unfinalized". Record finalization can occur
96 * 1) A writer can simultaneously commit and finalize its record by calling
99 * 2) When a new record is reserved and the previous record has been
100 * committed via prb_commit(), that previous record is automatically
103 * 3) When a record is committed via prb_commit() and a newer record
104 * already exists, the record being committed is automatically finalized.
154 * -----
161 * This ringbuffer allows up to 32768 records (2 ^ 15) and has a size of
176 * r.info->text_len = strlen(textstr);
177 * r.info->ts_nsec = local_clock();
178 * r.info->caller_id = printk_caller_id();
180 * // commit and finalize the record
184 * Note that additional writer functions are available to extend a record
188 * Sample writer code (record extending)::
192 * r.info->text_len = strlen(textstr);
193 * r.info->ts_nsec = local_clock();
194 * r.info->caller_id = printk_caller_id();
196 * // commit the record (but do not finalize yet)
207 * snprintf(&r.text_buf[r.info->text_len],
208 * r.text_buf_size - r.info->text_len, "hello");
210 * r.info->text_len += 5;
212 * // commit and finalize the record
227 * pr_warn("lost %llu records\n", info.seq - seq);
230 * pr_warn("record %llu text truncated\n", info.seq);
231 * text_buf[r.text_buf_size - 1] = 0;
239 * allow complex record access.
246 * bits counting array wraps). However, on 32-bit systems the number of
249 * printk messages were to occur in NMI context on a 32-bit system, the
250 * interrupted context would not be able to recognize that the 32-bit integer
257 * a 32-bit system might experience.
308 #define DATA_SIZE(data_ring) _DATA_SIZE((data_ring)->size_bits)
309 #define DATA_SIZE_MASK(data_ring) (DATA_SIZE(data_ring) - 1)
311 #define DESCS_COUNT(desc_ring) _DESCS_COUNT((desc_ring)->count_bits)
312 #define DESCS_COUNT_MASK(desc_ring) (DESCS_COUNT(desc_ring) - 1)
321 #define DATA_WRAPS(data_ring, lpos) ((lpos) >> (data_ring)->size_bits)
323 /* Determine if a logical position refers to a data-less block. */
325 #define BLK_DATALESS(blk) (LPOS_DATALESS((blk)->begin) && \
326 LPOS_DATALESS((blk)->next))
334 DESC_ID((id) - DESCS_COUNT(desc_ring))
343 * Note that the size of a data block is only known by its associated
357 return &desc_ring->descs[DESC_INDEX(desc_ring, n)]; in to_desc()
366 return &desc_ring->infos[DESC_INDEX(desc_ring, n)]; in to_info()
372 return (void *)&data_ring->data[DATA_INDEX(data_ring, begin_lpos)]; in to_block()
376 * Increase the data size to account for data block meta data plus any
377 * padding so that the adjacent data block is aligned on the ID size.
379 static unsigned int to_blk_size(unsigned int size) in to_blk_size() argument
383 size += sizeof(*db); in to_blk_size()
384 size = ALIGN(size, sizeof(db->id)); in to_blk_size()
385 return size; in to_blk_size()
389 * Sanity checker for reserve size. The ringbuffer code assumes that a data
390 * block does not exceed the maximum possible size that could fit within the
391 * ringbuffer. This function provides that basic size check so that the
394 static bool data_check_size(struct prb_data_ring *data_ring, unsigned int size) in data_check_size() argument
398 if (size == 0) in data_check_size()
402 * Ensure the alignment padded size could possibly fit in the data in data_check_size()
406 size = to_blk_size(size); in data_check_size()
407 if (size > DATA_SIZE(data_ring) - sizeof(db->id)) in data_check_size()
429 * non-state_var data, they are only valid if the descriptor is in a
438 atomic_long_t *state_var = &desc->state_var; in desc_read()
474 * state has been re-checked. A memcpy() for all of @desc in desc_read()
478 memcpy(&desc_out->text_blk_lpos, &desc->text_blk_lpos, in desc_read()
479 sizeof(desc_out->text_blk_lpos)); /* LMM(desc_read:C) */ in desc_read()
482 *seq_out = info->seq; /* also part of desc_read:C */ in desc_read()
484 *caller_id_out = info->caller_id; /* also part of desc_read:C */ in desc_read()
487 * 1. Guarantee the descriptor content is loaded before re-checking in desc_read()
503 * 2. Guarantee the record data is loaded before re-checking the in desc_read()
534 atomic_long_set(&desc_out->state_var, state_val); in desc_read()
549 atomic_long_t *state_var = &desc->state_var; in desc_make_reusable()
562 * on error the caller can re-load the tail lpos to determine the situation.
570 struct prb_data_ring *data_ring = &rb->text_data_ring; in data_make_reusable()
571 struct prb_desc_ring *desc_ring = &rb->desc_ring; in data_make_reusable()
579 while ((lpos_end - lpos_begin) - 1 < DATA_SIZE(data_ring)) { in data_make_reusable()
590 id = blk->id; /* LMM(data_make_reusable:A) */ in data_make_reusable()
605 if (blk_lpos->begin != lpos_begin) in data_make_reusable()
614 if (blk_lpos->begin != lpos_begin) in data_make_reusable()
620 lpos_begin = blk_lpos->next; in data_make_reusable()
634 struct prb_data_ring *data_ring = &rb->text_data_ring; in data_push_tail()
639 /* If @lpos is from a data-less block, there is nothing to do. */ in data_push_tail()
661 tail_lpos = atomic_long_read(&data_ring->tail_lpos); /* LMM(data_push_tail:A) */ in data_push_tail()
670 while ((lpos - tail_lpos) - 1 < DATA_SIZE(data_ring)) { in data_push_tail()
733 tail_lpos_new = atomic_long_read(&data_ring->tail_lpos in data_push_tail()
750 if (atomic_long_try_cmpxchg(&data_ring->tail_lpos, &tail_lpos, in data_push_tail()
770 struct prb_desc_ring *desc_ring = &rb->desc_ring; in desc_push_tail()
835 atomic_long_cmpxchg(&desc_ring->tail_id, tail_id, in desc_push_tail()
863 * Re-check the tail ID. The descriptor following @tail_id is in desc_push_tail()
867 if (atomic_long_read(&desc_ring->tail_id) == tail_id) /* LMM(desc_push_tail:D) */ in desc_push_tail()
877 struct prb_desc_ring *desc_ring = &rb->desc_ring; in desc_reserve()
884 head_id = atomic_long_read(&desc_ring->head_id); /* LMM(desc_reserve:A) */ in desc_reserve()
914 if (id_prev_wrap == atomic_long_read(&desc_ring->tail_id in desc_reserve()
950 * happen via desc_push_tail()->data_push_tail(). A full in desc_reserve()
965 } while (!atomic_long_try_cmpxchg(&desc_ring->head_id, &head_id, in desc_reserve()
974 prev_state_val = atomic_long_read(&desc->state_var); /* LMM(desc_reserve:E) */ in desc_reserve()
989 if (!atomic_long_try_cmpxchg(&desc->state_var, &prev_state_val, in desc_reserve()
1003 unsigned long lpos, unsigned int size) in get_next_lpos() argument
1009 next_lpos = lpos + size; in get_next_lpos()
1016 return (DATA_THIS_WRAP_START_LPOS(data_ring, next_lpos) + size); in get_next_lpos()
1024 static char *data_alloc(struct printk_ringbuffer *rb, unsigned int size, in data_alloc() argument
1027 struct prb_data_ring *data_ring = &rb->text_data_ring; in data_alloc()
1032 if (size == 0) { in data_alloc()
1033 /* Specify a data-less block. */ in data_alloc()
1034 blk_lpos->begin = NO_LPOS; in data_alloc()
1035 blk_lpos->next = NO_LPOS; in data_alloc()
1039 size = to_blk_size(size); in data_alloc()
1041 begin_lpos = atomic_long_read(&data_ring->head_lpos); in data_alloc()
1044 next_lpos = get_next_lpos(data_ring, begin_lpos, size); in data_alloc()
1046 if (!data_push_tail(rb, next_lpos - DATA_SIZE(data_ring))) { in data_alloc()
1047 /* Failed to allocate, specify a data-less block. */ in data_alloc()
1048 blk_lpos->begin = FAILED_LPOS; in data_alloc()
1049 blk_lpos->next = FAILED_LPOS; in data_alloc()
1070 } while (!atomic_long_try_cmpxchg(&data_ring->head_lpos, &begin_lpos, in data_alloc()
1074 blk->id = id; /* LMM(data_alloc:B) */ in data_alloc()
1084 blk->id = id; in data_alloc()
1087 blk_lpos->begin = begin_lpos; in data_alloc()
1088 blk_lpos->next = next_lpos; in data_alloc()
1090 return &blk->data[0]; in data_alloc()
1096 * copies the old data to the new data block. If @size yields a data block
1097 * with the same or less size, the data block is left as is.
1105 static char *data_realloc(struct printk_ringbuffer *rb, unsigned int size, in data_realloc() argument
1108 struct prb_data_ring *data_ring = &rb->text_data_ring; in data_realloc()
1115 head_lpos = atomic_long_read(&data_ring->head_lpos); in data_realloc()
1116 if (head_lpos != blk_lpos->next) in data_realloc()
1120 wrapped = (DATA_WRAPS(data_ring, blk_lpos->begin) != DATA_WRAPS(data_ring, blk_lpos->next)); in data_realloc()
1122 size = to_blk_size(size); in data_realloc()
1124 next_lpos = get_next_lpos(data_ring, blk_lpos->begin, size); in data_realloc()
1127 if (head_lpos - next_lpos < DATA_SIZE(data_ring)) { in data_realloc()
1131 blk = to_block(data_ring, blk_lpos->begin); in data_realloc()
1132 return &blk->data[0]; in data_realloc()
1135 if (!data_push_tail(rb, next_lpos - DATA_SIZE(data_ring))) in data_realloc()
1139 if (!atomic_long_try_cmpxchg(&data_ring->head_lpos, &head_lpos, in data_realloc()
1144 blk = to_block(data_ring, blk_lpos->begin); in data_realloc()
1146 if (DATA_WRAPS(data_ring, blk_lpos->begin) != DATA_WRAPS(data_ring, next_lpos)) { in data_realloc()
1156 blk->id = id; in data_realloc()
1164 memcpy(&blk->data[0], &old_blk->data[0], in data_realloc()
1165 (blk_lpos->next - blk_lpos->begin) - sizeof(blk->id)); in data_realloc()
1169 blk_lpos->next = next_lpos; in data_realloc()
1171 return &blk->data[0]; in data_realloc()
1178 /* Data-less blocks take no space. */ in space_used()
1182 if (DATA_WRAPS(data_ring, blk_lpos->begin) == DATA_WRAPS(data_ring, blk_lpos->next)) { in space_used()
1184 return (DATA_INDEX(data_ring, blk_lpos->next) - in space_used()
1185 DATA_INDEX(data_ring, blk_lpos->begin)); in space_used()
1192 return (DATA_INDEX(data_ring, blk_lpos->next) + in space_used()
1193 DATA_SIZE(data_ring) - DATA_INDEX(data_ring, blk_lpos->begin)); in space_used()
1198 * and calculate the size of the data part. A NULL pointer is returned if
1211 /* Data-less data block description. */ in get_data()
1213 if (blk_lpos->begin == NO_LPOS && blk_lpos->next == NO_LPOS) { in get_data()
1221 if (DATA_WRAPS(data_ring, blk_lpos->begin) == DATA_WRAPS(data_ring, blk_lpos->next) && in get_data()
1222 blk_lpos->begin < blk_lpos->next) { in get_data()
1223 db = to_block(data_ring, blk_lpos->begin); in get_data()
1224 *data_size = blk_lpos->next - blk_lpos->begin; in get_data()
1227 } else if (DATA_WRAPS(data_ring, blk_lpos->begin + DATA_SIZE(data_ring)) == in get_data()
1228 DATA_WRAPS(data_ring, blk_lpos->next)) { in get_data()
1230 *data_size = DATA_INDEX(data_ring, blk_lpos->next); in get_data()
1238 /* A valid data block will always be aligned to the ID size. */ in get_data()
1239 if (WARN_ON_ONCE(blk_lpos->begin != ALIGN(blk_lpos->begin, sizeof(db->id))) || in get_data()
1240 WARN_ON_ONCE(blk_lpos->next != ALIGN(blk_lpos->next, sizeof(db->id)))) { in get_data()
1245 if (WARN_ON_ONCE(*data_size < sizeof(db->id))) in get_data()
1248 /* Subtract block ID space from size to reflect data size. */ in get_data()
1249 *data_size -= sizeof(db->id); in get_data()
1251 return &db->data[0]; in get_data()
1256 * so that the record can be modified by a writer again. This is only possible
1269 id = atomic_long_read(&desc_ring->head_id); in desc_reopen_last()
1285 * record data. A full memory barrier is needed because @state_var in desc_reopen_last()
1299 if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val, in desc_reopen_last()
1309 * prb_reserve_in_last() - Re-reserve and extend the space in the ringbuffer
1310 * used by the newest record.
1313 * @rb: The ringbuffer to re-reserve and extend data in.
1314 * @r: The record structure to allocate buffers for.
1316 * @max_size: Fail if the extended size would be greater than this.
1318 * This is the public function available to writers to re-reserve and extend
1321 * The writer specifies the text size to extend (not the new total size) by
1326 * newest record. In that case the caller must reserve new data using
1334 * - @r->text_buf points to the beginning of the entire text buffer.
1336 * - @r->text_buf_size is set to the new total size of the buffer.
1338 * - @r->info is not touched so that @r->info->text_len could be used
1341 * - prb_record_text_space() can be used on @e to query the new
1344 * Important: All @r->info fields will already be set with the current values
1345 * for the record. I.e. @r->info->text_len will be less than
1346 * @text_buf_size. Writers can use @r->info->text_len to know
1348 * @r->info->text_len after concatenating.
1353 struct prb_desc_ring *desc_ring = &rb->desc_ring; in prb_reserve_in_last()
1359 local_irq_save(e->irqflags); in prb_reserve_in_last()
1364 local_irq_restore(e->irqflags); in prb_reserve_in_last()
1376 e->rb = rb; in prb_reserve_in_last()
1377 e->id = id; in prb_reserve_in_last()
1384 if (caller_id != info->caller_id) in prb_reserve_in_last()
1387 if (BLK_DATALESS(&d->text_blk_lpos)) { in prb_reserve_in_last()
1388 if (WARN_ON_ONCE(info->text_len != 0)) { in prb_reserve_in_last()
1390 info->text_len); in prb_reserve_in_last()
1391 info->text_len = 0; in prb_reserve_in_last()
1394 if (!data_check_size(&rb->text_data_ring, r->text_buf_size)) in prb_reserve_in_last()
1397 if (r->text_buf_size > max_size) in prb_reserve_in_last()
1400 r->text_buf = data_alloc(rb, r->text_buf_size, in prb_reserve_in_last()
1401 &d->text_blk_lpos, id); in prb_reserve_in_last()
1403 if (!get_data(&rb->text_data_ring, &d->text_blk_lpos, &data_size)) in prb_reserve_in_last()
1407 * Increase the buffer size to include the original size. If in prb_reserve_in_last()
1409 * block size. in prb_reserve_in_last()
1411 if (WARN_ON_ONCE(info->text_len > data_size)) { in prb_reserve_in_last()
1413 info->text_len, data_size); in prb_reserve_in_last()
1414 info->text_len = data_size; in prb_reserve_in_last()
1416 r->text_buf_size += info->text_len; in prb_reserve_in_last()
1418 if (!data_check_size(&rb->text_data_ring, r->text_buf_size)) in prb_reserve_in_last()
1421 if (r->text_buf_size > max_size) in prb_reserve_in_last()
1424 r->text_buf = data_realloc(rb, r->text_buf_size, in prb_reserve_in_last()
1425 &d->text_blk_lpos, id); in prb_reserve_in_last()
1427 if (r->text_buf_size && !r->text_buf) in prb_reserve_in_last()
1430 r->info = info; in prb_reserve_in_last()
1432 e->text_space = space_used(&rb->text_data_ring, &d->text_blk_lpos); in prb_reserve_in_last()
1437 /* prb_commit() re-enabled interrupts. */ in prb_reserve_in_last()
1439 /* Make it clear to the caller that the re-reserve failed. */ in prb_reserve_in_last()
1453 atomic_long_cmpxchg_relaxed(&d->state_var, prev_state_val, in desc_make_final()
1457 atomic_long_set(&desc_ring->last_finalized_id, id); in desc_make_final()
1461 * prb_reserve() - Reserve space in the ringbuffer.
1465 * @r: The record structure to allocate buffers for.
1469 * The writer specifies the text size to reserve by setting the
1481 * Important: @info->text_len needs to be set correctly by the writer in
1488 struct prb_desc_ring *desc_ring = &rb->desc_ring; in prb_reserve()
1494 if (!data_check_size(&rb->text_data_ring, r->text_buf_size)) in prb_reserve()
1503 local_irq_save(e->irqflags); in prb_reserve()
1507 atomic_long_inc(&rb->fail); in prb_reserve()
1508 local_irq_restore(e->irqflags); in prb_reserve()
1520 seq = info->seq; in prb_reserve()
1527 e->rb = rb; in prb_reserve()
1528 e->id = id; in prb_reserve()
1542 info->seq = DESC_INDEX(desc_ring, id); in prb_reserve()
1544 info->seq = seq + DESCS_COUNT(desc_ring); in prb_reserve()
1552 if (info->seq > 0) in prb_reserve()
1553 desc_make_final(desc_ring, DESC_ID(id - 1)); in prb_reserve()
1555 r->text_buf = data_alloc(rb, r->text_buf_size, &d->text_blk_lpos, id); in prb_reserve()
1556 /* If text data allocation fails, a data-less record is committed. */ in prb_reserve()
1557 if (r->text_buf_size && !r->text_buf) { in prb_reserve()
1559 /* prb_commit() re-enabled interrupts. */ in prb_reserve()
1563 r->info = info; in prb_reserve()
1565 /* Record full text space used by record. */ in prb_reserve()
1566 e->text_space = space_used(&rb->text_data_ring, &d->text_blk_lpos); in prb_reserve()
1578 struct prb_desc_ring *desc_ring = &e->rb->desc_ring; in _prb_commit()
1579 struct prb_desc *d = to_desc(desc_ring, e->id); in _prb_commit()
1580 unsigned long prev_state_val = DESC_SV(e->id, desc_reserved); in _prb_commit()
1588 * 1 Guarantee all record data is stored before the descriptor state in _prb_commit()
1593 * re-checking the head ID in order to possibly finalize this in _prb_commit()
1607 if (!atomic_long_try_cmpxchg(&d->state_var, &prev_state_val, in _prb_commit()
1608 DESC_SV(e->id, state_val))) { /* LMM(_prb_commit:B) */ in _prb_commit()
1613 local_irq_restore(e->irqflags); in _prb_commit()
1617 * prb_commit() - Commit (previously reserved) data to the ringbuffer.
1624 * Finalizing happens automatically when space for the next record is
1634 struct prb_desc_ring *desc_ring = &e->rb->desc_ring; in prb_commit()
1640 * If this descriptor is no longer the head (i.e. a new record has in prb_commit()
1641 * been allocated), extending the data for this record is no longer in prb_commit()
1644 head_id = atomic_long_read(&desc_ring->head_id); /* LMM(prb_commit:A) */ in prb_commit()
1645 if (head_id != e->id) in prb_commit()
1646 desc_make_final(desc_ring, e->id); in prb_commit()
1650 * prb_final_commit() - Commit and finalize (previously reserved) data to
1666 struct prb_desc_ring *desc_ring = &e->rb->desc_ring; in prb_final_commit()
1671 atomic_long_set(&desc_ring->last_finalized_id, e->id); in prb_final_commit()
1691 next_size = text_size - (next - text); in count_lines()
1702 * size to possibly detect bugs in the writer code. A WARN_ON_ONCE() is
1746 * descriptor. However, it also verifies that the record is finalized and has
1750 * -EINVAL: A finalized record with sequence number @seq does not exist.
1751 * -ENOENT: A finalized record with sequence number @seq exists, but its data
1752 * is not available. This is a valid record, so readers should
1753 * continue with the next record.
1759 struct prb_data_blk_lpos *blk_lpos = &desc_out->text_blk_lpos; in desc_read_finalized_seq()
1766 * An unexpected @id (desc_miss) or @seq mismatch means the record in desc_read_finalized_seq()
1768 * means the record does not yet exist for the reader. in desc_read_finalized_seq()
1774 return -EINVAL; in desc_read_finalized_seq()
1779 * available; report it as existing but with lost data. Or the record in desc_read_finalized_seq()
1780 * may actually be a record with lost data. in desc_read_finalized_seq()
1783 (blk_lpos->begin == FAILED_LPOS && blk_lpos->next == FAILED_LPOS)) { in desc_read_finalized_seq()
1784 return -ENOENT; in desc_read_finalized_seq()
1791 * Copy the ringbuffer data from the record with @seq to the provided
1799 struct prb_desc_ring *desc_ring = &rb->desc_ring; in prb_read()
1802 atomic_long_t *state_var = &rdesc->state_var; in prb_read()
1815 * of the record. in prb_read()
1821 if (r->info) in prb_read()
1822 memcpy(r->info, info, sizeof(*(r->info))); in prb_read()
1824 /* Copy text data. If it fails, this is a data-less record. */ in prb_read()
1825 if (!copy_data(&rb->text_data_ring, &desc.text_blk_lpos, info->text_len, in prb_read()
1826 r->text_buf, r->text_buf_size, line_count)) { in prb_read()
1827 return -ENOENT; in prb_read()
1830 /* Ensure the record is still finalized and has the same @seq. */ in prb_read()
1837 struct prb_desc_ring *desc_ring = &rb->desc_ring; in prb_first_seq()
1844 id = atomic_long_read(&rb->desc_ring.tail_id); /* LMM(prb_first_seq:A) */ in prb_first_seq()
1879 * Non-blocking read of a record. Updates @seq to the last finalized record
1897 * can happen for -ENOENT and -EINVAL cases. in _prb_read_valid()
1901 } else if (err == -ENOENT) { in _prb_read_valid()
1902 /* Record exists, but no data available. Skip. */ in _prb_read_valid()
1906 /* Non-existent/non-finalized record. Must stop. */ in _prb_read_valid()
1915 * prb_read_valid() - Non-blocking read of a requested record or (if gone)
1916 * the next available record.
1919 * @seq: The sequence number of the record to read.
1920 * @r: A record data buffer to store the read record to.
1922 * This is the public function available to readers to read a record.
1930 * Return: true if a record was read, otherwise false.
1932 * On success, the reader must check r->info.seq to see which record was
1935 * Failure means @seq refers to a not yet written record.
1944 * prb_read_valid_info() - Non-blocking read of meta data for a requested
1945 * record or (if gone) the next available record.
1948 * @seq: The sequence number of the record to read.
1949 * @info: A buffer to store the read record meta data to.
1950 * @line_count: A buffer to store the number of lines in the record text.
1953 * meta data of a record.
1960 * Return: true if a record's meta data was read, otherwise false.
1962 * On success, the reader must check info->seq to see which record meta data
1965 * Failure means @seq refers to a not yet written record.
1978 * prb_first_valid_seq() - Get the sequence number of the oldest available
1979 * record.
1989 * Return: The sequence number of the first/oldest record or, if the
2003 * prb_next_seq() - Get the sequence number after the last available record.
2014 * Return: The sequence number of the next newest (not yet available) record
2019 struct prb_desc_ring *desc_ring = &rb->desc_ring; in prb_next_seq()
2025 id = atomic_long_read(&desc_ring->last_finalized_id); in prb_next_seq()
2030 * Begin searching after the last finalized record. in prb_next_seq()
2034 * record at index 0 exists. in prb_next_seq()
2059 * prb_init() - Initialize a ringbuffer to use provided external buffers.
2063 * @textbits: The size of @text_buf as a power-of-2 value.
2065 * @descbits: The count of @descs items as a power-of-2 value.
2083 rb->desc_ring.count_bits = descbits; in prb_init()
2084 rb->desc_ring.descs = descs; in prb_init()
2085 rb->desc_ring.infos = infos; in prb_init()
2086 atomic_long_set(&rb->desc_ring.head_id, DESC0_ID(descbits)); in prb_init()
2087 atomic_long_set(&rb->desc_ring.tail_id, DESC0_ID(descbits)); in prb_init()
2088 atomic_long_set(&rb->desc_ring.last_finalized_id, DESC0_ID(descbits)); in prb_init()
2090 rb->text_data_ring.size_bits = textbits; in prb_init()
2091 rb->text_data_ring.data = text_buf; in prb_init()
2092 atomic_long_set(&rb->text_data_ring.head_lpos, BLK0_LPOS(textbits)); in prb_init()
2093 atomic_long_set(&rb->text_data_ring.tail_lpos, BLK0_LPOS(textbits)); in prb_init()
2095 atomic_long_set(&rb->fail, 0); in prb_init()
2097 atomic_long_set(&(descs[_DESCS_COUNT(descbits) - 1].state_var), DESC0_SV(descbits)); in prb_init()
2098 descs[_DESCS_COUNT(descbits) - 1].text_blk_lpos.begin = FAILED_LPOS; in prb_init()
2099 descs[_DESCS_COUNT(descbits) - 1].text_blk_lpos.next = FAILED_LPOS; in prb_init()
2101 infos[0].seq = -(u64)_DESCS_COUNT(descbits); in prb_init()
2102 infos[_DESCS_COUNT(descbits) - 1].seq = 0; in prb_init()
2106 * prb_record_text_space() - Query the full actual used ringbuffer space for
2119 * Return: The size in bytes used by the text data of the associated record.
2123 return e->text_space; in prb_record_text_space()