unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet via "Emacs development discussions." <emacs-devel@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gerd.moellmann@gmail.com, ofv@wanadoo.es, emacs-devel@gnu.org,
	eller.helmut@gmail.com, acorallo@gnu.org
Subject: Re: Some experience with the igc branch
Date: Sat, 28 Dec 2024 21:05:43 +0000	[thread overview]
Message-ID: <871pxrecy7.fsf@protonmail.com> (raw)
In-Reply-To: <865xn3sn2e.fsf@gnu.org>

"Eli Zaretskii" <eliz@gnu.org> writes:

>> Date: Fri, 27 Dec 2024 16:42:48 +0000
>> From: Pip Cet <pipcet@protonmail.com>
>> Cc: gerd.moellmann@gmail.com, ofv@wanadoo.es, emacs-devel@gnu.org, eller.helmut@gmail.com, acorallo@gnu.org
>>
>> "Eli Zaretskii" <eliz@gnu.org> writes:
>>
>> >> All redirected MPS calls wait synchronously for the allocation thread to
>> >> respond.
>> >>
>> >> This includes the MPS SIGSEGV handler, which calls into MPS, so it must
>> >> be directed to another thread.
>> >
>> > MPS SIGSEGV handler is invoked when the Lisp machine touches objects
>> > which were relocated by MPS, right?
>> > What exactly does the allocation thread do when that happens?
>>
>> Attempt to trigger another fault at the same address, which calls into
>> MPS, which eventually does whatever is necessary to advance to a state
>> where there is no longer a memory barrier.  Of course we could call the
>> MPS signal handler directly from the allocation thread rather than
>> triggering another fault.  (MPS allows for the possibility that the
>> memory barrier is no longer in place by the time the arena lock has been
>> acquired, and it has to, for multi-threaded operation.)
>>
>> What precisely MPS does is an implementation detail, and may be
>> complicated (the instruction emulation code which causes so much trouble
>> for weak objects, for example).
>>
>> I also think it's an implementation detail what MPS uses memory barriers
>> for: I don't think the current code uses superfluous memory barriers to
>> gather statistics, for example, but we certainly cannot assume that will
>> never happen.
>
> I think you lost me.  Let me try to explain what I was asking about.
>
> MPS SIGSEGV is triggered when the main thread touches memory that was
> relocated by MPS.

(well, the memory hasn't been relocated, it just contains invalid
pointers).

> With the current way we interface with MPS, where
> the main thread calls MPS directly, MPS sets up SIGSEGV to invoke its
> (MPS's) own handler, which then handles the memory access.

It removes the barrier and returns, making the main thread try again.

> By
> contrast, under your proposal, MPS should be called from a separate
> thread.  However, the way we currently process signals, the signals
> are delivered to the main thread.  So we should install our own
> SIGSEGV handler which will run in the context of the main thread, and
> should somehow redirect the handling of this SIGSEGV to the MPS
> thread, right?

Correct.

> So now the main thread calls pthread_kill to deliver
> the SIGSEGV to the MPS thread,

No, that wouldn't work.  We need the signal handler to have access to
the siginfo_t data, and pthread_kill provides no way to include that
information.

Instead, we call the SIGSEGV handler directly on the other thread,
passing in the same siginfo structure.

(My original code simply accessed a byte at the fault address; however,
reading the byte isn't sufficient, and writing it risks exposing
inadmissible intermediate states to other threads, so now we call the
sa_sigaction function directly).

> but what will the MPS thread do with that?

Call the MPS SIGSEGV handler, which knows what to do based (currently)
only on the address.

> how will it know which MPS function to call?

The MPS SIGSEGV handler is obtained by calling sigaction.

>> >> 3. we don't allocate memory
>> >
>> > Why can't GC happen when we don't allocate memory?
>> >
>> >> 4. we don't trigger memory barriers
>> >
>> > Same question here.
>>
>> I meant all four conditions are necessary, not that any one of thew
>> mould be sufficient.
>>
>> GC can happen if another thread triggers a memory barrier OR another
>> thread allocates OR we hit a memory barrier OR we allocate.  The
>> question is whether it is ever useful to assume that GC can happen ONLY
>> in these four cases.
>
> GC can also happen when Emacs is idle, and at that time there's no
> allocations.

If you want to spell it out, sure, but there's no way for the main
thread to become idle without potentially allocating memory, so this
fifth condition is redundant.

Pip




  reply	other threads:[~2024-12-28 21:05 UTC|newest]

Thread overview: 223+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-22 15:40 Some experience with the igc branch Óscar Fuentes
2024-12-22 17:18 ` Gerd Möllmann
2024-12-22 17:29 ` Gerd Möllmann
2024-12-22 17:41 ` Pip Cet via Emacs development discussions.
2024-12-22 17:56   ` Gerd Möllmann
2024-12-22 19:11   ` Óscar Fuentes
2024-12-23  0:05     ` Pip Cet via Emacs development discussions.
2024-12-23  1:00       ` Óscar Fuentes
2024-12-24 22:34         ` Pip Cet via Emacs development discussions.
2024-12-25  4:25           ` Freezing frame with igc Gerd Möllmann
2024-12-25 11:19             ` Pip Cet via Emacs development discussions.
2024-12-25 11:55             ` Óscar Fuentes
2024-12-23  3:42       ` Some experience with the igc branch Gerd Möllmann
2024-12-23  6:27     ` Jean Louis
2024-12-22 20:29   ` Helmut Eller
2024-12-22 20:50   ` Gerd Möllmann
2024-12-22 22:26     ` Pip Cet via Emacs development discussions.
2024-12-23  3:23       ` Gerd Möllmann
     [not found]         ` <m234ieddeu.fsf_-_@gmail.com>
     [not found]           ` <87ttaueqp9.fsf@protonmail.com>
     [not found]             ` <m2frme921u.fsf@gmail.com>
     [not found]               ` <87ldw6ejkv.fsf@protonmail.com>
     [not found]                 ` <m2bjx2h8dh.fsf@gmail.com>
2024-12-23 14:45                   ` Make Signal handling patch platform-dependent? Pip Cet via Emacs development discussions.
2024-12-23 14:54                     ` Gerd Möllmann
2024-12-23 15:11                       ` Eli Zaretskii
2024-12-23 13:35       ` Some experience with the igc branch Eli Zaretskii
2024-12-23 14:03         ` Discussion with MPS people Gerd Möllmann
2024-12-23 14:04           ` Gerd Möllmann
2024-12-23 15:07         ` Some experience with the igc branch Pip Cet via Emacs development discussions.
2024-12-23 15:26           ` Gerd Möllmann
2024-12-23 16:03             ` Pip Cet via Emacs development discussions.
2024-12-23 16:44               ` Eli Zaretskii
2024-12-23 17:16                 ` Pip Cet via Emacs development discussions.
2024-12-23 18:35                   ` Eli Zaretskii
2024-12-23 18:48                     ` Gerd Möllmann
2024-12-23 19:25                       ` Eli Zaretskii
2024-12-23 20:30                     ` Benjamin Riefenstahl
2024-12-23 23:39                       ` Pip Cet via Emacs development discussions.
2024-12-24 12:14                         ` Eli Zaretskii
2024-12-24 13:18                           ` Pip Cet via Emacs development discussions.
2024-12-24 13:42                           ` Benjamin Riefenstahl
2024-12-24  3:37                       ` Eli Zaretskii
2024-12-24  8:48                         ` Benjamin Riefenstahl
2024-12-24 13:52                           ` Eli Zaretskii
2024-12-24 13:54                             ` Benjamin Riefenstahl
2024-12-23 17:44               ` Gerd Möllmann
2024-12-23 19:00                 ` Eli Zaretskii
2024-12-23 19:37                   ` Eli Zaretskii
2024-12-23 20:49                   ` Gerd Möllmann
2024-12-23 21:43                     ` Helmut Eller
2024-12-23 21:49                       ` Pip Cet via Emacs development discussions.
2024-12-23 21:58                         ` Helmut Eller
2024-12-23 23:20                           ` Pip Cet via Emacs development discussions.
2024-12-24  5:38                             ` Helmut Eller
2024-12-24  6:27                               ` Gerd Möllmann
2024-12-24 10:09                               ` Pip Cet via Emacs development discussions.
2024-12-24  4:05                       ` Gerd Möllmann
2024-12-24  8:50                         ` Gerd Möllmann
2024-12-24  6:03                     ` SIGPROF + SIGCHLD and igc Gerd Möllmann
2024-12-24  8:23                       ` Helmut Eller
2024-12-24  8:39                         ` Gerd Möllmann
2024-12-25  9:22                           ` Helmut Eller
2024-12-25  9:43                             ` Gerd Möllmann
2024-12-24 13:05                         ` Eli Zaretskii
2024-12-25 10:46                           ` Helmut Eller
2024-12-25 12:45                             ` Eli Zaretskii
2024-12-24 12:54                       ` Eli Zaretskii
2024-12-24 12:59                         ` Gerd Möllmann
2024-12-27  8:08                       ` Helmut Eller
2024-12-27  8:51                         ` Eli Zaretskii
2024-12-27 14:53                           ` Helmut Eller
2024-12-27 15:09                             ` Pip Cet via Emacs development discussions.
2024-12-27 15:19                             ` Eli Zaretskii
2024-12-29 18:50                           ` Helmut Eller
2024-12-29 19:05                             ` Eli Zaretskii
2024-12-29 19:34                               ` Helmut Eller
2024-12-29 20:08                                 ` Eli Zaretskii
2024-12-29 20:50                                   ` Helmut Eller
2024-12-27  8:55                         ` Gerd Möllmann
2024-12-27 15:40                           ` Helmut Eller
2024-12-27 15:53                             ` Gerd Möllmann
2024-12-27 11:36                         ` Pip Cet via Emacs development discussions.
2024-12-27 16:14                           ` Helmut Eller
2024-12-28 10:02                             ` Helmut Eller
2024-12-28 10:50                               ` Eli Zaretskii
2024-12-28 13:52                                 ` Helmut Eller
2024-12-28 14:25                                   ` Eli Zaretskii
2024-12-28 16:46                                     ` Helmut Eller
2024-12-28 17:35                                       ` Eli Zaretskii
2024-12-28 18:08                                         ` Helmut Eller
2024-12-28 19:00                                           ` Eli Zaretskii
2024-12-28 19:28                                             ` Helmut Eller
2024-12-28 19:32                                       ` Pip Cet via Emacs development discussions.
2024-12-28 19:51                                         ` Helmut Eller
2024-12-28 20:43                                           ` Pip Cet via Emacs development discussions.
2024-12-29  5:44                                             ` Eli Zaretskii
2024-12-29 12:15                                               ` Pip Cet via Emacs development discussions.
2024-12-29 20:44                                               ` Pip Cet via Emacs development discussions.
2024-12-30 15:03                                                 ` Eli Zaretskii
2024-12-30 16:46                                                   ` Pip Cet via Emacs development discussions.
2024-12-30 17:47                                                     ` Eli Zaretskii
2024-12-30 17:53                                                       ` Daniel Colascione
2024-12-30 18:25                                                         ` Eli Zaretskii
2024-12-23 23:37                   ` Some experience with the igc branch Pip Cet via Emacs development discussions.
2024-12-24  4:03                     ` Gerd Möllmann
2024-12-24 10:25                       ` Pip Cet via Emacs development discussions.
2024-12-24 10:50                         ` Gerd Möllmann
2024-12-24 13:15                         ` Eli Zaretskii
2024-12-24 12:26                       ` Eli Zaretskii
2024-12-24 12:56                         ` Gerd Möllmann
2024-12-24 13:19                           ` Pip Cet via Emacs development discussions.
2024-12-24 13:38                             ` Gerd Möllmann
2024-12-24 13:46                           ` Eli Zaretskii
2024-12-24 14:12                             ` Gerd Möllmann
2024-12-24 14:40                               ` Eli Zaretskii
2024-12-25  4:56                                 ` Gerd Möllmann
2024-12-25 12:19                                   ` Eli Zaretskii
2024-12-25 12:50                                     ` Gerd Möllmann
2024-12-25 13:00                                       ` Eli Zaretskii
2024-12-25 13:08                                         ` Gerd Möllmann
2024-12-25 13:26                                           ` Eli Zaretskii
2024-12-25 14:07                                             ` Gerd Möllmann
2024-12-25 14:43                                               ` Helmut Eller
2024-12-25 14:59                                                 ` Eli Zaretskii
2024-12-25 20:44                                                   ` Helmut Eller
2024-12-26  6:29                                                     ` Eli Zaretskii
2024-12-26  8:02                                                       ` Helmut Eller
2024-12-26  9:32                                                         ` Eli Zaretskii
2024-12-26 12:24                                                           ` Helmut Eller
2024-12-26 15:23                                                             ` Eli Zaretskii
2024-12-26 23:29                                                               ` Paul Eggert
2024-12-27  7:57                                                                 ` Eli Zaretskii
2024-12-27 19:34                                                                   ` Paul Eggert
2024-12-28  8:06                                                                     ` Eli Zaretskii
2024-12-28 20:44                                                                       ` Paul Eggert
2024-12-29  5:47                                                                         ` Eli Zaretskii
2024-12-29 19:09                                                                           ` Paul Eggert
2024-12-29 19:20                                                                             ` Eli Zaretskii
2024-12-29 19:30                                                                               ` Paul Eggert
2024-12-29 20:01                                                                                 ` Eli Zaretskii
2024-12-30  7:55                                                                                   ` Paul Eggert
2024-12-25 15:02                                                 ` Gerd Möllmann
2024-12-25 13:09                                       ` Eli Zaretskii
2024-12-25 13:46                                         ` Gerd Möllmann
2024-12-25 14:37                                           ` Eli Zaretskii
2024-12-25 14:57                                             ` Gerd Möllmann
2024-12-25 15:28                                               ` Eli Zaretskii
2024-12-25 15:49                                                 ` Gerd Möllmann
2024-12-25 17:26                                                   ` Eli Zaretskii
2024-12-26  5:25                                                     ` Gerd Möllmann
2024-12-26  7:43                                                       ` Eli Zaretskii
2024-12-26  7:57                                                         ` Gerd Möllmann
2024-12-26 11:56                                                           ` Eli Zaretskii
2024-12-26 15:27                                                           ` Stefan Kangas
2024-12-26 19:51                                                             ` Gerd Möllmann
2024-12-27  9:45                                                               ` Gerd Möllmann
2024-12-27 13:56                                                                 ` Gerd Möllmann
2024-12-27 15:01                                                                   ` Pip Cet via Emacs development discussions.
2024-12-27 15:28                                                                     ` Eli Zaretskii
2024-12-27 15:47                                                                       ` Pip Cet via Emacs development discussions.
2024-12-27 16:18                                                                       ` Gerd Möllmann
2024-12-28  9:10                                                                         ` Stefan Kangas
2024-12-28  9:20                                                                           ` Gerd Möllmann
2024-12-28  9:24                                                                             ` Gerd Möllmann
2024-12-27 16:05                                                                     ` Gerd Möllmann
2024-12-27 17:00                                                                       ` Pip Cet via Emacs development discussions.
2024-12-27 16:37                                                                   ` Eli Zaretskii
2024-12-27 17:26                                                                     ` Pip Cet via Emacs development discussions.
2024-12-27 19:12                                                                       ` Gerd Möllmann
2024-12-28  7:36                                                                       ` Eli Zaretskii
2024-12-28 12:35                                                                         ` Pip Cet via Emacs development discussions.
2024-12-28 12:51                                                                           ` Gerd Möllmann
2024-12-28 13:13                                                                           ` Eli Zaretskii
2024-12-28  9:29                                                                       ` Eli Zaretskii
2024-12-28 13:12                                                                         ` Pip Cet via Emacs development discussions.
2024-12-28 14:08                                                                           ` Eli Zaretskii
2024-12-27 18:21                                                                     ` Gerd Möllmann
2024-12-27 19:23                                                                       ` Pip Cet via Emacs development discussions.
2024-12-27 20:28                                                                         ` Gerd Möllmann
2024-12-28 10:39                                                                       ` Eli Zaretskii
2024-12-28 11:07                                                                         ` Gerd Möllmann
2024-12-28 11:23                                                                           ` Gerd Möllmann
2024-12-28 14:04                                                                           ` Pip Cet via Emacs development discussions.
2024-12-28 14:25                                                                             ` Gerd Möllmann
2024-12-28 16:27                                                                             ` Eli Zaretskii
2024-12-28  6:08                                                                     ` Gerd Möllmann
2024-12-25 17:40                                       ` Pip Cet via Emacs development discussions.
2024-12-25 17:51                                         ` Eli Zaretskii
2024-12-26 15:24                                           ` Pip Cet via Emacs development discussions.
2024-12-26 15:57                                             ` Eli Zaretskii
2024-12-27 14:34                                               ` Pip Cet via Emacs development discussions.
2024-12-27 15:58                                                 ` Eli Zaretskii
2024-12-27 16:42                                                   ` Pip Cet via Emacs development discussions.
2024-12-28 18:02                                                     ` Eli Zaretskii
2024-12-28 21:05                                                       ` Pip Cet via Emacs development discussions. [this message]
2024-12-29  6:15                                                         ` Eli Zaretskii
2024-12-29 12:39                                                           ` Pip Cet via Emacs development discussions.
2024-12-29 13:52                                                             ` Eli Zaretskii
2024-12-29 17:14                                                               ` Pip Cet via Emacs development discussions.
2024-12-26  5:27                                         ` Gerd Möllmann
2024-12-26  5:29                                         ` Gerd Möllmann
2024-12-24 21:18                               ` Pip Cet via Emacs development discussions.
2024-12-25  5:23                                 ` Gerd Möllmann
2024-12-25 10:48                                   ` Pip Cet via Emacs development discussions.
2024-12-25 13:40                                     ` Stefan Kangas
2024-12-25 17:03                                       ` Pip Cet via Emacs development discussions.
2024-12-26  5:22                                         ` Gerd Möllmann
2024-12-26  7:33                                           ` Eli Zaretskii
2024-12-26  8:02                                             ` Gerd Möllmann
2024-12-26 15:50                                             ` Stefan Kangas
2024-12-26 16:13                                               ` Eli Zaretskii
2024-12-26 19:40                                                 ` Gerd Möllmann
2024-12-26 17:01                                               ` Pip Cet via Emacs development discussions.
2024-12-26 19:45                                                 ` Gerd Möllmann
2024-12-26 20:05                                                   ` Eli Zaretskii
2024-12-26 20:12                                                     ` Gerd Möllmann
2024-12-26 16:12                                         ` Stefan Kangas
2024-12-26 17:05                                           ` Eli Zaretskii
2024-12-25 11:48                                   ` Helmut Eller
2024-12-25 11:58                                     ` Gerd Möllmann
2024-12-25 12:52                                     ` Eli Zaretskii
2024-12-25 12:31                                   ` Eli Zaretskii
2024-12-25 12:54                                     ` Gerd Möllmann
2024-12-24 12:11                     ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2024-12-27  9:49 Sean Devlin
2024-12-27 12:34 ` Eli Zaretskii
2024-12-28  1:55   ` Sean Devlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871pxrecy7.fsf@protonmail.com \
    --to=emacs-devel@gnu.org \
    --cc=acorallo@gnu.org \
    --cc=eliz@gnu.org \
    --cc=eller.helmut@gmail.com \
    --cc=gerd.moellmann@gmail.com \
    --cc=ofv@wanadoo.es \
    --cc=pipcet@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).