Project

General

Profile

Osmo io » History » Revision 7

Revision 6 (laforge, 03/14/2024 07:51 AM) → Revision 7/8 (laforge, 03/14/2024 08:05 AM)

h1. osmo_io 

 @osmo_io@ is the new (2023) way of ho we do I/O in osmocom projects. It moves from a raw select/poll abstraction (where every application performs its own read/write once the fd becomes readble/writable) to a submission/completion model, where the actual I/O is performed by the library, an the application just submits write requests (as @struct msgb@) and receives write-completion and read-completion call-backs. 

 Apart from having more code reuse and a cleaner split between application and I/O library, this has the added advantage that the underlying operating system I/O mechanism can be swapped out without touching each and every application.    Specifically, we have currently the following two back-ends implemented in libosmocore: 
 * *POLL*: classic osmo_fd based implementation using @poll(2)@ (default) 
 * *IO_URING*: a backend using the Linux kernel @io_uring(7)@ API 

 The choice of back-end is done via setting the @LIBOSMO_IO_BACKEND@ environment variable.    If you set it to IO_URING when starting an osmocom program, all sub-systems / interfaces ported over to the osmo_io API will make use of the @io_uring(7)@ API (via liburing). 

 The main advantage of io_uring is performance.    Benchmarking has shown that a classic, poll-based production osmo-bsc loaded with 400 TRX is spending about 40% of its CPU cycles in the system call overhad (sock_poll, tcp_poll and do_sys_poll) and a lot of system call entry/exit in general, due to the many small read/write/recvmsg/sendmsg/recfrom/sendto and poll calls. 

 For more information, see:  
 * the original discussion in #5751  
 * FIXME 

 API reference at https://ftp.osmocom.org/api/latest/libosmocore/core/html/osmo__io_8c.html#details 

 

 h2. Implementation status 

 The below tables indicate the implementation status of the osmo_io migration: 

 h3. Libraries 

 |_.library/interface|_.protocol|_.transport|_.users|_.commit|_.issue| 
 |libosmocore|gsmtap|UDP|everyone|"libosmocore":https://gerrit.osmocom.org/c/libosmocore/+/34743|#6213| 
 |libosmo-mgcp-client|MGCP|UDP|osmo-bsc, osmo-msc, osmo-hnbgw|"osmo-mgw":https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw/commit/8b524c9151177d681b35332146d7628fafd82846|#5754| 
 |libosmogb ns2|NS|UDP|osmo-pcu, osmo-gbproxy, osmo-sgsn|"libosmocore":https://gitea.osmocom.org/osmocom/libosmocore/commit/eb9edbab54463cb705ec7b770e022a215ce503c7|#5751| 
 |libosmo-netif|stream_cli|TCP|libosmo-sigtran(ipa), osmo-bsc(cbsp), osmo-cbc(cbsp)|"libosmo-netif":https://gitea.osmocom.org/osmocom/libosmo-netif/commit/0e7028f742dedefd9fccc2d5b26875fca4036f58|#5753| 
 |libosmo-netif|stream_cli|SCTP|libosmo-sigtran|"libosmo-netif":https://gitea.osmocom.org/osmocom/libosmo-netif/commit/7e6d2e0f99ff095f4714f03b1ed991d6c9cb9c61|#5753| 
 |libosmo-sigtran|xUA ASP (SUA, M3UA)|SCTP|osmo-bsc, osmo-msc, osmo-sgsn, osmo-hnbgw, osmo-smlc|"libosmo-sigtran":https://gitea.osmocom.org/osmocom/libosmo-sccp/commit/9257cd896e255403822bee6f87f5487a92fd3c11|#5752| 

 h3. Program 

 |_.program|_.Interface/protocol|_.transport|_.commit|_.issue| 
 |osmo-gbproxy|Gb/NS|UDP|indirect via "libosmogb ns2":https://gitea.osmocom.org/osmocom/libosmocore/commit/eb9edbab54463cb705ec7b770e022a215ce503c7| 
 |osmo-bsc|CBSP|TCP client+server|"osmo-bsc":https://gitea.osmocom.org/cellular-infrastructure/osmo-bsc/commit/85687bf176e4b9663f2396a27c28b49221c72fa3|#6170| 
 |osmo-bsc|meas_feed|UDP|"osmo-bsc":https://gitea.osmocom.org/cellular-infrastructure/osmo-bsc/commit/ea388e1db1465afdcfd2796336732d29d80a2b9f| 
 |osmo-bsc|MGCP|UDP|indirect via libosmo-mgcp-client|#5755| 
 |osmo-bsc|M3UA/SUA/IPA|SCTP/TCP|indirect via libosmo-sigtran|#5755| 
 |osmo-hnbgw|MGCP|UDP|indirect via libosmo-mgcp-client| 
 |osmo-hnbgw|M3UA/SUA/IPA|SCTP/TCP|indirect via libosmo-sigtran| 
 |osmo-msc|MGCP|UDP|indirect via libosmo-mgcp-client| 
 |osmo-msc|M3UA/SUA/IPA|SCTP/TCP|indirect via libosmo-sigtran| 
 |osmo-sgsn|M3UA/SUA/IPA|SCTP/TCP|indirect via libosmo-sigtran| 
 |osmo-sgsn|Gb/NS|UDP|indirect via "libosmogb ns2":https://gitea.osmocom.org/osmocom/libosmocore/commit/eb9edbab54463cb705ec7b770e022a215ce503c7| 
 |osmo-smlc|M3UA/SUA/IPA|SCTP/TCP|indirect via libosmo-sigtran| 
 |osmo-stp|M3UA/SUA/IPA|SCTP/TCP|indirect via libosmo-sigtran|#5752| 

 h2. Further reading 

 * "wikipedia page on io_uring":https://en.wikipedia.org/wiki/Io_uring 
 * "Efficient IO with io_uring":https://kernel.dk/io_uring.pdf by the io_uring creator Jens Axboe. 
 * "io_uring and networking in 2023":https://kernel.dk/io_uring%20and%20networking%20in%202023.pdf
Add picture from clipboard (Maximum size: 48.8 MB)