kernel: pipes: rewrite pipes implementation

This new implementation of pipes has a number of advantages over the
previous.
  1. The schedule locking is eliminated both making it safer for SMP
     and allowing for pipes to be used from ISR context.
  2. The code used to be structured to have separate code for copying
     to/from a wating thread's buffer and the pipe buffer. This had
     unnecessary duplication that has been replaced with a simpler
     scatter-gather copy model.
  3. The manner in which the "working list" is generated has also been
     simplified. It no longer tries to use the thread's queuing node.
     Instead, the k_pipe_desc structure (whose instances are on the
     part of the k_thread structure) has been extended to contain
     additional fields including a node for use with a linked list. As
     this impacts the k_thread structure, pipes are now configurable
     in the kernel via CONFIG_PIPES.

Fixes #47061

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2022-07-08 11:27:09 -04:00 committed by Carles Cufí
commit f86027ffb7
7 changed files with 356 additions and 427 deletions

View file

@ -30,8 +30,10 @@ struct k_spinlock _track_list_k_msgq_lock;
struct k_mbox *_track_list_k_mbox;
struct k_spinlock _track_list_k_mbox_lock;
#ifdef CONFIG_PIPES
struct k_pipe *_track_list_k_pipe;
struct k_spinlock _track_list_k_pipe_lock;
#endif
struct k_queue *_track_list_k_queue;
struct k_spinlock _track_list_k_queue_lock;
@ -95,11 +97,13 @@ void sys_track_k_mbox_init(struct k_mbox *mbox)
SYS_TRACK_LIST_PREPEND(_track_list_k_mbox, mbox));
}
#ifdef CONFIG_PIPES
void sys_track_k_pipe_init(struct k_pipe *pipe)
{
SYS_PORT_TRACING_TYPE_MASK(k_pipe,
SYS_TRACK_LIST_PREPEND(_track_list_k_pipe, pipe));
}
#endif
void sys_track_k_queue_init(struct k_queue *queue)
{
@ -132,8 +136,10 @@ static int sys_track_static_init(const struct device *arg)
SYS_PORT_TRACING_TYPE_MASK(k_mbox,
SYS_TRACK_STATIC_INIT(k_mbox));
#ifdef CONFIG_PIPES
SYS_PORT_TRACING_TYPE_MASK(k_pipe,
SYS_TRACK_STATIC_INIT(k_pipe));
#endif
SYS_PORT_TRACING_TYPE_MASK(k_queue,
SYS_TRACK_STATIC_INIT(k_queue));