+/* madvise provides a way to tell the kernel in case a buffers contents
- can be discarded under memory pressure, which is useful for userspace
- bo cache where we want to optimistically hold on to buffer allocate
- and potential mmap, but allow the pages to be discarded under memory
- pressure.
- Typical usage would involve madvise(DONTNEED) when buffer enters BO
- cache, and madvise(WILLNEED) if trying to recycle buffer from BO cache.
- In the WILLNEED case, 'retained' indicates to userspace whether the
- backing pages still exist.
- */
+#define PANFROST_MADV_WILLNEED 0 /* backing pages are needed, status returned in 'retained' */ +#define PANFROST_MADV_DONTNEED 1 /* backing pages not needed */
+struct drm_panfrost_madvise {
- __u32 handle; /* in, GEM handle */
- __u32 madv; /* in, PANFROST_MADV_x */
- __u32 retained; /* out, whether backing store still exists */
+};
Just to clarify about the `retained` flag: if userspace does a madvise(WILLNEED) and we find out that retained=0, what's supposed to happen?
Should userspace evict the BO from its local cache and allocate one fresh? Or just remmap? Or something else?