mbox series

[00/16] syscalls: Use common variants structure

Message ID cover.1599545766.git.viresh.kumar@linaro.org
Headers show
Series syscalls: Use common variants structure | expand

Message

Viresh Kumar Sept. 8, 2020, 6:19 a.m. UTC
Hi Cyril,

As you suggested earlier, here is an attempt to use a common structure
prototype at most of the places.

futex, clock_adjtime() and clock_getres() tests are left with their own
implementations due to compatibility issues.

--
viresh

Viresh Kumar (16):
  syscalls: Add common time64 variants structure
  syscalls: clock_gettime: Reuse struct time64_variants
  syscalls: clock_nanosleep: Reuse struct time64_variants
  syscalls: clock_settime: Reuse struct time64_variants
  syscalls: io_pgetevents: Reuse struct time64_variants
  syscalls: semop: Reuse struct time64_variants
  syscalls: mq_timed: Reuse struct time64_variants
  syscalls: ppoll: Reuse struct time64_variants
  syscalls: rt_sigtimedwait: Reuse struct time64_variants
  syscalls: sched_rr_get_interval: Reuse struct time64_variants
  syscalls: sendmmsg: Reuse struct time64_variants
  syscalls: timer_settime: Reuse struct time64_variants
  syscalls: timer_gettime: Reuse struct time64_variants
  syscalls: timerfd: Reuse struct time64_variants
  syscalls: utimensat: Reuse struct time64_variants
  futex: Move variants struct definition to common header

 include/time64_variants.h                     | 56 +++++++++++++++++++
 .../syscalls/clock_gettime/clock_gettime01.c  | 19 +++----
 .../syscalls/clock_gettime/clock_gettime02.c  | 17 +++---
 .../syscalls/clock_gettime/clock_gettime03.c  | 27 ++++-----
 .../syscalls/clock_gettime/clock_gettime04.c  | 29 +++++-----
 .../clock_nanosleep/clock_nanosleep01.c       | 21 +++----
 .../clock_nanosleep/clock_nanosleep03.c       | 26 ++++-----
 .../clock_nanosleep/clock_nanosleep04.c       | 22 +++-----
 .../syscalls/clock_settime/clock_settime01.c  | 26 ++++-----
 .../syscalls/clock_settime/clock_settime02.c  | 20 +++----
 .../syscalls/clock_settime/clock_settime03.c  | 22 +++-----
 .../syscalls/futex/futex_cmp_requeue01.c      | 12 ++--
 .../syscalls/futex/futex_cmp_requeue02.c      |  9 +--
 .../kernel/syscalls/futex/futex_wait01.c      | 10 +---
 .../kernel/syscalls/futex/futex_wait02.c      | 11 ++--
 .../kernel/syscalls/futex/futex_wait03.c      | 11 ++--
 .../kernel/syscalls/futex/futex_wait04.c      | 10 +---
 .../syscalls/futex/futex_wait_bitset01.c      | 11 +---
 .../kernel/syscalls/futex/futex_wake01.c      |  9 +--
 .../kernel/syscalls/futex/futex_wake02.c      | 11 ++--
 .../kernel/syscalls/futex/futex_wake03.c      | 13 ++---
 .../kernel/syscalls/futex/futex_wake04.c      | 14 ++---
 testcases/kernel/syscalls/futex/futextest.h   |  7 +++
 .../syscalls/io_pgetevents/io_pgetevents01.c  | 16 ++----
 .../syscalls/io_pgetevents/io_pgetevents02.c  | 18 +++---
 testcases/kernel/syscalls/ipc/semop/semop.h   | 18 +++---
 testcases/kernel/syscalls/ipc/semop/semop01.c |  6 +-
 testcases/kernel/syscalls/ipc/semop/semop02.c |  6 +-
 testcases/kernel/syscalls/ipc/semop/semop03.c |  6 +-
 .../mq_timedreceive/mq_timedreceive01.c       | 14 ++---
 .../syscalls/mq_timedsend/mq_timedsend01.c    | 16 +++---
 testcases/kernel/syscalls/ppoll/ppoll01.c     | 21 +++----
 .../rt_sigtimedwait/rt_sigtimedwait01.c       | 15 ++---
 .../sched_rr_get_interval01.c                 | 21 +++----
 .../sched_rr_get_interval02.c                 | 21 +++----
 .../sched_rr_get_interval03.c                 | 21 +++----
 .../kernel/syscalls/sendmmsg/sendmmsg01.c     | 24 +++-----
 .../syscalls/timer_gettime/timer_gettime01.c  | 21 +++----
 .../syscalls/timer_settime/timer_settime01.c  | 25 ++++-----
 .../syscalls/timer_settime/timer_settime02.c  | 18 +++---
 testcases/kernel/syscalls/timerfd/timerfd01.c | 27 ++++-----
 testcases/kernel/syscalls/timerfd/timerfd04.c | 20 +++----
 .../syscalls/timerfd/timerfd_gettime01.c      |  8 +--
 .../syscalls/timerfd/timerfd_settime01.c      | 17 +++---
 .../syscalls/timerfd/timerfd_settime02.c      | 15 ++---
 testcases/kernel/syscalls/utils/mq_timed.h    | 18 ++----
 .../kernel/syscalls/utimensat/utimensat01.c   | 18 +++---
 47 files changed, 367 insertions(+), 456 deletions(-)
 create mode 100644 include/time64_variants.h

Comments

Petr Vorel Sept. 11, 2020, 9:53 a.m. UTC | #1
Hi Viresh,

> Hi Cyril,

> As you suggested earlier, here is an attempt to use a common structure
> prototype at most of the places.

> futex, clock_adjtime() and clock_getres() tests are left with their own
> implementations due to compatibility issues.

> Viresh Kumar (16):
>   syscalls: Add common time64 variants structure
>   syscalls: clock_gettime: Reuse struct time64_variants
>   syscalls: clock_nanosleep: Reuse struct time64_variants
>   syscalls: clock_settime: Reuse struct time64_variants
>   syscalls: io_pgetevents: Reuse struct time64_variants
>   syscalls: semop: Reuse struct time64_variants
>   syscalls: mq_timed: Reuse struct time64_variants
>   syscalls: ppoll: Reuse struct time64_variants
>   syscalls: rt_sigtimedwait: Reuse struct time64_variants
>   syscalls: sched_rr_get_interval: Reuse struct time64_variants
>   syscalls: sendmmsg: Reuse struct time64_variants
>   syscalls: timer_settime: Reuse struct time64_variants
>   syscalls: timer_gettime: Reuse struct time64_variants
>   syscalls: timerfd: Reuse struct time64_variants
>   syscalls: utimensat: Reuse struct time64_variants
>   futex: Move variants struct definition to common header
One of the commits fails on various tests [1].

Some failures (I haven't checked all):

* missing nfds_t (<poll.h> is probably from old commits) [2]:

CC testcases/kernel/syscalls/mq_open/mq_open01
In file included from ../../../../include/time64_variants.h:13,
                 from /usr/src/ltp/testcases/kernel/syscalls/mq_timedreceive/../utils/mq_timed.h:10,
                 from mq_timedreceive01.c:17:
/usr/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
    1 | #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
      |  ^~~~~~~
In file included from /usr/src/ltp/testcases/kernel/syscalls/mq_timedreceive/../utils/mq_timed.h:10,
                 from mq_timedreceive01.c:17:
../../../../include/time64_variants.h:41:35: error: unknown type name 'nfds_t'
41 |  int (*ppoll)(struct pollfd *fds, nfds_t nfds, void *tmo_p,

* <libaio.h> not found [3]:
BUILD libltpnewipc.a
make[6]: Nothing to be done for 'all'.
In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop02.c:29:
In file included from In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop01.c:15:
In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop.h:7:
/usr/src/ltp/include/time64_variants.h:10:10: fatal error: /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop.h'libaio.h' file not
      found
:7:
/usr/src/ltp/include/time64_variants.h:10:10: fatal error: 'libaio.h' file#include <libaio.h>
         ^~~~~~~~~~
 not
      found
#include <libaio.h>

[1] https://travis-ci.org/github/pevik/ltp/builds/726197434
[2] https://travis-ci.org/github/pevik/ltp/jobs/726197439#L5295
[3] https://travis-ci.org/github/pevik/ltp/jobs/726197440#L6649

Kind regards,
Petr
Viresh Kumar Sept. 11, 2020, 10:39 a.m. UTC | #2
On 11-09-20, 11:53, Petr Vorel wrote:
> Hi Viresh,
> One of the commits fails on various tests [1].
> 
> Some failures (I haven't checked all):
> 
> * missing nfds_t (<poll.h> is probably from old commits) [2]:
> 
> CC testcases/kernel/syscalls/mq_open/mq_open01
> In file included from ../../../../include/time64_variants.h:13,
>                  from /usr/src/ltp/testcases/kernel/syscalls/mq_timedreceive/../utils/mq_timed.h:10,
>                  from mq_timedreceive01.c:17:
> /usr/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
>     1 | #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
>       |  ^~~~~~~
> In file included from /usr/src/ltp/testcases/kernel/syscalls/mq_timedreceive/../utils/mq_timed.h:10,
>                  from mq_timedreceive01.c:17:
> ../../../../include/time64_variants.h:41:35: error: unknown type name 'nfds_t'
> 41 |  int (*ppoll)(struct pollfd *fds, nfds_t nfds, void *tmo_p,
> 
> * <libaio.h> not found [3]:
> BUILD libltpnewipc.a
> make[6]: Nothing to be done for 'all'.
> In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop02.c:29:
> In file included from In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop01.c:15:
> In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop.h:7:
> /usr/src/ltp/include/time64_variants.h:10:10: fatal error: /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop.h'libaio.h' file not
>       found
> :7:
> /usr/src/ltp/include/time64_variants.h:10:10: fatal error: 'libaio.h' file#include <libaio.h>
>          ^~~~~~~~~~
>  not
>       found
> #include <libaio.h>

I didn't get any of these on my x86 box :(

I think this should fix it, but I would required help of your bot to
get the testing done for all these architectures. This should get
merged in the first patch, I will resend it.

diff --git a/include/time64_variants.h b/include/time64_variants.h
index 934268b0328b..972eb333b614 100644
--- a/include/time64_variants.h
+++ b/include/time64_variants.h
@@ -7,10 +7,13 @@
 #ifndef TIME64_VARIANTS_H
 #define TIME64_VARIANTS_H
 
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
+#endif /* HAVE_LIBAIO */
+
 #include <signal.h>
 #include <stdio.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <time.h>
 #include "tst_timer.h"
 
@@ -32,8 +35,12 @@ struct time64_variants {
        int (*timer_settime)(kernel_timer_t timerid, int flags, void *its, void *old_its);
        int (*tfd_gettime)(int fd, void *its);
        int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value);
+
+#ifdef HAVE_LIBAIO
        int (*io_pgetevents)(io_context_t ctx, long min_nr, long max_nr,
                        struct io_event *events, void *timeout, sigset_t *sigmask);
+#endif /* HAVE_LIBAIO */
+
        int (*mqt_send)(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
                        unsigned int msg_prio, void *abs_timeout);
        ssize_t (*mqt_receive)(mqd_t mqdes, char *msg_ptr, size_t msg_len,
Viresh Kumar Sept. 11, 2020, 11:01 a.m. UTC | #3
On 11-09-20, 16:09, Viresh Kumar wrote:
> I didn't get any of these on my x86 box :(
> 
> I think this should fix it, but I would required help of your bot to
> get the testing done for all these architectures. This should get
> merged in the first patch, I will resend it.
> 
> diff --git a/include/time64_variants.h b/include/time64_variants.h
> index 934268b0328b..972eb333b614 100644
> --- a/include/time64_variants.h
> +++ b/include/time64_variants.h
> @@ -7,10 +7,13 @@
>  #ifndef TIME64_VARIANTS_H
>  #define TIME64_VARIANTS_H
>  
> +#ifdef HAVE_LIBAIO
>  #include <libaio.h>
> +#endif /* HAVE_LIBAIO */
> +
>  #include <signal.h>
>  #include <stdio.h>
> -#include <sys/poll.h>
> +#include <poll.h>
>  #include <time.h>
>  #include "tst_timer.h"
>  
> @@ -32,8 +35,12 @@ struct time64_variants {
>         int (*timer_settime)(kernel_timer_t timerid, int flags, void *its, void *old_its);
>         int (*tfd_gettime)(int fd, void *its);
>         int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value);
> +
> +#ifdef HAVE_LIBAIO
>         int (*io_pgetevents)(io_context_t ctx, long min_nr, long max_nr,
>                         struct io_event *events, void *timeout, sigset_t *sigmask);
> +#endif /* HAVE_LIBAIO */
> +
>         int (*mqt_send)(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
>                         unsigned int msg_prio, void *abs_timeout);
>         ssize_t (*mqt_receive)(mqd_t mqdes, char *msg_ptr, size_t msg_len,

And both these changes broke my build. I don't even understand how
could the ifdef change break it for me :(

I am looking into it.
Petr Vorel Sept. 11, 2020, 11:45 a.m. UTC | #4
Hi Viresh,

> On 11-09-20, 11:53, Petr Vorel wrote:
> > Hi Viresh,
> > One of the commits fails on various tests [1].

> > Some failures (I haven't checked all):

> > * missing nfds_t (<poll.h> is probably from old commits) [2]:

> > CC testcases/kernel/syscalls/mq_open/mq_open01
> > In file included from ../../../../include/time64_variants.h:13,
> >                  from /usr/src/ltp/testcases/kernel/syscalls/mq_timedreceive/../utils/mq_timed.h:10,
> >                  from mq_timedreceive01.c:17:
> > /usr/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
> >     1 | #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
> >       |  ^~~~~~~
> > In file included from /usr/src/ltp/testcases/kernel/syscalls/mq_timedreceive/../utils/mq_timed.h:10,
> >                  from mq_timedreceive01.c:17:
> > ../../../../include/time64_variants.h:41:35: error: unknown type name 'nfds_t'
> > 41 |  int (*ppoll)(struct pollfd *fds, nfds_t nfds, void *tmo_p,

> > * <libaio.h> not found [3]:
> > BUILD libltpnewipc.a
> > make[6]: Nothing to be done for 'all'.
> > In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop02.c:29:
> > In file included from In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop01.c:15:
> > In file included from /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop.h:7:
> > /usr/src/ltp/include/time64_variants.h:10:10: fatal error: /usr/src/ltp/testcases/kernel/syscalls/ipc/semop/semop.h'libaio.h' file not
> >       found
> > :7:
> > /usr/src/ltp/include/time64_variants.h:10:10: fatal error: 'libaio.h' file#include <libaio.h>
> >          ^~~~~~~~~~
> >  not
> >       found
> > #include <libaio.h>

> I didn't get any of these on my x86 box :(

This is also confusing for me.

Maybe enable travis CI builds for your ltp fork?
You contribute a lot, catching bugs early would be great.

Kind regards,
Petr
Cyril Hrubis Sept. 11, 2020, 1:46 p.m. UTC | #5
Hi!
> > #include <libaio.h>
> 
> I didn't get any of these on my x86 box :(

That's because you have libaio-devel installed, we test all build
combinations with and without a few system libraries LTP depends on.
Cyril Hrubis Sept. 11, 2020, 1:47 p.m. UTC | #6
Hi!
> > --- a/include/time64_variants.h
> > +++ b/include/time64_variants.h
> > @@ -7,10 +7,13 @@
> >  #ifndef TIME64_VARIANTS_H
> >  #define TIME64_VARIANTS_H
> >  
> > +#ifdef HAVE_LIBAIO
> >  #include <libaio.h>
> > +#endif /* HAVE_LIBAIO */
> > +
> >  #include <signal.h>
> >  #include <stdio.h>
> > -#include <sys/poll.h>
> > +#include <poll.h>
> >  #include <time.h>
> >  #include "tst_timer.h"
> >  
> > @@ -32,8 +35,12 @@ struct time64_variants {
> >         int (*timer_settime)(kernel_timer_t timerid, int flags, void *its, void *old_its);
> >         int (*tfd_gettime)(int fd, void *its);
> >         int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value);
> > +
> > +#ifdef HAVE_LIBAIO
> >         int (*io_pgetevents)(io_context_t ctx, long min_nr, long max_nr,
> >                         struct io_event *events, void *timeout, sigset_t *sigmask);
> > +#endif /* HAVE_LIBAIO */
> > +
> >         int (*mqt_send)(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
> >                         unsigned int msg_prio, void *abs_timeout);
> >         ssize_t (*mqt_receive)(mqd_t mqdes, char *msg_ptr, size_t msg_len,
> 
> And both these changes broke my build. I don't even understand how
> could the ifdef change break it for me :(

My guess would be missing include for "config.h" in this file to get
HAVE_LIBAIO definitions.
Viresh Kumar Sept. 16, 2020, 5:51 a.m. UTC | #7
On 11-09-20, 15:47, Cyril Hrubis wrote:
> Hi!
> > > --- a/include/time64_variants.h
> > > +++ b/include/time64_variants.h
> > > @@ -7,10 +7,13 @@
> > >  #ifndef TIME64_VARIANTS_H
> > >  #define TIME64_VARIANTS_H
> > >  
> > > +#ifdef HAVE_LIBAIO
> > >  #include <libaio.h>
> > > +#endif /* HAVE_LIBAIO */
> > > +
> > >  #include <signal.h>
> > >  #include <stdio.h>
> > > -#include <sys/poll.h>
> > > +#include <poll.h>
> > >  #include <time.h>
> > >  #include "tst_timer.h"
> > >  
> > > @@ -32,8 +35,12 @@ struct time64_variants {
> > >         int (*timer_settime)(kernel_timer_t timerid, int flags, void *its, void *old_its);
> > >         int (*tfd_gettime)(int fd, void *its);
> > >         int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value);
> > > +
> > > +#ifdef HAVE_LIBAIO
> > >         int (*io_pgetevents)(io_context_t ctx, long min_nr, long max_nr,
> > >                         struct io_event *events, void *timeout, sigset_t *sigmask);
> > > +#endif /* HAVE_LIBAIO */
> > > +
> > >         int (*mqt_send)(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
> > >                         unsigned int msg_prio, void *abs_timeout);
> > >         ssize_t (*mqt_receive)(mqd_t mqdes, char *msg_ptr, size_t msg_len,
> > 
> > And both these changes broke my build. I don't even understand how
> > could the ifdef change break it for me :(
> 
> My guess would be missing include for "config.h" in this file to get
> HAVE_LIBAIO definitions.

Right. That was it. Thanks.

Though I still get failures if I include poll.h instead of sys/poll.h
here and the errors happen only in mq_timedsend/receive tests. I am
trying to figure out why, but no clue yet.