Not as elegant as the userspace solution, but it’s a whole bunch faster.
One of the gotchas in the tarpit that is R*dh*t 8.0 is that when you've got 6000 processes and 12gb used, the fuser command tends to drag the machine down to hell because it has to open and read from approximately 30,000 files (at work, we use fuser to make sure people are logged off a port when a new telnet connection comes in on that port. And we use it several times) either because it takes too long or (more likely) because it has to allocate kernel memory approximately 60,000 times as part of figuring out who has what file.
I've put in a horrible hack:
This might not be quite as elegant as searching through 6000 subdirectories in /proc, then opening 3 or 4 files in each subdirectory, having the kernel convert binary data into ascii, then converting the ascii back to binary and then piecing it all together, but it has the tiny advantages of
- it doesn't try to allocate any pages, and
- it's about 1000 times as fast even when the system has enough free pages so that fuser doesn't cause a paging storm.
I'll just have to suffer the indignity of not following the conventional kernel hacking wisdom. All die. Oh the embarrassment.