Re: pgsql: Introduce pg_shmem_allocations_numa view

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Christoph Berg <myon(at)debian(dot)org>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Introduce pg_shmem_allocations_numa view
Date: 2025-06-24 20:32:25
Message-ID: b54df21b-6595-4031-baf8-7c87851794c8@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 6/24/25 17:30, Christoph Berg wrote:
> Re: Tomas Vondra
>> If it's a reliable fix, then I guess we can do it like this. But won't
>> that be a performance penalty on everyone? Or does the system split the
>> array into 16-element chunks anyway, so this makes no difference?
>
> There's still the overhead of the syscall itself. But no idea how
> costly it is to have this 16-step loop in user or kernel space.
>
> We could claim that on 32-bit systems, shared_buffers would be smaller
> anyway, so there the overhead isn't that big. And the step size should
> be larger (if at all) on 64-bit.
>
>> Anyway, maybe we should start by reporting this to the kernel people. Do
>> you want me to do that, or shall one of you take care of that? I suppose
>> that'd be better, as you already wrote a fix / know the code better.
>
> Submitted: https://marc.info/?l=linux-mm&m=175077821909222&w=2
>

Thanks! Now we wait ...

Attached is a minor tweak of the valgrind suppresion rules, to add the
two places touching the memory. I was hoping I could add a single rule
for pg_numa_touch_mem_if_required, but that does not work - it's a
macro, not a function. So I had to add one rule for both functions,
querying the NUMA. That's a bit disappointing, because it means it'll
hide all other failues (of Memcheck:Addr8 type) in those functions.

Perhaps it'd be be better to turn pg_numa_touch_mem_if_required into a
proper (inlined) function, at least with USE_VALGRIND defined. Something
like the v2 patch - needs more testing to ensure the inlined function
doesn't break the touching or something silly like that.

regards

--
Tomas Vondra

Attachment Content-Type Size
fix-valgrind-for-numa.patch text/x-patch 831 bytes
fix-valgrind-for-numa-v2.patch text/x-patch 1.4 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2025-06-25 00:00:59 pgsql: doc: Add secondary index entries for vacuum-related parameters.
Previous Message Christoph Berg 2025-06-24 18:24:22 Re: pgsql: Introduce pg_shmem_allocations_numa view

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-06-24 20:33:31 Re: like pg_shmem_allocations, but fine-grained for DSM registry ?
Previous Message Peter Eisentraut 2025-06-24 20:29:22 Re: [PATCH] Fix OAuth feature detection on OpenBSD+Meson