Re: Interrupts vs signals
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Andres Freund <andres@anarazel.de>
Cc: Thomas Munro <thomas.munro@gmail.com>,
Michael Paquier <michael@paquier.xyz>, Robert Haas <robertmhaas@gmail.com>,
Fujii Masao <masao.fujii@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-06T14:30:37Z
Lists: pgsql-hackers
Attachments
- v12-0001-Refactor-how-some-aux-processes-advertise-their-.patch (text/x-patch) patch v12-0001
- v12-0002-Centralize-resetting-SIGCHLD-handler.patch (text/x-patch) patch v12-0002
- v12-0003-Replace-Latches-with-Interrupts.patch (text/x-patch) patch v12-0003
- v12-0004-Introduce-PendingInterrupts-with-separate-flags-.patch (text/x-patch) patch v12-0004
On 20/02/2026 16:22, Heikki Linnakangas wrote: > On 18/02/2026 02:11, Heikki Linnakangas wrote: >> On 14/02/2026 23:56, Andres Freund wrote: >>> Could we have the mask of interrupts that WaitInterrupt() is waiting >>> for in a >>> second variable? That way we could avoid interrupting WaitInterrupt() >>> when >>> raising or sending a signal that WaitInterrupt() is not waiting for. >>> I think >>> that can be one race-freely with a bit of care? >> >> Yeah, I thought of that, but I'm not sure what the right tradeoff here >> is. I doubt the spurious wakeups matter much in practice. Then again, >> maybe it's not much more complicated, so maybe I should try that. >> >> Now with this new version, the same consideration applies to the >> CFI_ATTENTION flag I added. We could expose a process's >> CheckForInterruptsMask alongside the pending interrupts, so it would >> be SendInterrupt()'s responsibility to check if the receiving >> backend's CheckForInterruptsMask includes the interrupt that's being >> sent. That would similarly eliminate the "false positive" >> ProcessInterrupts() calls from CHECK_FOR_INTERRUPTS(), by moving the >> logic to the senders. The SLEEPING_ON_INTERRUPTS and CFI_ATTENTION >> flags are quite symmetrical. > > I tried that approach, exposing an "attention bitmask" where a backend > advertises which interrupts it's currently interested in. I think I like > it. > > Patch attached. The relevant changes for this "attention mechanism" are > in the last patch, but there are some other small changes too so this > split into patches is a little messy. I moved the list of standard > interrupts to a separate header file, for example. So for reviewing, I > recommend reading the resulting interrupt.h and interrupt.c files after > applying all the patches, instead of trying to read the diff for those. Here's another rebase, no other changes. - Heikki
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