)]}'
{
  "commit": "66a8cb95ed04025664d1db4e952155ee1dccd048",
  "tree": "74417422a78bc8198de46b0e52e490175af866e0",
  "parents": [
    "eb0c53771fb2f5f66b0edb3ebce33be4bbf1c285"
  ],
  "author": {
    "name": "Steven Rostedt",
    "email": "srostedt@redhat.com",
    "time": "Wed Mar 31 13:21:56 2010 -0400"
  },
  "committer": {
    "name": "Steven Rostedt",
    "email": "rostedt@goodmis.org",
    "time": "Wed Mar 31 22:57:04 2010 -0400"
  },
  "message": "ring-buffer: Add place holder recording of dropped events\n\nCurrently, when the ring buffer drops events, it does not record\nthe fact that it did so. It does inform the writer that the event\nwas dropped by returning a NULL event, but it does not put in any\nplace holder where the event was dropped.\n\nThis is not a trivial thing to add because the ring buffer mostly\nruns in overwrite (flight recorder) mode. That is, when the ring\nbuffer is full, new data will overwrite old data.\n\nIn a produce/consumer mode, where new data is simply dropped when\nthe ring buffer is full, it is trivial to add the placeholder\nfor dropped events. When there\u0027s more room to write new data, then\na special event can be added to notify the reader about the dropped\nevents.\n\nBut in overwrite mode, any new write can overwrite events. A place\nholder can not be inserted into the ring buffer since there never\nmay be room. A reader could also come in at anytime and miss the\nplaceholder.\n\nLuckily, the way the ring buffer works, the read side can find out\nif events were lost or not, and how many events. Everytime a write\ntakes place, if it overwrites the header page (the next read) it\nupdates a \"overrun\" variable that keeps track of the number of\nlost events. When a reader swaps out a page from the ring buffer,\nit can record this number, perfom the swap, and then check to\nsee if the number changed, and take the diff if it has, which would be\nthe number of events dropped. This can be stored by the reader\nand returned to callers of the reader.\n\nSince the reader page swap will fail if the writer moved the head\npage since the time the reader page set up the swap, this gives room\nto record the overruns without worrying about races. If the reader\nsets up the pages, records the overrun, than performs the swap,\nif the swap succeeds, then the overrun variable has not been\nupdated since the setup before the swap.\n\nFor binary readers of the ring buffer, a flag is set in the header\nof each sub page (sub buffer) of the ring buffer. This flag is embedded\nin the size field of the data on the sub buffer, in the 31st bit (the size\ncan be 32 or 64 bits depending on the architecture), but only 27\nbits needs to be used for the actual size (less actually).\n\nWe could add a new field in the sub buffer header to also record the\nnumber of events dropped since the last read, but this will change the\nformat of the binary ring buffer a bit too much. Perhaps this change can\nbe made if the information on the number of events dropped is considered\nimportant enough.\n\nNote, the notification of dropped events is only used by consuming reads\nor peeking at the ring buffer. Iterating over the ring buffer does not\nkeep this information because the necessary data is only available when\na page swap is made, and the iterator does not swap out pages.\n\nCc: Robert Richter \u003crobert.richter@amd.com\u003e\nCc: Andi Kleen \u003candi@firstfloor.org\u003e\nCc: Li Zefan \u003clizf@cn.fujitsu.com\u003e\nCc: Arnaldo Carvalho de Melo \u003cacme@redhat.com\u003e\nCc: \"Luis Claudio R. Goncalves\" \u003clclaudio@uudg.org\u003e\nCc: Frederic Weisbecker \u003cfweisbec@gmail.com\u003e\nSigned-off-by: Steven Rostedt \u003crostedt@goodmis.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "166b67ea622f11563a33c539b78c5dafc7c2503f",
      "old_mode": 33188,
      "old_path": "drivers/oprofile/cpu_buffer.c",
      "new_id": "7581dbe456da91de62aa5f96a8479f9058999390",
      "new_mode": 33188,
      "new_path": "drivers/oprofile/cpu_buffer.c"
    },
    {
      "type": "modify",
      "old_id": "5fcc31ed5771358b625eb24434e656e28f016cd8",
      "old_mode": 33188,
      "old_path": "include/linux/ring_buffer.h",
      "new_id": "c8297761e414b43aac4e6a6323d2846fe3fa2b47",
      "new_mode": 33188,
      "new_path": "include/linux/ring_buffer.h"
    },
    {
      "type": "modify",
      "old_id": "d1187ef20caf914048fb897dc5c63f1b302edbf6",
      "old_mode": 33188,
      "old_path": "kernel/trace/ring_buffer.c",
      "new_id": "8295650444c5e939a647b83c7a8a8b5b1d946c47",
      "new_mode": 33188,
      "new_path": "kernel/trace/ring_buffer.c"
    },
    {
      "type": "modify",
      "old_id": "df74c7982255ba1c5095371e1ca3fd5369d3f3c2",
      "old_mode": 33188,
      "old_path": "kernel/trace/ring_buffer_benchmark.c",
      "new_id": "dc56556b55a24424bf4b0b10c79f00c39a8a86be",
      "new_mode": 33188,
      "new_path": "kernel/trace/ring_buffer_benchmark.c"
    },
    {
      "type": "modify",
      "old_id": "3ec2ee6f65602fde8cf701432a18b8c7b2fef11e",
      "old_mode": 33188,
      "old_path": "kernel/trace/trace.c",
      "new_id": "fabb0033a9be36ae8775b5bdd98c1b1bc4b5c99f",
      "new_mode": 33188,
      "new_path": "kernel/trace/trace.c"
    },
    {
      "type": "modify",
      "old_id": "e6989d9b44dae8a23a60bcdb669f226329ef1025",
      "old_mode": 33188,
      "old_path": "kernel/trace/trace_functions_graph.c",
      "new_id": "a7f75fb10aa4f326d697425c8b9c79b37b1f0bb6",
      "new_mode": 33188,
      "new_path": "kernel/trace/trace_functions_graph.c"
    },
    {
      "type": "modify",
      "old_id": "280fea470d67ea603f230d8bfc7868d5d48e62b2",
      "old_mode": 33188,
      "old_path": "kernel/trace/trace_selftest.c",
      "new_id": "e50180874c638e1a58697768b9ab7f7310229371",
      "new_mode": 33188,
      "new_path": "kernel/trace/trace_selftest.c"
    }
  ]
}
