Lines Matching refs:page

29 reader_page - A page outside the ring buffer used solely (for the most part)
32 head_page - a pointer to the page that the reader will use next
34 tail_page - a pointer to the page that will be written to next
36 commit_page - a pointer to the page with the last finished non-nested write.
93 At initialization a reader page is allocated for the reader that is not
97 to the same page.
99 The reader page is initialized to have its next pointer pointing to
100 the head page, and its previous pointer pointing to a page before
101 the head page.
103 The reader has its own page to use. At start up time, this page is
105 to read from the buffer, if its page is empty (like it is on start-up),
106 it will swap its page with the head_page. The old reader page will
108 The page after the inserted page (old reader_page) will become the
109 new head page.
111 Once the new page is given to the reader, the reader could do what
112 it wants with it, as long as a writer has left that page.
114 A sample of how the reader page is swapped: Note this does not
115 show the head page in the buffer, it is for demonstrating a swap
120 |page |
133 |page |-------------------+
146 |page |-------------------+
159 |page |-------------------+
165 | | page ----^ | |
172 It is possible that the page swapped is the commit page and the tail page,
173 if what is in the ring buffer is less than what is held in a buffer page.
176 reader page commit page tail page
192 When the writer leaves the page, it simply goes into the ring buffer
193 since the reader page still points to the next location in the ring
199 reader page - The page used solely by the reader and is not part
202 head page - the next page in the ring buffer that will be swapped
203 with the reader page.
205 tail page - the page where the next write will take place.
207 commit page - the page that last finished a write.
209 The commit page only is updated by the outermost writer in the
211 commit page.
224 Buffer page
235 Buffer page
247 Buffer page
259 Buffer page
271 Buffer page
286 The commit page points to the page that has the last full commit.
287 The tail page points to the page with the last write (before
290 The tail page is always equal to or after the commit page. It may
291 be several pages ahead. If the tail page catches up to the commit
292 page then no more writes may take place (regardless of the mode
297 head page
298 commit page
299 tail page
302 tail page
303 head page commit page |
311 There is a special case that the head page is after either the commit page
312 and possibly the tail page. That is when the commit (and tail) page has been
313 swapped with the reader page. This is because the head page is always
314 part of the ring buffer, but the reader page is not. Whenever there
315 has been less than a full page that has been committed inside the ring buffer,
316 and a reader swaps out a page, it will be swapping out the commit page.
319 reader page commit page tail page
335 head page
338 In this case, the head page will not move when the tail and commit
341 The reader cannot swap a page into the ring buffer if the commit page
342 is still on that page. If the read meets the last commit (real commit
346 When the tail meets the head page, if the buffer is in overwrite mode,
347 the head page will be pushed ahead one. If the buffer is in producer/consumer
352 tail page
361 head page
364 tail page
373 head page
376 tail page
385 head page
387 Note, the reader page will still point to the previous head page.
388 But when a swap takes place, it will use the most recent head page.
396 State flags are placed inside the pointer to the page. To do this,
397 each page must be aligned in memory by 4 bytes. This will allow the 2
408 HEADER - the page being pointed to is a head page
410 UPDATE - the page being pointed to is being updated by a writer
411 and was or is about to be a head page.
414 reader page
429 the next page is the next page to be swapped out by the reader.
430 This pointer means the next page is the head page.
432 When the tail page meets the head pointer, it will use cmpxchg to
436 tail page
444 tail page
459 When the reader tries to swap the page with the ring buffer, it
461 head page does not have the HEADER flag set, the compare will fail
462 and the reader will need to look for the new head page and try again.
465 The reader swaps the reader page as follows:
469 |page |
479 The reader sets the reader page next pointer as HEADER to the page after
480 the head page.
485 |page |-------H-----------+
496 It does a cmpxchg with the pointer to the previous head page to make it
497 point to the reader page. Note that the new pointer does not have the HEADER
498 flag set. This action atomically moves the head page forward.
502 |page |-------H-----------+
513 After the new head page is set, the previous pointer of the head page is
514 updated to the reader page.
518 |page |-------H-----------+
531 |page |-------H-----------+ <--- New head page
537 | | page ----^ | |
542 Another important point: The page that the reader page points back to
543 by its previous pointer (the one that now points to the new head page)
544 never points back to the reader page. That is because the reader page is
549 Note, the way to determine a reader page is simply by examining the previous
550 pointer of the page. If the next pointer of the previous page does not
551 point back to the original page, then the original page is a reader page:
556 | page |-------->| |<====== (buffer page)
564 The way the head page moves forward:
566 When the tail page meets the head page and the buffer is in overwrite mode
567 and more writes take place, the head page must be moved forward before the
568 writer may move the tail page. The way this is done is that the writer
569 performs a cmpxchg to convert the pointer to the head page from the HEADER
571 not be able to swap the head page from the buffer, nor will it be able to
572 move the head page, until the writer is finished with the move.
577 tail page
585 tail page
593 The following page will be made into the new head page.
595 tail page
603 After the new head page has been set, we can set the old head page
606 tail page
614 After the head page has been moved, the tail page may now move forward.
616 tail page
629 tail page may make it all the way around the buffer and meet the commit
630 page. At this time, we must start dropping writes (usually with some kind
632 reader page? The commit page is not part of the ring buffer. The tail page
636 reader page commit page
652 tail page
654 If the tail page were to simply push the head page forward, the commit when
655 leaving the reader page would not be pointing to the correct page.
657 The solution to this is to test if the commit page is on the reader page
658 before pushing the head page. If it is, then it can be assumed that the
659 tail page wrapped the buffer, and we must drop new writes.
661 This is not a race condition, because the commit page can only be moved
664 tail page. The reader cannot swap the reader page if it is also being
665 used as the commit page. The reader can simply check that the commit
666 is off the reader page. Once the commit page leaves the reader page
668 buffer page that is also the commit page.
674 In the pushing forward of the tail page we must first push forward
675 the head page if the head page is the next page. If the head page
676 is not the next page, the tail page is simply updated with a cmpxchg.
678 Only writers move the tail page. This must be done atomically to protect
685 The above will update the tail page if it is still pointing to the expected
686 page. If this fails, a nested write pushed it forward, the current write
690 temp page
693 tail page
701 Nested write comes in and moves the tail page forward:
703 tail page (moved by nested writer)
704 temp page |
712 The above would fail the cmpxchg, but since the tail page has already
714 on the new tail page.
716 But the moving of the head page is a bit more complex.
718 tail page
726 The write converts the head page pointer to UPDATE.
728 tail page
737 page is a head page, but it is also nested. It will detect that
742 The nested writer will set the new head page pointer.
744 tail page
756 tail page
768 tail page
778 the tail page ahead several pages:
783 tail page
791 The write converts the head page pointer to UPDATE.
793 tail page
802 head page.
806 tail page
814 The nested writer moves the tail page forward. But does not set the old
815 update page to NORMAL because it is not the outermost writer.
817 tail page
825 Another writer preempts and sees the page after the tail page is a head page.
830 tail page
838 The writer will move the head page forward:
843 tail page
857 tail page
866 Then it will move the tail page, and return back to the second writer.
871 tail page
880 The second writer will fail to move the tail page because it was already
881 moved, so it will try again and add its data to the new tail page.
887 tail page
895 The first writer cannot know atomically if the tail page moved
896 while it updates the HEAD page. It will then update the head page to
897 what it thinks is the new head page.
902 tail page
913 if the tail page is either where it use to be or on the next page:
918 A B tail page
926 If tail page != A and tail page != B, then it must reset the pointer
928 writers means that it only needs to check this after setting the HEAD page.
933 A B tail page
941 Now the writer can update the head page. This is also why the head page must
943 the reader from seeing the incorrect head page.
948 A B tail page