alexfru wrote:
This instruction does not distinguish between user and kernel pages. So, a misbehaving app would cause unnecessary memory reads (to refill the TLB) and introduce delays, which may be especially bad in the kernel and device drivers. And if some page tables that are needed to refill the TLB happen to be swapped out, this will incur additional disk reads and further increase delays. I'm not sure if there are other side effects.
I'd say that's a minor issue. It will only invalidate the cache, not the page tables themselves. Which entries are in the TLB is not really deterministic for the OS anyway. Any task switch might completely flush the TLB by changing CR3, and those are not really deterministic for a typical OS either. I'd say an OS that relies on certain TLB entries being cached is severely broken.
Still, I see no legitimate use for invlpg for a user program, but I cannot see how it can do much if any harm by using it either.