0

About 5-20 times a day I am presented with brief visual glitches and heisenbugs caused by race conditions that only occur under high I/O load. These disappear off the screen far too quickly for me to grab a camera in time, so I am looking to find/build a screenshotting/screen-recording tool that acts/responds with the lowest possible delay after I press a hotkey/shortcut.

Critically, this tool's high-responsiveness needs to be negligibly (ideally not at all) impacted by high I/O activity, like 10-second load averages of 20-40.

A fair argument could be made about loading PREEMPT_RT and running Xorg and a homemade screenshot dæmon as realtime. This would work... except for the bit about running X realtime; I actually do want to get work done on my computer. :)

Thing is, I can confidently run any code I like in realtime on my computer, just by putting it inside the Linux kernel. So, kernel module time!! To reiterate my question,

How do I find, access and grok the memory region(s) representing the pixels on my screen, all from within a Linux kernel module?

I've found that trying to read /dev/fb0 while X is running just produces a black image, so that apparently won't work.

Unfortunately https://dri.freedesktop.org/docs/drm/gpu/index.html doesn't show anything obviously related to framebuffer read-back, but I have no experience with this API, so I don't really know what I'm looking for.

I accept that driver-specific code will likely be needed (since there's unlikely a driver-agnostic canonical spot in memory representing what's actually on screen), and this fine. I'm using an Intel-GPU-based machine at the moment, and I am happy to start specifically coding for that.

FWIW, I asked a differently-worded version of this question just under two years ago. That question only attracted one comment about HDCP and was never answered, but as I am still dealing with this problem up to 20 times a day even two years later, I'm having another go.

(My current approach (scrot launched by i3's hotkey binder) very often takes up to 20 (!!) seconds to take a single screenshot on systems experiencing high I/O load.)

  • It may depend on what video driver and kernel sub-system you are using. Running X.org 2D or 3D acceleration or simple frame buffer? Places like /dev/dri /dev/fbx /dev/mem /dev/nvidia0 and others. – jc__ Feb 12 at 16:03
  • @jc__: I'm using the intel driver - as I noted - and presume this provides 2D and basic 3D accel. I've already had a look at the DRI docs. I noted that /dev/fb0 produced a black image when X is running. I am genuinely curious, do you think /dev/mem might include VRAM? (That would be awesome.) I don't have an Nvidia GPU. – i336_ Feb 12 at 22:48
  • @jc__: Genuinely appreciate the assistance – i336_ Feb 12 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.