From nobody Mon Jul 01 22:28:55 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WCggY1HW6z5QJjZ; Mon, 01 Jul 2024 22:28:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WCggY0gRsz4B7m; Mon, 1 Jul 2024 22:28:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719872937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2pCBzZqoE4u/Xc1LHXn/z/hYpP0+QtQFd02iDzhX9A=; b=j8OVs/BDYOHLClnxRqjIylW0l4+Q8Llri2yVj2KxyI/oztk3D9IJ3dFH0RWermCz91oVpC yRnHlAt73OppG8+mpE7rOiw2RKvwOdSfyrXrBLRYtYeRVOgT9VckMtaxZnOM31erzc2Am0 S2hEWTgJpkwR48ObtufTul/acJ2q2ZTq9GFjOH0wMCJEOkEUpJGJ/fUqWWjCKpPD8VKFlU OiXePynd+PtqxRmwasQXsLsqHD3L510EIT2aqKnGY6qVPBeTtrgD0z7LH89+n6iliUxVuE vv+9rEoH5MkYR477KVF+HLXTYDJYuTFC849U0JkMYsVO7y+2fw+BA8Ct/XGJVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719872937; a=rsa-sha256; cv=none; b=TQIkfS6kdx9q1u6e7t7LKnwBOvMP341bVoWi+44Kqxe7u8PtR10eXGr4LBZTWS0wPX76bP mFO4D3p1Fca5zEe9xaVRZhgnIhMGFMXFg8lT58kFB1bgCTHkWZ3cAg6T5T9kB9iYb600Dx krdJmnH87NmG7McrehJ76wX+P+CyeQjWGv57JlGniD6K6u7Kn4YAqdk8vnauC2NHd2CZV8 tLRe+0JdW7/kZQXoE5hEMpyuMj25L9gJqU6tStvEzCtBEv8tSbL7QX3T0tL7e2knYnsghQ BBGK43XIVgPHWeH5R/Y4MhG+bjkUeGrstu84BRK/+IN2KS2cetMJtbV74qClQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719872937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2pCBzZqoE4u/Xc1LHXn/z/hYpP0+QtQFd02iDzhX9A=; b=RCDsDzi1uVYJOtBU6GXhp66obwUkSsuD14pzAEqHvzfHqWhaeDYarKpp4qMbRFFotZ0Vwb LPwFouOzbLTFf5a+eRbgHrJxvCB0Z1N0xQ65dCS/pVMbzFJs+EVa8+8tFf/ZJJG8pGwrJ0 ZEBTyGGucLlKBBFWla/8ofPho65DvPPRfQ/NoUsAny3ElxzFBPsSD4+BHumovhsMbUkSJ0 sp6021XxzZul6aBR3CECRj9AxjoAiRHM98sxA77I1ZkkKYrSIwtOIHsKJydNBz0xtqudOV 1UQdM56GKmOtOepGTpe+PIh0cWNJakmXjT7XcgxktTxf1o1UZf9PSGGpKK8U2Q== Received: from [IPV6:2601:5c0:4200:b830:198e:c253:cce:4f0] (unknown [IPv6:2601:5c0:4200:b830:198e:c253:cce:4f0]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4WCggX5XMzzYNh; Mon, 1 Jul 2024 22:28:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Mon, 1 Jul 2024 18:28:55 -0400 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: 7cae020b9c97 - main - Simplify signal handling code in libthr by removing use of SYS_sigreturn Content-Language: en-US To: Warner Losh , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202406062150.456LorpK058076@gitrepo.freebsd.org> From: John Baldwin Cc: Dapeng Gao In-Reply-To: <202406062150.456LorpK058076@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 6/6/24 2:50 PM, Warner Losh wrote: > The branch main has been updated by imp: > > URL: https://cgit.FreeBSD.org/src/commit/?id=7cae020b9c977c11881363d726b13d1cd2feec5e > > commit 7cae020b9c977c11881363d726b13d1cd2feec5e > Author: Dapeng Gao > AuthorDate: 2024-06-03 18:18:13 +0000 > Commit: Warner Losh > CommitDate: 2024-06-06 21:48:39 +0000 > > Simplify signal handling code in libthr by removing use of SYS_sigreturn > > The use of SYS_sigreturn is unnecessary here. > > If handle_signal is called when a signal is delivered, it can just > return normally back to sigcode which will call sigreturn anyway. > > In case handle_signal is called by check_deferred_signal, using > setcontext is better than SYS_sigreturn because that is the correct > system call to pair with the earlier getcontext. > > Reviewed by: imp, kib > Differential Revision: https://reviews.freebsd.org/D44893 > --- > lib/libthr/thread/thr_sig.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c > index ad291d106001..b953c430158c 100644 > --- a/lib/libthr/thread/thr_sig.c > +++ b/lib/libthr/thread/thr_sig.c > @@ -247,7 +247,6 @@ static void > handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp) > { > struct pthread *curthread = _get_curthread(); > - ucontext_t uc2; > __siginfohandler_t *sigfunc; > int cancel_point; > int cancel_async; > @@ -307,13 +306,11 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp) > curthread->cancel_point = cancel_point; > curthread->cancel_enable = cancel_enable; > > - memcpy(&uc2, ucp, sizeof(uc2)); > - SIGDELSET(uc2.uc_sigmask, SIGCANCEL); > + SIGDELSET(ucp->uc_sigmask, SIGCANCEL); > > /* reschedule cancellation */ > - check_cancel(curthread, &uc2); > + check_cancel(curthread, ucp); > errno = err; > - syscall(SYS_sigreturn, &uc2); > } > > void > @@ -400,6 +397,7 @@ check_deferred_signal(struct pthread *curthread) > /* remove signal */ > curthread->deferred_siginfo.si_signo = 0; > handle_signal(&act, info.si_signo, &info, uc); > + syscall(SYS_sigreturn, uc); The commit log implies this should be calling setcontext() instead of syscall()? Was that a stale part of the commit log? I thought I remember discussing this at one point. Maybe the issue was that you couldn't pre-resolve the PLT for setcontext()? -- John Baldwin