qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/1] util/oslib: Returns real thread identifier on FreeBSD an


From: Li-Wen Hsu
Subject: Re: [PATCH 1/1] util/oslib: Returns real thread identifier on FreeBSD and NetBSD
Date: Wed, 3 Jun 2020 23:07:05 +0800

Sorry that I am not familiar with this part so I asked others to help
review (the FreeBSD related code).  It's good and please append:

Reviewed-by: Edward Tomasz Napierala <trasz@FreeBSD.org>

Thanks!

On Wed, Jun 3, 2020 at 2:14 PM David CARLIER <devnexen@gmail.com> wrote:
>
> Sorry it landed in the spam.
>
> It does make things more accurate, thus a bit more than cosmetic, as
> stated in the commit message, thr_self/_lwp_self represents the
> current thread id in multi thread context.
>
> For OpenBSD it is syscall(SYS_getthrid) I believe
> https://man.openbsd.org/getthrid.2
>
> On Wed, 3 Jun 2020 at 06:12, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> >
> > ping?
> >
> > On 5/26/20 9:29 AM, David CARLIER wrote:
> > > From 792fbcd9114f43bd80fd1ef5b25cd9935a536f9f Mon Sep 17 00:00:00 2001
> > > From: David Carlier <devnexen@gmail.com>
> > > Date: Tue, 26 May 2020 08:25:26 +0100
> > > Subject: [PATCH] util/oslib: Returns the real thread identifier on 
> > > FreeBSD and
> > >  NetBSD
> > >
> > > getpid is good enough in a mono thread context, however
> > >  thr_self/_lwp_self reflects the real current thread identifier
> > >  from a given process.
> > > ---
> > >  util/oslib-posix.c | 9 +++++++++
> > >  1 file changed, 9 insertions(+)
> > >
> > > diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> > > index 062236a1ab..916f1be224 100644
> > > --- a/util/oslib-posix.c
> > > +++ b/util/oslib-posix.c
> > > @@ -48,11 +48,13 @@
> > >  #ifdef __FreeBSD__
> > >  #include <sys/sysctl.h>
> > >  #include <sys/user.h>
> > > +#include <sys/thr.h>
> > >  #include <libutil.h>
> > >  #endif
> > >
> > >  #ifdef __NetBSD__
> > >  #include <sys/sysctl.h>
> > > +#include <lwp.h>
> > >  #endif
> > >
> > >  #include "qemu/mmap-alloc.h"
> > > @@ -84,6 +86,13 @@ int qemu_get_thread_id(void)
> > >  {
> > >  #if defined(__linux__)
> > >      return syscall(SYS_gettid);
> > > +#elif defined(__FreeBSD__)
> > > +    /* thread id is up to INT_MAX */
> > > +    long tid;
> > > +    thr_self(&tid);
> > > +    return (int)tid;
> > > +#elif defined(__NetBSD__)
> > > +    return _lwp_self();
> > >  #else
> > >      return getpid();
> > >  #endif
> > >
> >



reply via email to

[Prev in Thread] Current Thread [Next in Thread]