Re: Interrupts vs signals
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Michael Paquier <michael@paquier.xyz>,
Robert Haas <robertmhaas@gmail.com>, Fujii Masao <masao.fujii@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>, Andres Freund <andres@anarazel.de>
Date: 2024-12-02T07:32:33Z
Lists: pgsql-hackers
On Sat, Nov 23, 2024 at 10:58 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote: > Hmm, so this would replace the maybeSleepingOnInterrupts bitmask I > envisioned. Makes a lot of sense. If it's a single bit though, that > means that you'll still get woken up by interrupts that you're not > waiting for. Maybe that's fine. Or we could merge the > maybeSleepingOnInterrupts and pendingInterrupts bitmasks to a single > atomic word, so that you would have a separate "maybe sleeping" bit for > each interrupt bit, but could still use atomic_fetch_or atomically read > the interrupt bits and announce the sleeping. I think one bit is fine for now. At least, until we have a serious problem with interrupts arriving when you're sleeping but not ready to service that particular interrupt. The 'interrupt bit already set, don't try to wake me' stuff discussed earlier would limit the number of useless wakeups to one, until you eventually are ready and consume the interrupt. The main case I can think of, if we fast forward to the all-procsignals-become-interrupts patch (which I'll be rebasing on top of this when the next version appears), is that you might receive a sinval catchup request, but you might be busy running a long query. Sinval catchup messages are only processed between queries, so you just keep ignoring them until end of query. I think that's fine, and unlikely. Do you have other cases in mind? If there is legitimate use case for a more fine-grained maybe-sleeping and I've been too optimistic above, I don't think we should give one whole maybe-sleeping bit to each interrupt reason. We only have 32 bit atomics (splinlock-based emulation of 64 bit atomics is not good enough for this, it's not safe in SIGALRM handlers, at least not without a lot more pain; admittedly the SIGALRM handlers should eventually be replaced but not for a while) so if we used up two bits for every interrupt reason we could handle only 16 interrupt reasons, and that's already not enough. Perhaps we could add maybe-sleeping bits for classes of interrupt if we ever determine that one bit for all of them isn't enough?
Commits
-
Ignore SIGINT in walwriter and walsummarizer
- a92b809f9da1 19 (unreleased) landed
-
Split WaitEventSet functions to separate source file
- 393e0d231405 18.0 landed
-
Use ModifyWaitEvent to update exit_on_postmaster_death
- 84e5b2f07a5e 18.0 landed
-
Remove unused ShutdownLatchSupport() function
- a98e4dee63ce 18.0 landed
-
Rename two functions that wake up other processes
- 368d8270c838 18.0 landed
-
Use ProcNumbers instead of direct Latch pointers to address other procs
- a9c546a5a378 18.0 landed
-
Clean up WaitLatch calls that passed latch without WL_LATCH_SET
- f9ecb57a506a 18.0 landed
-
Remove unneeded #include
- 094ae071605d 18.0 landed
-
Remove unused latch
- 6c0c49f7d37d 18.0 landed
-
Remove support for background workers without BGWORKER_SHMEM_ACCESS.
- 80a8f95b3bca 15.0 cited