aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHelmut Eller2025-01-03 17:27:10 +0100
committerGerd Möllmann2025-01-08 04:19:19 +0100
commitf3ef8385dc5ebe4fa67967d02eade6f8c74872da (patch)
treecda4ac0e572586851b71667a19933f18f52b63a5 /src
parentcabe8da3b628f31aa1e0f7993cde941927ba0669 (diff)
downloademacs-f3ef8385dc5ebe4fa67967d02eade6f8c74872da.tar.gz
emacs-f3ef8385dc5ebe4fa67967d02eade6f8c74872da.zip
Delay processing of SIGPROF to the next safepoint
* src/lisp.h (process_pending_profiler_signals): New function. * src/profiler.c (pending_profiler_signals): New variable. (handle_profiler_signal): Instead of calling add_sample, set pending_signals and increment pending_profiler_signals. (process_pending_profiler_signals): New function. * src/keyboard.c (process_pending_signals): Call process_pending_profiler_signals.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c1
-rw-r--r--src/lisp.h1
-rw-r--r--src/profiler.c17
3 files changed, 18 insertions, 1 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 94337d2ba8c..67a7f129a51 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8190,6 +8190,7 @@ process_pending_signals (void)
8190 handle_async_input (); 8190 handle_async_input ();
8191 do_pending_atimers (); 8191 do_pending_atimers ();
8192 do_async_work (); 8192 do_async_work ();
8193 process_pending_profiler_signals ();
8193} 8194}
8194 8195
8195/* Undo any number of BLOCK_INPUT calls down to level LEVEL, 8196/* Undo any number of BLOCK_INPUT calls down to level LEVEL,
diff --git a/src/lisp.h b/src/lisp.h
index f8bf92d665c..0d9ed9b7495 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -5974,6 +5974,7 @@ extern bool profiler_memory_running;
5974extern void malloc_probe (size_t); 5974extern void malloc_probe (size_t);
5975extern void syms_of_profiler (void); 5975extern void syms_of_profiler (void);
5976extern void mark_profiler (void); 5976extern void mark_profiler (void);
5977extern void process_pending_profiler_signals (void);
5977 5978
5978 5979
5979#ifdef DOS_NT 5980#ifdef DOS_NT
diff --git a/src/profiler.c b/src/profiler.c
index 66a0e37f92e..f22a0352e73 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -387,6 +387,9 @@ static enum profiler_cpu_running
387/* Hash-table log of CPU profiler. */ 387/* Hash-table log of CPU profiler. */
388static struct profiler_log cpu; 388static struct profiler_log cpu;
389 389
390/* Number of unprocessed profiler signals. */
391static uintptr_t pending_profiler_signals;
392
390/* The current sampling interval in nanoseconds. */ 393/* The current sampling interval in nanoseconds. */
391static EMACS_INT current_sampling_interval; 394static EMACS_INT current_sampling_interval;
392 395
@@ -402,7 +405,19 @@ handle_profiler_signal (int signal)
402 count += overruns; 405 count += overruns;
403 } 406 }
404#endif 407#endif
405 add_sample (&cpu, count); 408 pending_signals = true;
409 pending_profiler_signals += count;
410}
411
412void
413process_pending_profiler_signals (void)
414{
415 uintptr_t count = pending_profiler_signals;
416 if (count)
417 {
418 pending_profiler_signals = 0;
419 add_sample (&cpu, count);
420 }
406} 421}
407 422
408static void 423static void