Skip to contentSkip to conversation

Add LD_NUMA_REPLICATION for glibc

PATCH Huang Shijie 2 participants 3 messages Sep 3, 2021 – Sep 6, 2021 2 messages not in the archive Memory management

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 14 lines · Florian Weimer

* Huang Shijie via Libc-alpha:

Quoted 12 lines

This patch adds LD_NUMA_REPLICATION which influences the linkage of shared libraries at run time.

If LD_NUMA_REPLICATION is set for program foo like this:
#LD_NUMA_REPLICATION=1 ./foo

At the time ld.so mmaps the shared libraries, it will uses

	mmap(, c->prot | PROT_WRITE, MAP_COPY | MAP_FILE | MAP_POPULATE,)

for them, and the mmap will trigger COW(copy on write) for the shared libraries at the NUMA node which the program foo runs. After the COW, the foo will have a copy of the shared library segment(mmap covered) which belong to the same NUMA node.

Quoted 5 lines
Quoted 2 lines

So when enable LD_NUMA_REPLICATION, it will consume more memory, but it will reduce the remote-access in NUMA.

I think the kernel could do this in a much better way, avoiding duplicating the pages within the same NUMA node.

I think maybe only the per-NUMA-node page cache can avoid it..

Quoted 4 lines

The other issue is the temporary RWX mapping, which does not interoperate well with some security hardening features.

Thanks for the feedback.
I CC more people who may have interesting about this.

Thanks
Huang Shijie

#3 lore raw
Quoted 34 lines

-----Original Message-----
From: Huang Shijie [mailto:[email protected]]
Sent: Saturday, September 4, 2021 3:16 AM
To: Florian Weimer <[email protected]>
Cc: Huang Shijie via Libc-alpha <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Song Bao Hua (Barry Song) <[email protected]>; [email protected]
Subject: Re: [PATCH] Add LD_NUMA_REPLICATION for glibc

Quoted 3 lines · Florian Weimer

* Huang Shijie via Libc-alpha:

Quoted 1 line

This patch adds LD_NUMA_REPLICATION which influences the linkage of shared

libraries at run time.

Quoted 11 lines
Quoted 11 lines

If LD_NUMA_REPLICATION is set for program foo like this:
#LD_NUMA_REPLICATION=1 ./foo

At the time ld.so mmaps the shared libraries, it will uses

	mmap(, c->prot | PROT_WRITE, MAP_COPY | MAP_FILE | MAP_POPULATE,)

for them, and the mmap will trigger COW(copy on write) for the shared libraries at the NUMA node which the program foo runs. After the COW, the foo will have a copy of the shared library segment(mmap covered) which belong to the same NUMA node.

Quoted 5 lines
Quoted 2 lines

So when enable LD_NUMA_REPLICATION, it will consume more memory, but it will reduce the remote-access in NUMA.

I think the kernel could do this in a much better way, avoiding duplicating the pages within the same NUMA node.

Quoted 9 lines

I think maybe only the per-NUMA-node page cache can avoid it..

Quoted 4 lines

The other issue is the temporary RWX mapping, which does not interoperate well with some security hardening features.

Thanks for the feedback.
I CC more people who may have interesting about this.

Hi Shijie,
Thanks!

Could we have some benchmark data for this patch? I assume it will benefit frontend-bound large workset which might face relatively more icache miss?

Quoted 3 lines

Thanks
Huang Shijie

Thanks
Barry

#4 lore raw

Hi Barry,

Quoted 3 lines · Song Bao Hua (Barry Song)

Could we have some benchmark data for this patch? I assume it will benefit frontend-bound large workset which might face relatively more icache miss?

I did not find a proper program for the benchmark test..

Thanks
Huang Shijie