That works and is the simple solution, but then you would essentially have
a _separate_ swap area for anonymous maps. That may be good enough, and
it's certainly the simple solution.
The traditional UNIX solution as far as I know is to have the anonymous
mappings be backed in the general swapfile, and then the problem is one of
trying to keep track of which entries are used for shared anonymous pages
and which are used for private anonymous pages (and giving a number to the
shared anonymous ones).
Having a separate swap area for shared anonymous pages would certainly
make sense, and would get rid of all the problems, but would require the
machine to be set up correctly that way by somebody (essentially it turns
the anonymous shared mappings to a real shared mapping of a special
"magic" object - which can be either a real file or a partition or
something, but the point is that the "something" will have to be set up by
the maintainer of the machine rather than being the global swap device).
Would that be acceptable to people?
Linus