From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9278 Path: news.gmane.org!not-for-mail From: Justin Cormack Newsgroups: gmane.linux.lib.musl.general Subject: Re: setcontext/getcontext/makecontext missing? Date: Sat, 6 Feb 2016 21:20:49 -0800 Message-ID: References: <87199830-7260-4E33-B3A6-BE15AF610BCE@akamai.com> <20160204145409.GB9915@port70.net> <20160204154137.GN9349@brightrain.aerifal.cx> <20160204162246.GF25193@example.net> <20160204192403.GR9349@brightrain.aerifal.cx> <20160205095835.GH25193@example.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114b305453369d052b273fc2 X-Trace: ger.gmane.org 1454822466 17711 80.91.229.3 (7 Feb 2016 05:21:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Feb 2016 05:21:06 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9291-gllmg-musl=m.gmane.org@lists.openwall.com Sun Feb 07 06:21:05 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aSHmT-0004O0-4V for gllmg-musl@m.gmane.org; Sun, 07 Feb 2016 06:21:05 +0100 Original-Received: (qmail 32253 invoked by uid 550); 7 Feb 2016 05:21:01 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 32235 invoked from network); 7 Feb 2016 05:21:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=specialbusservice.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=yyJAvrmk/TMuVJH6QyV75AO5fV8T1SK/KkuzkEYJ0VM=; b=UKLOGq6uAIyCeFtJ8WWaXNj/GIPPOXPcu9/JMqy6125RnQFPyH3j4MrakpHwC3Kw/M ULbm1W6wFFVJjMXui1Y8HN3eSoaV8S7TVpuTaTDXYd9h6Qie1QP7/yKvji8TWAuoT7VQ Z2nLnOMJ1UdiQHd5Ctqhrt1epFSeQaXMVClJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=yyJAvrmk/TMuVJH6QyV75AO5fV8T1SK/KkuzkEYJ0VM=; b=iRFGf6708EnPHgm1N/Ml/coCcvvXosrOg5bVit0D+YZlJu7PoyVrBCRtpc/p4vrZfD w8xYKh1WsPWPhe5w0+6lxFZQr6CIKGqNQ+CdjyqQ6lHOrcpnkOidlTQRkrsaWn4zQISg krW8nzHSBEJJEx6lOM8QGrIIjgNYlIIfOWQgN/QaePiUyF3RWuoT6rGeEDrzqoDSqPEk xz6Tr9c0+O9fNXj/oFYHxbS0+wI9rBnsKAenIrtDiociy/0nV/fOZ1fNHfTTf2qNE5hr zHwj+bv9LZ4RbgVfvwzwVLkyfDC65uHNkGJDmodWH3rXmQC5g3Sa61jnrwkssN6nyO1F 3V6w== X-Gm-Message-State: AG10YOT8rXq4fzyOnaDjwuEA5nh7jzNultYq8aLxA41elOo0NkyFkRYtgGaBIcWE1BLClIzy4qUkWULAs3g17Q== X-Received: by 10.28.220.134 with SMTP id t128mr12193071wmg.61.1454822449683; Sat, 06 Feb 2016 21:20:49 -0800 (PST) In-Reply-To: <20160205095835.GH25193@example.net> Xref: news.gmane.org gmane.linux.lib.musl.general:9278 Archived-At: --001a114b305453369d052b273fc2 Content-Type: text/plain; charset=UTF-8 On 5 Feb 2016 1:59 am, wrote: > > On Thu, Feb 04, 2016 at 02:24:03PM -0500, Rich Felker wrote: > > > Pthreads feels like an overkill, hardly efficient when all one needs > > > is cooperative threading designed from the beginning to fit in one > > > process. > > > the comparison is not between pure-userspace switching and having the > > kernel involved, but between a SYS_rt_sigprocmask syscall and a > > voluntary context switch between threads in the same process. The > > latter is extremely light and comparable to some of the cheapest > > syscalls, so I suspect the performance difference between ucontext and > > threads is negligible. > > Thanks for pointing this out, if rt_sigprocmask can not be skipped > then indeed a switch becomes much more expensive. Many users of this interface do not actually require this. Actually NetBSD makes the context functions syscalls themselves. And OpenBSD does not provide them at all. I have taken to just including implementations (without the signal calls) in code that needs to use them, with modifications to fix the prototype issues as most code only needs to pass a single argument. At one point I was going to do implementations for Musl but I think it is a bad idea. > > Given that there are a lot of other good > > reasons you should be using threads instead of ucontext, I think the > > matter is pretty clear. > > Sure, the API was not exactly well thought-out. > Still I'd like to have a lighweight choice when it is enough. > This is of course offtopic for musl, given that there is no reasonable > standard/specification for the purpose. > > Regards, > Rune > --001a114b305453369d052b273fc2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On 5 Feb 2016 1:59 am, <u-uy74@aetey.= se> wrote:
>
> On Thu, Feb 04, 2016 at 02:24:03PM -0500, Rich Felker wrote:
> > > Pthreads feels like an overkill, hardly efficient when all o= ne needs
> > > is cooperative threading designed from the beginning to fit = in one
> > > process.
>
> > the comparison is not between pure-userspace switching and having= the
> > kernel involved, but between a SYS_rt_sigprocmask syscall and a > > voluntary context switch between threads in the same process. The=
> > latter is extremely light and comparable to some of the cheapest<= br> > > syscalls, so I suspect the performance difference between ucontex= t and
> > threads is negligible.
>
> Thanks for pointing this out, if rt_sigprocmask can not be skipped
> then indeed a switch becomes much more expensive.

Many users of this interface do not actually require this. A= ctually NetBSD makes the context functions syscalls themselves. And OpenBSD= does not provide them at all.

I have taken to just including implementations (without the = signal calls) in code that needs to use them, with modifications to fix the= prototype issues as most code only needs to pass a single argument. At one= point I was going to do implementations for Musl but I think it is a bad i= dea.

> > Given that there are a lot of other good
> > reasons you should be using threads instead of ucontext, I think = the
> > matter is pretty clear.
>
> Sure, the API was not exactly well thought-out.
> Still I'd like to have a lighweight choice when it is enough.
> This is of course offtopic for musl, given that there is no reasonable=
> standard/specification for the purpose.
>
> Regards,
> Rune
>

--001a114b305453369d052b273fc2--