pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/41989?usp=email )
Change subject: osmo_io: Allow fetching maximum value allowed by osmo_iofd_set_io_buffers()
......................................................................
osmo_io: Allow fetching maximum value allowed by osmo_iofd_set_io_buffers()
Before this patch, there's no way for a user of the API to know whether
a requested buffers value is actually going to be accepted or not.
Change-Id: Id3d8413c119eb3d9b60aa068295a59561236938c
---
M src/core/osmo_io.c
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/89/41989/1
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 7c931d3..8ee6967 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -915,15 +915,23 @@
* \param[in] op the osmo_io_op (read or write) to set the number of IO buffers for
* \param[in] buffers the number of IO buffer for each specified operation
* \returns zero on success, a negative value on error
+ *
+ * The minimum valid buffers to set is always 1.
+ * The maximum valid buffers is implementation defined, and trying to set a
+ * value greater than the maximum will return an error.
+ * Passing \ref buffers with a value of 0 can be used to fetch the maximum value allowed.
*/
int osmo_iofd_set_io_buffers(struct osmo_io_fd *iofd, enum osmo_io_op op, uint8_t buffers)
{
if (iofd->mode != OSMO_IO_FD_MODE_READ_WRITE)
return -EINVAL;
- if (buffers < 1 || buffers > IOFD_MSGHDR_IO_BUFFERS)
+ if (buffers > IOFD_MSGHDR_IO_BUFFERS)
return -EINVAL;
+ if (buffers == 0)
+ return IOFD_MSGHDR_IO_BUFFERS;
+
switch (op) {
case OSMO_IO_OP_READ:
iofd->io_read_buffers = buffers;
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41989?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id3d8413c119eb3d9b60aa068295a59561236938c
Gerrit-Change-Number: 41989
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/41990?usp=email )
Change subject: logging_file: Request up to 8 iofd write buffers if available
......................................................................
logging_file: Request up to 8 iofd write buffers if available
This should help in decreasing latency between submitting a logging line
and getting it written to file. It should, for the same reason, optimize
CPU use.
Change-Id: Ia88b27948922d278e0f72fc2aac4b4ae88465b4d
---
M src/core/logging_file.c
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/90/41990/1
diff --git a/src/core/logging_file.c b/src/core/logging_file.c
index 9c7cf36..067f993 100644
--- a/src/core/logging_file.c
+++ b/src/core/logging_file.c
@@ -253,6 +253,10 @@
_log_target_file_setup_talloc_pool(target);
osmo_iofd_set_txqueue_max_length(iofd, OSMO_MAX(osmo_iofd_get_txqueue_max_length(iofd), LOG_WQUEUE_LEN));
+ /* Request to use 8 write buffers, or less if not as many are available: */
+ rc = osmo_iofd_set_io_buffers(iofd, OSMO_IO_OP_WRITE, 0);
+ rc = osmo_iofd_set_io_buffers(iofd, OSMO_IO_OP_WRITE, OSMO_MIN(rc, 8));
+
rc = osmo_iofd_register(iofd, -1);
if (rc < 0) {
osmo_iofd_free(iofd);
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41990?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ia88b27948922d278e0f72fc2aac4b4ae88465b4d
Gerrit-Change-Number: 41990
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/41988?usp=email )
Change subject: osmo_io: Remove outdated comment in API doc of osmo_iofd_set_io_buffers()
......................................................................
osmo_io: Remove outdated comment in API doc of osmo_iofd_set_io_buffers()
Multiple iov buffers are supported in poll backend since
4272cd46b1e5b264e6f6b65d38bcb08e3a139a9e.
Related: OS#6705
Change-Id: I9b75f3597081c6cd7e24f75f0e289b93edb3aa86
---
M src/core/osmo_io.c
1 file changed, 0 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/88/41988/1
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 3cd9dc5..7c931d3 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -910,7 +910,6 @@
*
* If the osmo_io_fd is in OSMO_IO_FD_MODE_READ_WRITE mode, this API function can be used to tell the
* osmo_io proecess how many buffers should be read or written with a single read or write operation.
- * This feature is supported with io_uring backend only.
*
* \param[in] iofd the iofd file descriptor
* \param[in] op the osmo_io_op (read or write) to set the number of IO buffers for
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41988?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I9b75f3597081c6cd7e24f75f0e289b93edb3aa86
Gerrit-Change-Number: 41988
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/41987?usp=email )
Change subject: osmo_io: Introduce API osmo_iofd_get_txqueue_max_length()
......................................................................
osmo_io: Introduce API osmo_iofd_get_txqueue_max_length()
Change-Id: I92526aa554fc87734fae3fac0ad650d17bf52bb5
---
M include/osmocom/core/osmo_io.h
M src/core/libosmocore.map
M src/core/osmo_io.c
3 files changed, 12 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/41987/1
diff --git a/include/osmocom/core/osmo_io.h b/include/osmocom/core/osmo_io.h
index 525c23c..c92492c 100644
--- a/include/osmocom/core/osmo_io.h
+++ b/include/osmocom/core/osmo_io.h
@@ -233,6 +233,7 @@
void osmo_iofd_set_alloc_info(struct osmo_io_fd *iofd, unsigned int size, unsigned int headroom);
void osmo_iofd_set_txqueue_max_length(struct osmo_io_fd *iofd, unsigned int size);
+unsigned int osmo_iofd_get_txqueue_max_length(const struct osmo_io_fd *iofd);
void *osmo_iofd_get_data(const struct osmo_io_fd *iofd);
void osmo_iofd_set_data(struct osmo_io_fd *iofd, void *data);
diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map
index cb79843..f6e15f0 100644
--- a/src/core/libosmocore.map
+++ b/src/core/libosmocore.map
@@ -273,6 +273,7 @@
osmo_iofd_set_name;
osmo_iofd_set_name_f;
osmo_iofd_get_priv_nr;
+osmo_iofd_get_txqueue_max_length;
osmo_iofd_init;
osmo_iofd_mode_names;
osmo_iofd_ops;
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 514d592..3cd9dc5 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -1147,6 +1147,16 @@
iofd->tx_queue.max_length = max_length;
}
+
+/*! Get the maximum number of messages enqueued for sending.
+ * \param[in] iofd the file descriptor
+ * \returns the maximum size of the transmit queue
+ */
+unsigned int osmo_iofd_get_txqueue_max_length(const struct osmo_io_fd *iofd)
+{
+ return iofd->tx_queue.max_length;
+}
+
/*! Retrieve the associated user-data from an osmo_io_fd.
*
* A call to this function will return the opaque user data pointer which was specified previously
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41987?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I92526aa554fc87734fae3fac0ad650d17bf52bb5
Gerrit-Change-Number: 41987
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/41986?usp=email )
Change subject: logging: Also Avoid infinite loop/deadlock in log_check_level()
......................................................................
logging: Also Avoid infinite loop/deadlock in log_check_level()
A LOG() macro being called inside an already-logging path will first
call log_check_level() before calling osmo_vlogp(). Since calling
happens with the mutex hold, it has been seen to deadlock in eg.
osmo-hnbgw.
Change-Id: I0098629b335b3aa174b49fd79c33d22b04bc4785
---
M src/core/logging.c
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/41986/1
diff --git a/src/core/logging.c b/src/core/logging.c
index 60634af..db5433e 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -753,7 +753,8 @@
if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
/* Avoid re-entrant logging: If logging to log target generates
* extra logging (eg. an error log line due to some wqueue being full),
- * we may end up in an infinite loop. */
+ * we may end up in an infinite loop, or deadlock trying to re-acquire
+ * this same lock. */
return;
}
log_thread_state.logging_active = true;
@@ -1397,6 +1398,13 @@
/* TODO: The following could/should be cached (update on config) */
+ if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
+ /* Avoid re-entrant logging: If logging to log target generates
+ * extra logging (eg. an error log line due to some wqueue being full),
+ * we may end up in an infinite loop, or deadlock trying to re-acquire
+ * this same lock. */
+ return 0;
+ }
log_tgt_mutex_lock();
llist_for_each_entry(tar, &osmo_log_target_list, entry) {
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41986?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I0098629b335b3aa174b49fd79c33d22b04bc4785
Gerrit-Change-Number: 41986
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/41984?usp=email )
Change subject: Fix 'logging: Avoid infinite loop logging inside logging path'
......................................................................
Fix 'logging: Avoid infinite loop logging inside logging path'
I didn't see the early return of log_cache_check(), which should leave
the logging_active variable as true forever.
Fixes: bc400626b28c85fe0f52ce25947a90650b0d06b5
Change-Id: I13ed182688597c7da279a50bf057eff6d13f0867
---
M src/core/logging.c
1 file changed, 7 insertions(+), 8 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/src/core/logging.c b/src/core/logging.c
index 3e60597..60634af 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -743,14 +743,6 @@
{
struct log_target *tar;
- if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
- /* Avoid re-entrant logging: If logging to log target generates
- * extra logging (eg. an error log line due to some wqueue being full),
- * we may end up in an infinite loop. */
- return;
- }
- log_thread_state.logging_active = true;
-
subsys = map_subsys(subsys);
#if !defined(EMBEDDED)
@@ -758,6 +750,13 @@
return;
#endif
+ if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
+ /* Avoid re-entrant logging: If logging to log target generates
+ * extra logging (eg. an error log line due to some wqueue being full),
+ * we may end up in an infinite loop. */
+ return;
+ }
+ log_thread_state.logging_active = true;
log_tgt_mutex_lock();
llist_for_each_entry(tar, &osmo_log_target_list, entry) {
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41984?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I13ed182688597c7da279a50bf057eff6d13f0867
Gerrit-Change-Number: 41984
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/41984?usp=email )
Change subject: Fix 'logging: Avoid infinite loop logging inside logging path'
......................................................................
Fix 'logging: Avoid infinite loop logging inside logging path'
I didn't see the early return of log_cache_check(), which should leave
the logging_active variable as true forever.
Fixes: bc400626b28c85fe0f52ce25947a90650b0d06b5
Change-Id: I13ed182688597c7da279a50bf057eff6d13f0867
---
M src/core/logging.c
1 file changed, 7 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/41984/1
diff --git a/src/core/logging.c b/src/core/logging.c
index 3e60597..60634af 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -743,14 +743,6 @@
{
struct log_target *tar;
- if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
- /* Avoid re-entrant logging: If logging to log target generates
- * extra logging (eg. an error log line due to some wqueue being full),
- * we may end up in an infinite loop. */
- return;
- }
- log_thread_state.logging_active = true;
-
subsys = map_subsys(subsys);
#if !defined(EMBEDDED)
@@ -758,6 +750,13 @@
return;
#endif
+ if (OSMO_UNLIKELY(log_thread_state.logging_active)) {
+ /* Avoid re-entrant logging: If logging to log target generates
+ * extra logging (eg. an error log line due to some wqueue being full),
+ * we may end up in an infinite loop. */
+ return;
+ }
+ log_thread_state.logging_active = true;
log_tgt_mutex_lock();
llist_for_each_entry(tar, &osmo_log_target_list, entry) {
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41984?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I13ed182688597c7da279a50bf057eff6d13f0867
Gerrit-Change-Number: 41984
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>