Change in libosmocore[master]: vty sched: add api to force deferred applying

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Hoernchen gerrit-no-reply at lists.osmocom.org
Thu Sep 9 14:06:21 UTC 2021


Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/25415 )


Change subject: vty sched: add api to force deferred applying
......................................................................

vty sched: add api to force deferred applying

Some applications might not yet have threads at config parsing time, so
applying to threads just does not work, allow enforcing this with a new
api call. This is not reflected in the config file, since this is the
only way this works, so let's not confuse the user with those details by
storing flags or modifying the settings.

Change-Id: Id8405099e6b316c2e14fb0c9b3c5e80a68a91277
---
M include/osmocom/vty/cpu_sched_vty.h
M src/vty/cpu_sched_vty.c
2 files changed, 15 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/15/25415/1

diff --git a/include/osmocom/vty/cpu_sched_vty.h b/include/osmocom/vty/cpu_sched_vty.h
index 171f168..b60fbf9 100644
--- a/include/osmocom/vty/cpu_sched_vty.h
+++ b/include/osmocom/vty/cpu_sched_vty.h
@@ -33,5 +33,6 @@
 
 void osmo_cpu_sched_vty_init(void *tall_ctx);
 int osmo_cpu_sched_vty_apply_localthread(void);
+void osmo_cpu_sched_force_apply_later(bool yes);
 
 /*! @} */
diff --git a/src/vty/cpu_sched_vty.c b/src/vty/cpu_sched_vty.c
index 4ccc627..92b356f 100644
--- a/src/vty/cpu_sched_vty.c
+++ b/src/vty/cpu_sched_vty.c
@@ -76,6 +76,7 @@
 	int sched_rr_prio;
 	struct llist_head cpu_affinity_li;
 	pthread_mutex_t cpu_affinity_li_mutex;
+	bool force_apply_later;
 };
 
 static struct sched_vty_opts *sched_vty_opts;
@@ -392,6 +393,8 @@
 	cpu_set_t *cpuset;
 	size_t cpuset_size;
 
+	applynow = sched_vty_opts->force_apply_later ? false : applynow;
+
 	tid_type = procname2pid(&pid, str_who, applynow);
 	if (tid_type == SCHED_VTY_THREAD_UNKNOWN) {
 		vty_out(vty, "%% Failed parsing target thread %s%s",
@@ -404,7 +407,7 @@
 			(unsigned long)pid, VTY_NEWLINE);
 		return CMD_WARNING;
 	}
-	if (tid_type == SCHED_VTY_THREAD_ALL && !applynow)  {
+	if (tid_type == SCHED_VTY_THREAD_ALL && !applynow && !sched_vty_opts->force_apply_later)  {
 		vty_out(vty, "%% It makes no sense to delay applying cpu-affinity on all threads%s",
 			VTY_NEWLINE);
 		return CMD_WARNING;
@@ -587,7 +590,7 @@
 		if (generate_cpu_hex_mask(str_mask, sizeof(str_mask), it->cpuset, it->cpuset_size) < 0)
 			OSMO_STRLCPY_ARRAY(str_mask, "ERROR");
 		vty_out(vty, " cpu-affinity %s %s%s%s", it->bufname, str_mask,
-			it->delay ? " delay" : "", VTY_NEWLINE);
+			(it->delay && !sched_vty_opts->force_apply_later) ? " delay" : "", VTY_NEWLINE);
 	}
 
 	return CMD_SUCCESS;
@@ -676,4 +679,13 @@
 	return rc;
 }
 
+/*! Force deferred cpu affinty for applications that spawn their threads late
+ * \param[in] yes  Enable/disable delayed thread priority application
+ */
+void osmo_cpu_sched_force_apply_later(bool yes)
+{
+	OSMO_ASSERT(sched_vty_opts);
+	sched_vty_opts->force_apply_later = yes;
+}
+
 /*! @} */

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/25415
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id8405099e6b316c2e14fb0c9b3c5e80a68a91277
Gerrit-Change-Number: 25415
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210909/c1b9d950/attachment.htm>


More information about the gerrit-log mailing list