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

Re: [Minios-devel] [UNIKRAFT PATCH v2] lib/nolibc: Fix remaining time in nanosleep



Hi Dafna,

I haven't looked into it more than seeing that the function is incomplete in newlib, but I would assume it's more or less the same patch, yes.

The patch should be submitted as unikraft newlib patch though, not to newlib upstream. The broken functionality is part of unikraft's glue code for newlib. (git://xenbits.xen.org/unikraft/libs/newlib.git:time.c)

Cheers,
Florian

On 09/11/2018 03:09 PM, Dafna Hirschfeld wrote:
Hi,
Yes, Ill have a look,
I should supply the same patch to the newlibc?

Dafna

On Tue, Sep 11, 2018 at 9:17 AM Florian Schmidt <Florian.Schmidt@xxxxxxxxx <mailto:Florian.Schmidt@xxxxxxxxx>> wrote:

    Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx
    <mailto:florian.schmidt@xxxxxxxxx>>

    Thank you for the patch! Do you want to look into the newlib glue code,
    as Costin mentioned? It's basically a very similar patch updating the
    glue function for nanosleep() there. Otherwise one of us will do it
    soon(tm).

    Cheers,
    Florian

    On 09/04/2018 10:36 PM, Dafna Hirschfeld wrote:
     > Calculate the remaining time to sleep and update
     > the rem parameter if it is given.
     > If the remaining time is larger than 0, it means that
     > the thread was waken up explicitly and nanosleep returns -1
     > to indicate that. Otherwise nanosleep returns 0
     >
     > Signed-off-by: Dafna Hirschfeld <dafna3@xxxxxxxxx
    <mailto:dafna3@xxxxxxxxx>>
     > ---
     >   lib/nolibc/time.c | 22 ++++++++++++++++++----
     >   1 file changed, 18 insertions(+), 4 deletions(-)
     >
     > diff --git a/lib/nolibc/time.c b/lib/nolibc/time.c
     > index 1c058ae..9e3e24e 100644
     > --- a/lib/nolibc/time.c
     > +++ b/lib/nolibc/time.c
     > @@ -59,9 +59,16 @@ static void __spin_wait(__nsec nsec)
     >
     >   int nanosleep(const struct timespec *req, struct timespec *rem)
     >   {
     > -     __nsec nsec = (__nsec) req->tv_sec * 1000000000L;
     > +     __nsec before, after, diff, nsec;
     >
     > +     if (!req || req->tv_nsec < 0 || req->tv_nsec > 999999999) {
     > +             errno = EINVAL;
     > +             return -1;
     > +     }
     > +
     > +     nsec = (__nsec) req->tv_sec * 1000000000L;
     >       nsec += req->tv_nsec;
     > +     before = ukplat_monotonic_clock();
     >
     >   #if CONFIG_HAVE_SCHED
     >       uk_sched_thread_sleep(nsec);
     > @@ -69,9 +76,16 @@ int nanosleep(const struct timespec *req,
    struct timespec *rem)
     >       __spin_wait(nsec);
     >   #endif
     >
     > -     if (rem) {
     > -             rem->tv_sec = 0;
     > -             rem->tv_nsec = 0;
     > +     after = ukplat_monotonic_clock();
     > +     diff = after - before;
     > +
     > +     if (diff < nsec) {
     > +             if (rem) {
     > +                     rem->tv_sec = ukarch_time_nsec_to_sec(nsec
    - diff);
     > +                     rem->tv_nsec = ukarch_time_subsec(nsec - diff);
     > +             }
     > +             errno = EINTR;
     > +             return -1;
     >       }
     >       return 0;
     >   }
     >

-- Dr. Florian Schmidt
    フローリアン・シュミット
    Research Scientist,
    Systems and Machine Learning Group
    NEC Laboratories Europe
    Kurfürsten-Anlage 36, D-69115 Heidelberg
    Tel.     +49 (0)6221 4342-265
    Fax:     +49 (0)6221 4342-155
    e-mail: florian.schmidt@xxxxxxxxx <mailto:florian.schmidt@xxxxxxxxx>
    ============================================================
    Registered at Amtsgericht Mannheim, Germany, HRB728558


--
Dr. Florian Schmidt
フローリアン・シュミット
Research Scientist,
Systems and Machine Learning Group
NEC Laboratories Europe
Kurfürsten-Anlage 36, D-69115 Heidelberg
Tel.     +49 (0)6221 4342-265
Fax:     +49 (0)6221 4342-155
e-mail:  florian.schmidt@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.