On 2023/3/17 5:43, Marco Elver wrote:
On Thu, 16 Mar 2023 at 16:10, Zhenhua Huang <quic_zhenhuah@xxxxxxxxxxx> wrote:
Kfence only needs its pool to be mapped as page granularity, if it is
inited early. Previous judgement was a bit over protected. From [1], Mark
suggested to "just map the KFENCE region a page granularity". So I
decouple it from judgement and do page granularity mapping for kfence
pool only. Need to be noticed that late init of kfence pool still requires
page granularity mapping.
Page granularity mapping in theory cost more(2M per 1GB) memory on arm64
platform. Like what I've tested on QEMU(emulated 1GB RAM) with
gki_defconfig, also turning off rodata protection:
Before:
[root@liebao ]# cat /proc/meminfo
MemTotal: 999484 kB
After:
[root@liebao ]# cat /proc/meminfo
MemTotal: 1001480 kB
To implement this, also relocate the kfence pool allocation before the
linear mapping setting up, arm64_kfence_alloc_pool is to allocate phys
addr, __kfence_pool is to be set after linear mapping set up.
LINK: [1] https://lore.kernel.org/linux-arm-kernel/Y+IsdrvDNILA59UN@FVFF77S0Q05N/
Suggested-by: Mark Rutland <mark.rutland@xxxxxxx>
Signed-off-by: Zhenhua Huang <quic_zhenhuah@xxxxxxxxxxx>
Reviewed-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
Reviewed-by: Marco Elver <elver@xxxxxxxxxx>
One question: what happens if the page-granular direct map is
requested either way, is there any downside with this patch? Does it
mean map_mem() just does a little extra work it shouldn't have? (Not
saying that's a problem, just trying to ask you to double-check it's
ok.)
Yeah.. I think so Marco. Seems the extra work in map_mem() is we did
judgement there.. Other side is we added one early param.
However, please also wait for an arm64 maintainer to have a look. I'm
assuming that because it touches mostly arm64 code, this patch ought
to go through the arm64 tree?
Yeah, sure. We will wait for arm64 maintainers' comments.
Thanks,
Zhenhua
Thanks,
-- Marco