lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <893e8ed21e544d048bff7933013332a0@AcuMS.aculab.com>
Date:   Wed, 18 Nov 2020 15:59:32 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Arnd Bergmann' <arnd@...nel.org>,
        Willem de Bruijn <willemdebruijn.kernel@...il.com>
CC:     Matthew Wilcox <willy@...radead.org>,
        Linux FS-devel Mailing List <linux-fsdevel@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Al Viro <viro@...iv.linux.org.uk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Soheil Hassas Yeganeh <soheil.kdev@...il.com>,
        Arnd Bergmann <arnd@...db.de>, Shuo Chen <shuochen@...gle.com>,
        linux-man <linux-man@...r.kernel.org>
Subject: RE: [PATCH v3 1/2] epoll: add nsec timeout support with epoll_pwait2

From: Arnd Bergmann
> Sent: 18 November 2020 15:38
> 
> On Wed, Nov 18, 2020 at 4:10 PM Willem de Bruijn
> <willemdebruijn.kernel@...il.com> wrote:
> > On Wed, Nov 18, 2020 at 10:00 AM Matthew Wilcox <willy@...radead.org> wrote:
> > >
> > > On Wed, Nov 18, 2020 at 09:46:15AM -0500, Willem de Bruijn wrote:
> > > > -static inline struct timespec64 ep_set_mstimeout(long ms)
> > > > +static inline struct timespec64 ep_set_nstimeout(s64 timeout)
> > > >  {
> > > > -     struct timespec64 now, ts = {
> > > > -             .tv_sec = ms / MSEC_PER_SEC,
> > > > -             .tv_nsec = NSEC_PER_MSEC * (ms % MSEC_PER_SEC),
> > > > -     };
> > > > +     struct timespec64 now, ts;
> > > >
> > > > +     ts = ns_to_timespec64(timeout);
> > > >       ktime_get_ts64(&now);
> > > >       return timespec64_add_safe(now, ts);
> > > >  }
> > >
> > > Why do you pass around an s64 for timeout, converting it to and from
> > > a timespec64 instead of passing around a timespec64?
> >
> > I implemented both approaches. The alternative was no simpler.
> > Conversion in existing epoll_wait, epoll_pwait and epoll_pwait
> > (compat) becomes a bit more complex and adds a stack variable there if
> > passing the timespec64 by reference. And in ep_poll the ternary
> > timeout test > 0, 0, < 0 now requires checking both tv_secs and
> > tv_nsecs. Based on that, I found this simpler. But no strong
> > preference.
> 
> The 64-bit division can be fairly expensive on 32-bit architectures,
> at least when it doesn't get optimized into a multiply+shift.

I'd have thought you'd want to do everything in 64bit nanosecs.
Conversions to/from any of the 'timespec' structure are expensive.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ