This kind of thing gets really complex really quickly. If you account for
cumulative memory usage (byte-seconds), it becomes pretty much impossible to do
efficiently, since any mapping or unmapping in the system can affect any other
process's effective memory usage. If you're talking about physical memory, then
it becomes more complex, because swapping 1 page can change an arbitary set of
process's effective memory usages. However, if you just charge a process for its
own virtual memory usage, it's much easier, since you only need to keep track of
its own changes in sbrk/mmap/etc.
Have a look at SHARE II at http://www.softway.com.au for a commercial product
which does a lot of per-user scheduling and resource accounting/control (yes, I
work there, I ported it to Irix, this is a plug). We've looked at trying to take
sharing into account when charging for memory usage, but haven't yet come up with
something which is sufficiently cheap. However, there hasn't been that much
demand for truly fair charging of memory; people are mostly interested in the
scheduler.
That would be an interesting 2.1 item: a properly designed interface to allow a
modular replacement of the scheduling policy. The current scheduler is good for
its expected workloads, but it would be nice to more easily experiment with
different policies.
J