Philippe Gerum : cobalt/rtdm: leave mode selection to I/O syscall handlers
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 108 lines · git repository hosting
Module: xenomai-3 Branch: wip/dovetail Commit: 37f90fb2a9d1d8ad6e120e01c8972817b315baf6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=37f90fb2a9d1d8ad6e120e01c8972817b315baf6Author: Philippe Gerum <[email protected]> Date: Thu Jul 7 18:35:47 2016 +0200cobalt/rtdm: leave mode selection to I/O syscall handlers
We don't want requests bearing invalid file descriptors (RTDM-wise) to trigger any mode switch, so that RTDM requests on regular fildes can be rejected with little overhead.
Tell the core to hand over mode selection to RTDM I/O syscall handlers, which now check the file descriptor prior to triggering any mode transition.
---
kernel/cobalt/posix/io.c | 10 +-- kernel/cobalt/posix/syscall32.c | 4 +- kernel/cobalt/rtdm/fd.c | 144 +++++++++++++++++++++++---------------- 3 files changed, 92 insertions(+), 66 deletions(-)kernel/cobalt/posix/io.c +5
-5@@ -58,25 +58,25 @@ COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))return rtdm_fd_fcntl (fd, cmd, arg); } -COBALT_SYSCALL (ioctl, probing, +COBALT_SYSCALL (ioctl, handover, (int fd, unsigned int request, void __user *arg)) {return rtdm_fd_ioctl (fd, request, arg); } -COBALT_SYSCALL (read, probing, +COBALT_SYSCALL (read, handover, (int fd, void __user *buf, size_t size)) {return rtdm_fd_read (fd, buf, size); } -COBALT_SYSCALL (write, probing, +COBALT_SYSCALL (write, handover, (int fd, const void __user *buf, size_t size)) {return rtdm_fd_write (fd, buf, size); } -COBALT_SYSCALL (recvmsg, probing, +COBALT_SYSCALL (recvmsg, handover, (int fd, struct user_msghdr __user *umsg, int flags)) {struct user_msghdr m;@@ -93,7 +93,7 @@ COBALT_SYSCALL(recvmsg, probing,return cobalt_copy_to_user (umsg, &m,sizeof (*umsg)) ?: ret; } -COBALT_SYSCALL (sendmsg, probing, +COBALT_SYSCALL (sendmsg, handover, (int fd, struct user_msghdr __user *umsg, int flags)) {struct user_msghdr m;kernel/cobalt/posix/syscall32.c +2
-2@@ -766,7 +766,7 @@ COBALT_SYSCALL32emu(select, nonrestartable,return err; } -COBALT_SYSCALL32emu (recvmsg, probing, +COBALT_SYSCALL32emu (recvmsg, handover, (int fd, struct compat_msghdr __user *umsg, int flags)) {@@ -784,7 +784,7 @@ COBALT_SYSCALL32emu(recvmsg, probing,return sys32_put_msghdr (umsg, &m) ?: ret; } -COBALT_SYSCALL32emu (sendmsg, probing, +COBALT_SYSCALL32emu (sendmsg, handover, (int fd, struct compat_msghdr __user *umsg, int flags)) {struct user_msghdr m;kernel/cobalt/rtdm/fd.c +10
-0@@ -392,6 +392,44 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...) }EXPORT_SYMBOL_GPL (rtdm_fd_fcntl); +static struct rtdm_fd *get_fd_fixup_mode (int ufd) +{ +struct xnthread *thread; +struct rtdm_fd *fd; + + fd =rtdm_fd_get (ufd,0 ); +if (IS_ERR (fd)) +return fd; + +/*
kernel/cobalt/rtdm/fd.c int rtdm_fd_fcntl(int ufd, int cmd, ...) · line 414
Quoted 10 lines
kernel/cobalt/rtdm/fd.c +10
-0+* Mode is selected according to the following convention: +* +* - Cobalt threads must try running the syscall from primary +* mode as a first attempt, regardless of their scheduling +* class. The driver handler may ask for demoting the caller +* to secondary mode by returning -ENOSYS. +* +* - Regular threads (i.e. not bound to Cobalt) may only run +* the syscall from secondary mode. +*/
In case of IOCTLs, we would also have to push the decision one level further, into the driver. Only in few cases, default would remain this policy here. Do you already have a suggestion how to do that?
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 115 lines · Jan Kiszka
Quoted 114 lines · git repository hosting
Module: xenomai-3 Branch: wip/dovetail Commit: 37f90fb2a9d1d8ad6e120e01c8972817b315baf6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=37f90fb2a9d1d8ad6e120e01c8972817b315baf6Author: Philippe Gerum <[email protected]> Date: Thu Jul 7 18:35:47 2016 +0200cobalt/rtdm: leave mode selection to I/O syscall handlers
We don't want requests bearing invalid file descriptors (RTDM-wise) to trigger any mode switch, so that RTDM requests on regular fildes can be rejected with little overhead.
Tell the core to hand over mode selection to RTDM I/O syscall handlers, which now check the file descriptor prior to triggering any mode transition.
---
kernel/cobalt/posix/io.c | 10 +-- kernel/cobalt/posix/syscall32.c | 4 +- kernel/cobalt/rtdm/fd.c | 144 +++++++++++++++++++++++---------------- 3 files changed, 92 insertions(+), 66 deletions(-)kernel/cobalt/posix/io.c +5
-5@@ -58,25 +58,25 @@ COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))return rtdm_fd_fcntl (fd, cmd, arg); } -COBALT_SYSCALL (ioctl, probing, +COBALT_SYSCALL (ioctl, handover, (int fd, unsigned int request, void __user *arg)) {return rtdm_fd_ioctl (fd, request, arg); } -COBALT_SYSCALL (read, probing, +COBALT_SYSCALL (read, handover, (int fd, void __user *buf, size_t size)) {return rtdm_fd_read (fd, buf, size); } -COBALT_SYSCALL (write, probing, +COBALT_SYSCALL (write, handover, (int fd, const void __user *buf, size_t size)) {return rtdm_fd_write (fd, buf, size); } -COBALT_SYSCALL (recvmsg, probing, +COBALT_SYSCALL (recvmsg, handover, (int fd, struct user_msghdr __user *umsg, int flags)) {struct user_msghdr m;@@ -93,7 +93,7 @@ COBALT_SYSCALL(recvmsg, probing,return cobalt_copy_to_user (umsg, &m,sizeof (*umsg)) ?: ret; } -COBALT_SYSCALL (sendmsg, probing, +COBALT_SYSCALL (sendmsg, handover, (int fd, struct user_msghdr __user *umsg, int flags)) {struct user_msghdr m;kernel/cobalt/posix/syscall32.c +2
-2@@ -766,7 +766,7 @@ COBALT_SYSCALL32emu(select, nonrestartable,return err; } -COBALT_SYSCALL32emu (recvmsg, probing, +COBALT_SYSCALL32emu (recvmsg, handover, (int fd, struct compat_msghdr __user *umsg, int flags)) {@@ -784,7 +784,7 @@ COBALT_SYSCALL32emu(recvmsg, probing,return sys32_put_msghdr (umsg, &m) ?: ret; } -COBALT_SYSCALL32emu (sendmsg, probing, +COBALT_SYSCALL32emu (sendmsg, handover, (int fd, struct compat_msghdr __user *umsg, int flags)) {struct user_msghdr m;kernel/cobalt/rtdm/fd.c +16
-0@@ -392,6 +392,44 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...) }EXPORT_SYMBOL_GPL (rtdm_fd_fcntl); +static struct rtdm_fd *get_fd_fixup_mode (int ufd) +{ +struct xnthread *thread; +struct rtdm_fd *fd; + + fd =rtdm_fd_get (ufd,0 ); +if (IS_ERR (fd)) +return fd; + +/* +* Mode is selected according to the following convention: +* +* - Cobalt threads must try running the syscall from primary +* mode as a first attempt, regardless of their scheduling +* class. The driver handler may ask for demoting the caller +* to secondary mode by returning -ENOSYS.
Quoted 9 lines
kernel/cobalt/rtdm/fd.c int rtdm_fd_fcntl(int ufd, int cmd, ...) · line 414
Quoted 4 lines
kernel/cobalt/rtdm/fd.c +4
-0+* +* - Regular threads (i.e. not bound to Cobalt) may only run +* the syscall from secondary mode. +*/ In case of IOCTLs, we would also have to push the decision one level further, into the driver. Only in few cases, default would remain this policy here. Do you already have a suggestion how to do that?
Yes, by tagging the specific ioctl codes accordingly in a way the RTDM core can detect (e.g. some bit set in the request code), so that the driver may eventually enforce the policy. A tag meaning "that ioctl request should run in secondary mode" would cover all requirements.
Signature · 1 line
Philippe.
Quoted 126 lines · Philippe Gerum
Quoted 115 lines · Jan Kiszka
Quoted 114 lines · git repository hosting
Module: xenomai-3 Branch: wip/dovetail Commit: 37f90fb2a9d1d8ad6e120e01c8972817b315baf6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=37f90fb2a9d1d8ad6e120e01c8972817b315baf6Author: Philippe Gerum <[email protected]> Date: Thu Jul 7 18:35:47 2016 +0200cobalt/rtdm: leave mode selection to I/O syscall handlers
We don't want requests bearing invalid file descriptors (RTDM-wise) to trigger any mode switch, so that RTDM requests on regular fildes can be rejected with little overhead.
Tell the core to hand over mode selection to RTDM I/O syscall handlers, which now check the file descriptor prior to triggering any mode transition.
---
kernel/cobalt/posix/io.c | 10 +-- kernel/cobalt/posix/syscall32.c | 4 +- kernel/cobalt/rtdm/fd.c | 144 +++++++++++++++++++++++---------------- 3 files changed, 92 insertions(+), 66 deletions(-)kernel/cobalt/posix/io.c +5
-5@@ -58,25 +58,25 @@ COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))return rtdm_fd_fcntl (fd, cmd, arg); } -COBALT_SYSCALL (ioctl, probing, +COBALT_SYSCALL (ioctl, handover, (int fd, unsigned int request, void __user *arg)) {return rtdm_fd_ioctl (fd, request, arg); } -COBALT_SYSCALL (read, probing, +COBALT_SYSCALL (read, handover, (int fd, void __user *buf, size_t size)) {return rtdm_fd_read (fd, buf, size); } -COBALT_SYSCALL (write, probing, +COBALT_SYSCALL (write, handover, (int fd, const void __user *buf, size_t size)) {return rtdm_fd_write (fd, buf, size); } -COBALT_SYSCALL (recvmsg, probing, +COBALT_SYSCALL (recvmsg, handover, (int fd, struct user_msghdr __user *umsg, int flags)) {struct user_msghdr m;@@ -93,7 +93,7 @@ COBALT_SYSCALL(recvmsg, probing,return cobalt_copy_to_user (umsg, &m,sizeof (*umsg)) ?: ret; } -COBALT_SYSCALL (sendmsg, probing, +COBALT_SYSCALL (sendmsg, handover, (int fd, struct user_msghdr __user *umsg, int flags)) {struct user_msghdr m;kernel/cobalt/posix/syscall32.c +2
-2@@ -766,7 +766,7 @@ COBALT_SYSCALL32emu(select, nonrestartable,return err; } -COBALT_SYSCALL32emu (recvmsg, probing, +COBALT_SYSCALL32emu (recvmsg, handover, (int fd, struct compat_msghdr __user *umsg, int flags)) {@@ -784,7 +784,7 @@ COBALT_SYSCALL32emu(recvmsg, probing,return sys32_put_msghdr (umsg, &m) ?: ret; } -COBALT_SYSCALL32emu (sendmsg, probing, +COBALT_SYSCALL32emu (sendmsg, handover, (int fd, struct compat_msghdr __user *umsg, int flags)) {struct user_msghdr m;kernel/cobalt/rtdm/fd.c +16
-0@@ -392,6 +392,44 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...) }EXPORT_SYMBOL_GPL (rtdm_fd_fcntl); +static struct rtdm_fd *get_fd_fixup_mode (int ufd) +{ +struct xnthread *thread; +struct rtdm_fd *fd; + + fd =rtdm_fd_get (ufd,0 ); +if (IS_ERR (fd)) +return fd; + +/* +* Mode is selected according to the following convention: +* +* - Cobalt threads must try running the syscall from primary +* mode as a first attempt, regardless of their scheduling +* class. The driver handler may ask for demoting the caller +* to secondary mode by returning -ENOSYS. Quoted 9 lines
kernel/cobalt/rtdm/fd.c int rtdm_fd_fcntl(int ufd, int cmd, ...) · line 414
Quoted 4 lines
kernel/cobalt/rtdm/fd.c +4
-0+* +* - Regular threads (i.e. not bound to Cobalt) may only run +* the syscall from secondary mode. +*/ In case of IOCTLs, we would also have to push the decision one level further, into the driver. Only in few cases, default would remain this policy here. Do you already have a suggestion how to do that?
Quoted 5 lines
Yes, by tagging the specific ioctl codes accordingly in a way the RTDM core can detect (e.g. some bit set in the request code), so that the driver may eventually enforce the policy. A tag meaning "that ioctl request should run in secondary mode" would cover all requirements.
Ah - weak memory, you proposed this already. Let me look into this.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux