kernel-ark/drivers
Steven Rostedt 66a8cb95ed ring-buffer: Add place holder recording of dropped events
Currently, when the ring buffer drops events, it does not record
the fact that it did so. It does inform the writer that the event
was dropped by returning a NULL event, but it does not put in any
place holder where the event was dropped.

This is not a trivial thing to add because the ring buffer mostly
runs in overwrite (flight recorder) mode. That is, when the ring
buffer is full, new data will overwrite old data.

In a produce/consumer mode, where new data is simply dropped when
the ring buffer is full, it is trivial to add the placeholder
for dropped events. When there's more room to write new data, then
a special event can be added to notify the reader about the dropped
events.

But in overwrite mode, any new write can overwrite events. A place
holder can not be inserted into the ring buffer since there never
may be room. A reader could also come in at anytime and miss the
placeholder.

Luckily, the way the ring buffer works, the read side can find out
if events were lost or not, and how many events. Everytime a write
takes place, if it overwrites the header page (the next read) it
updates a "overrun" variable that keeps track of the number of
lost events. When a reader swaps out a page from the ring buffer,
it can record this number, perfom the swap, and then check to
see if the number changed, and take the diff if it has, which would be
the number of events dropped. This can be stored by the reader
and returned to callers of the reader.

Since the reader page swap will fail if the writer moved the head
page since the time the reader page set up the swap, this gives room
to record the overruns without worrying about races. If the reader
sets up the pages, records the overrun, than performs the swap,
if the swap succeeds, then the overrun variable has not been
updated since the setup before the swap.

For binary readers of the ring buffer, a flag is set in the header
of each sub page (sub buffer) of the ring buffer. This flag is embedded
in the size field of the data on the sub buffer, in the 31st bit (the size
can be 32 or 64 bits depending on the architecture), but only 27
bits needs to be used for the actual size (less actually).

We could add a new field in the sub buffer header to also record the
number of events dropped since the last read, but this will change the
format of the binary ring buffer a bit too much. Perhaps this change can
be made if the information on the number of events dropped is considered
important enough.

Note, the notification of dropped events is only used by consuming reads
or peeking at the ring buffer. Iterating over the ring buffer does not
keep this information because the necessary data is only available when
a page swap is made, and the iterator does not swap out pages.

Cc: Robert Richter <robert.richter@amd.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: "Luis Claudio R. Goncalves" <lclaudio@uudg.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-03-31 22:57:04 -04:00
..
accessibility
acpi acpi: Support IBM SMBus CMI devices 2010-03-24 14:38:37 +01:00
amba
ata pata_via: fix VT6410/6415/6330 detection issue 2010-03-28 00:51:50 -04:00
atm atm: use for_each_set_bit() 2010-03-15 16:00:47 -07:00
auxdisplay
base power: support _noirq actions on device types and classes 2010-03-24 11:00:02 +01:00
block Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-03-12 16:04:50 -08:00
bluetooth
cdrom
char Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/anholt/drm-intel 2010-03-24 16:42:43 -07:00
clocksource
connector
cpufreq
cpuidle
crypto
dca
dio
dma Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-03-12 16:04:50 -08:00
edac edac, mce: Filter out invalid values 2010-03-22 16:33:31 +01:00
eisa
firewire Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6 2010-03-26 15:07:46 -07:00
firmware
gpio drivers/gpio/max730x.c: add license macro 2010-03-24 16:31:20 -07:00
gpu Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2010-03-26 16:34:29 -07:00
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid 2010-03-18 16:52:31 -07:00
hwmon hwmon: (asc7621) Add X58 entry in Kconfig 2010-03-29 22:03:06 +02:00
i2c i2c-scmi: Provide module aliases for automatic loading 2010-03-24 14:38:39 +01:00
ide Revert "ide: skip probe if there are no devices on the port (v2)" 2010-03-28 18:58:28 -07:00
idle
ieee1394 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-03-12 16:04:50 -08:00
ieee802154
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2010-03-19 13:39:42 -07:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2010-03-14 11:13:54 -07:00
isdn isdn: Cleanup Sections in PCMCIA driver elsa 2010-03-25 11:58:02 -07:00
leds leds: Fix race between LED device uevent and actual attributes creation 2010-03-16 20:27:25 +00:00
lguest
macintosh backlight: Allow properties to be passed at registration 2010-03-16 19:47:54 +00:00
mca
md Merge branch 'for-linus' of git://neil.brown.name/md 2010-03-18 16:55:24 -07:00
media Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2010-03-14 11:13:54 -07:00
memstick
message
mfd Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6 2010-03-12 16:41:09 -08:00
misc c2port: fix device_create() return value check 2010-03-24 16:31:21 -07:00
mmc mmc: fix incorrect interpretation of card type bits 2010-03-24 16:31:21 -07:00
mtd Delete zero-length file drivers/mtd/maps/omap_nor.c 2010-03-19 14:25:45 -04:00
net r8169: offical fix for CVE-2009-4537 (overlength frame DMAs) 2010-03-29 13:16:02 -07:00
nubus
of
oprofile ring-buffer: Add place holder recording of dropped events 2010-03-31 22:57:04 -04:00
parisc
parport
pci Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2010-03-26 16:34:29 -07:00
pcmcia Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2010-03-26 16:34:29 -07:00
platform backlight: panasonic-laptop - Fix incomplete registration failure handling 2010-03-16 20:13:31 +00:00
pnp PNPACPI: add bus number support 2010-03-14 20:08:38 -04:00
power Merge branches 'battery-2.6.34', 'bugzilla-10805', 'bugzilla-14668', 'bugzilla-531916-power-state', 'ht-warn-2.6.34', 'pnp', 'processor-rename', 'sony-2.6.34', 'suse-bugzilla-531547', 'tz-check', 'video' and 'misc-2.6.34' into release 2010-03-14 21:30:17 -04:00
pps pps: serial clients support 2010-03-12 15:52:43 -08:00
ps3
rapidio
regulator regulator: fix dangling pointers 2010-03-22 19:46:16 +00:00
rtc rtc/mc13783: fix use after free bug 2010-03-24 16:31:19 -07:00
s390 [S390] fix broken proc interface for sclp_async 2010-03-24 11:49:53 +01:00
sbus
scsi Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2010-03-18 16:54:31 -07:00
serial Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2010-03-29 14:41:18 -07:00
sfi
sh Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6 2010-03-19 18:16:20 -07:00
sn
spi Merge branch 'merge' of git://git.secretlab.ca/git/linux-2.6 2010-03-18 17:01:19 -07:00
ssb
staging Staging: et131x: Properly disable FC in txmac. 2010-03-29 08:51:36 -07:00
tc
telephony
thermal
uio
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6 2010-03-19 13:40:03 -07:00
uwb Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/dvrabel/uwb 2010-03-19 18:14:22 -07:00
vhost vhost: fix error handling in vring ioctls 2010-03-17 23:07:35 +02:00
video Merge branch 'for-linus' of git://gitorious.org/linux-omap-dss2/linux 2010-03-24 16:52:15 -07:00
virtio
vlynq
w1 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-03-12 16:04:50 -08:00
watchdog
xen
zorro
Kconfig
Makefile