Let's say, I run
diff -rq on two big directories. All their contents appears in the read cache, and inevitably washes anything else from the read cache. So, even if there is still a lot of free RAM, other processes that depend on I/O eventually start suffering from 12309-like symptoms.
Setting
ionice -c 3 on the diff process wouldn't help. It's possible to
lock required files in RAM, so they won't be washed off at all, but this is an opposite approach and requires lots of opt-in fine-tuning for real cases, instead of opt-out.
I'd like instead just to limit only such kind of processes intended to fulfill background tasks involving scanning the whole disk during other work. If not per process, can I at least put them in a cgroup, where the page cache usage is limited, so it wouldn't take up all of the free memory? Or, as a last resort, can read caching be switched off for a process completely (it doesn't make sense anyway, as everything is read sequentially and used only once)?