From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: SIGPROF + SIGCHLD and igc Date: Sun, 29 Dec 2024 21:50:43 +0100 Message-ID: <87seq69pss.fsf@gmail.com> References: <87o713wwsi.fsf@telefonica.net> <87ldw7fwet.fsf@protonmail.com> <87a5cnfj8t.fsf@protonmail.com> <86seqe4j4f.fsf@gnu.org> <87ttaucub8.fsf@protonmail.com> <87pllicrpi.fsf@protonmail.com> <864j2u442i.fsf@gnu.org> <87a5ch5z1b.fsf@gmail.com> <86y101wlsr.fsf@gnu.org> <87msgeb9y6.fsf@gmail.com> <86ttampax7.fsf@gnu.org> <87ed1qb7ws.fsf@gmail.com> <86msgep7zk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18396"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: gerd.moellmann@gmail.com, pipcet@protonmail.com, ofv@wanadoo.es, emacs-devel@gnu.org, acorallo@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 29 21:51:33 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tS0G3-0004eI-SY for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Dec 2024 21:51:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tS0FR-0004aB-Dc; Sun, 29 Dec 2024 15:50:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tS0FN-0004Zb-2m for emacs-devel@gnu.org; Sun, 29 Dec 2024 15:50:49 -0500 Original-Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tS0FL-0001XZ-E1; Sun, 29 Dec 2024 15:50:48 -0500 Original-Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5d3ecae02beso10475101a12.0; Sun, 29 Dec 2024 12:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735505445; x=1736110245; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=nkrFIHSylIqgwkvLNirAng4zCWWmsXRXwQWvxUzNitk=; b=QlYFrq0ByMdAvmMPjkKg9EPWZEojf1djheel76nqCn9wosGoel99/jDdmQA8ZiGyh/ kctFkyG0o+MZZFcDekIAtE9/IAucgv5/J/AZDSv17ilVao37MH173gAbg2zjP8q38obj nUvajNBISsN4Lsh84vi0VmNRHG8UFmK4q2urSNglOrqK4bsrPWX9Im3zOs2FqiJgwEkk EAKkVyTqyJ5YQH810PWCtxQme21YSNhUItMdwG3O5TJcfbzEbBh44RYUPou+iO393A2c U/9gAcaqpnIplrZXCRzFW1lAwWa3DKg7vV5+T5uxv3/7UDA5ltqVUkPCaSqlv51txanh DUwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735505445; x=1736110245; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nkrFIHSylIqgwkvLNirAng4zCWWmsXRXwQWvxUzNitk=; b=UsGGFB0lsRz0rTUSqlrSpGtK7PiQLzG9awCuiNyyISb1+j6sgFeVKyJJcsZNkgEZeM 67QfcZoi5LS2+TOGtIeDp1knaJLFYtnwA+7VsmR3/oB3+exEJlG4d1l4RQ2PQfghY9nR idHX0FO9Tmlgt+WTcyC5meyoY41i8EOawPiWbWmQUut08OxOZfVcGI+lkbgmOhyg/5zp f9MTDNxcfY7/GR5Yks988pxoXHB0O0UYb4DUL6Tm185hVA+hmsPCi9xPzhtOVPO0TpVq ABuLZBTSWZlz8n/8ApBE24MWtiaYSj7Av6Zys0G6jfjtk1DNKWOylEn/98nThGs8t+U/ V/OA== X-Forwarded-Encrypted: i=1; AJvYcCUSLqtL8aGNq6JQgk5WryWdIP3l3+JChzL2xSUilUXggvIMUEi5tXoE2G0OySmxGzMIuAsAz8i4cw==@gnu.org, AJvYcCWX7Q5boI5ZMTXXWdBgk+oNJXMZVkIAz1ndCVwtgsp4no6Ni8886UQ8dW2mNXgoKu6s0/hcIjvT/jdC+d0=@gnu.org X-Gm-Message-State: AOJu0YwntJ88DtXcPodD4FE690rh/e2kA0YW1Fhl/NRET07EST8mWJAZ t/qdEBZQED7TG6v0Ck1dl0/2HHGr0EZjAFC8u4LiAVpoTtanelRgN/Kya3dm X-Gm-Gg: ASbGncu8ff9FDuImcrlYj/j62i2sfpO9LMKL47fYO14hCOOCf40+0TUlmaMZvhQ1ZM1 +i3zjP4bMpWT7RWWOd6hqB7Sbi/7s4Opfr/JwSRa57//Yf2lZsDxmyCRc6qn4AaxjMml5B1P6Cg mUiilGacBIUCSmye7P7Q2KD8GD1x9GBhJftfDyiCcRX9AFEfKnPkRXSwmCFuzs1K7xhsR+dda0v iCEM9Yy7+PbybNR7wtim0olMbsgMJtaCNJUXDc0RoRpFojghJbValY= X-Google-Smtp-Source: AGHT+IFThmI2ouXzFB9UT3Yt/VmcIrqMxwhFNi9KOrBPsy8o8uujZTdKTra1swFk43N+2PiHq+nF3Q== X-Received: by 2002:a05:6402:4402:b0:5cf:e9d6:cc8a with SMTP id 4fb4d7f45d1cf-5d81dda9256mr30071653a12.20.1735505444940; Sun, 29 Dec 2024 12:50:44 -0800 (PST) Original-Received: from caladan ([31.177.115.143]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80678c8dbsm13745253a12.40.2024.12.29.12.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 12:50:44 -0800 (PST) In-Reply-To: <86msgep7zk.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 29 Dec 2024 22:08:47 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=eller.helmut@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:327373 Archived-At: On Sun, Dec 29 2024, Eli Zaretskii wrote: 1>> From: Helmut Eller >> Cc: gerd.moellmann@gmail.com, pipcet@protonmail.com, ofv@wanadoo.es, >> emacs-devel@gnu.org, acorallo@gnu.org >> Date: Sun, 29 Dec 2024 20:34:11 +0100 >> >> On Sun, Dec 29 2024, Eli Zaretskii wrote: >> >> >> Here another observation: Let's assume that we can emulate SuspendThread >> >> and ResumeThread on POSIX and MacOS (much like MPS does it). In the >> >> profiler thread we can then simply do: >> >> >> >> SuspendThread () >> >> get_backtrace () >> >> ResumeThread () >> >> >> >> without invoking any SIGPROF handler or the need for >> >> ArenaEnter/ArenaLeave. >> > >> > Yes, we can. But that means changing what the SIGPROF handler does >> > will have no effect, which is bad for maintenance. By contrast, the >> > current MS-Windows implementation does basically the same, but it >> > calls the handler, not its body. >> > >> > Also, I don't quite see why you thing calling get_backtrace directly >> > will have any effect on the need to lock the arena. I'm probably >> > missing something. >> >> Ok. The arena lock is a problem. Is that also a problem for the Windows >> implementation? How does it avoid deadlocks when the thread holds the >> arena lock? > > You mean, when the SIGPROF handler is called by the thread which > simulates the SIGPROF signal? Yes. > The handler is called in the context of > the signaling thread, not in the context of the (suspended) Lisp > thread. I thought the possibility that the suspended Lisp thread holds the arena requires extra care on Windows. But I realize now, that that would be a problem even if the handler is executed in the context of the Lisp thread (as on POSIX). So there is no extra problem on Windows. >> >> The only complication seems to be, that we must avoid deadlocks when MPS >> >> tries to suspend a thread is already suspended by our emulation. >> > >> > If MPS always runs from the main thread, it doesn't (and cannot) >> > suspend the thread. Or maybe I misunderstand which thread do you mean >> > here? >> >> I may interpret "MPS runs in a thread" differently than you do. Maybe I >> should say a "thread is inside MPS" whenever a thread holds the arena >> lock. With this meaning, every thread can be inside MPS. > > Suspending a suspended thread on Windows doesn't cause any problems > (unless you do that more than 127 times without resuming the thread), > it just increments the thread's suspend count. To resume, you need to > call ResumeThread that many times. > > Does that answer your question? Yes. Helmut