Skip to contentSkip to conversation

backports: add sched_set_fifo_low

PATCH In review Felix Fietkau 2 participants 3 messages Nov 12, 2020 – Nov 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 backports: add sched_set_fifo_low

It is needed for mt76

---
 backport/backport-include/linux/sched.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 backport/backport-include/linux/sched.h
backport/backport-include/linux/sched.h new file +19 -0
new file mode 100644
index 000000000000..be77a8d771ab
@@ -0,0 +1,19 @@
+#ifndef __BACKPORT_LINUX_SCHED_H
+#define __BACKPORT_LINUX_SCHED_H
+
+#include_next <linux/sched.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_IS_LESS(5,9,0)
+#include <uapi/linux/sched/types.h>
+
+static inline void sched_set_fifo_low(struct task_struct *p)
+{
+	struct sched_param sparam = {.sched_priority = 1};
+
+	sched_setscheduler(p, SCHED_FIFO, &sparam);
+}
+
+#endif
+
+#endif
Signature · 4 lines
2.28.0

--
To unsubscribe from this list: send the line "unsubscribe backports" in
#1 lore raw

PATCH 2/2 backports: add tasklet_setup, from_tasklet

Add the new tasklet API

---
 backport/backport-include/linux/interrupt.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
backport/backport-include/linux/interrupt.h +17 -0
index f7e7134d8338..f334a9636180 100644
@@ -31,6 +31,23 @@ static inline void backport_hrtimer_start(struct hrtimer *timer, s64 time,
 	hrtimer_start(timer, _time, mode);
 }
 #define hrtimer_start LINUX_BACKPORT(hrtimer_start)
+
+#endif
+
+#if LINUX_VERSION_IS_LESS(5,9,0)
+
+static inline void
+tasklet_setup(struct tasklet_struct *t,
+	      void (*callback)(struct tasklet_struct *))
+{
+	void (*cb)(unsigned long data) = (void *)callback;
+
+	tasklet_init(t, cb, (unsigned long)t);
+}
+
+#define from_tasklet(var, callback_tasklet, tasklet_fieldname) \
+	container_of(callback_tasklet, typeof(*var), tasklet_fieldname)
+
 #endif
 
 #endif /* _BP_LINUX_INTERRUPT_H */
Signature · 4 lines
2.28.0

--
To unsubscribe from this list: send the line "unsubscribe backports" in
#2 lore raw
In reply to Felix Fietkau
Quoted 18 lines · Felix Fietkau

It is needed for mt76

---
  backport/backport-include/linux/sched.h | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

create mode 100644 backport/backport-include/linux/sched.h

backport/backport-include/linux/sched.h new file +4 -0
new file mode 100644
index 000000000000..be77a8d771ab
@@ -0,0 +1,19 @@
+#ifndef __BACKPORT_LINUX_SCHED_H
+#define __BACKPORT_LINUX_SCHED_H
+
+#include_next <linux/sched.h>

backport/backport-include/linux/sched.h line 14

Quoted 10 lines
backport/backport-include/linux/sched.h new file +10 -0
+#include <linux/version.h>
+
+#if LINUX_VERSION_IS_LESS(5,9,0)
+#include <uapi/linux/sched/types.h>
+
+static inline void sched_set_fifo_low(struct task_struct *p)
+{
+	struct sched_param sparam = {.sched_priority = 1};
+
+	sched_setscheduler(p, SCHED_FIFO, &sparam);

Hi Felix,

The upstream kernel uses this in sched_set_fifo_low():
WARN_ON_ONCE(sched_setscheduler_nocheck(p, SCHED_FIFO, &sp) != 0);
See:
https://elixir.bootlin.com/linux/v5.10-rc3/source/kernel/sched/core.c#L5570

Did you change this intentionally?

Hauke
--
To unsubscribe from this list: send the line "unsubscribe backports" in