tl; dr - memory pools and swapping are different concepts. You cannot draw any conclusions from one another.
kmalloc() and another kernel data distribution comes from slab / slub, etc. The same place that the kernel receives data for user space. Ergo pages often move between the kernel data segment and user space. It's right. He does not say anything about swapping. This is a separate issue, and you cannot deduce anything.
Kernel code is usually populated at boot time and is read-only and never changes after that. Ergo physical pages do not move between the kernel code segment and user space.
Why do you think that something comes from the same pool, is it the same? Network sockets also come from the same memory pool. This is a concern. Linux mm (memory management system) handles the swap. The page can be pinned (not exchangeable). Checking the kernel static memory (it can be .bss and .data) is a simple range check. Typically, memory is pinned and marked indispensable at the linux-mm level. User data (allocation of resources from the same pool) can be marked as replaceable linux-mm. For example, even without a swap, user space text is still available for replacement because it is supported by the index. Caching is much easier for read-only data. If data is exchanged, it is marked as such in the MMU tables, and the error handler must distinguish between swap and SIGBUS ; which is part of linux-mm.
There are also Linux versions with no-mm (or no MMU), and they never change. Theoretically, someone can exchange kernel data; but why is it in the core? The Linux path would be to use the module and load them as needed. Of course, linux-mm data is kernel data and hopefully you can see the problem of replacing this.
The problem with such conceptual questions,
- It may differ from Linux versions.
- It may differ from Linux configurations.
- Tip may change as Linux evolves.
Surely, linux-mm code cannot be replaced, nor an interrupt handler. It is possible that at some point in time, the kernel code and / or data may be replaced. I do not think that this is ever in the current case outside of the module loading / unloading (and it is rather pedantic / esoteric as to whether you call this replacement or not).
source share