Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F169431194
D54945.id170735.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D54945.id170735.diff
View Options
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -600,7 +600,7 @@
loadav, NULL, C_DIRECT_EXEC | C_PREL(32));
}
-static void
+void
ast_scheduler(struct thread *td, int tda __unused)
{
#ifdef KTRACE
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -97,6 +97,7 @@
int ts_slptime; /* Seconds !RUNNING. */
int ts_slice; /* Remaining part of time slice. */
int ts_flags;
+ bool ts_needs_resched;
struct runq *ts_runq; /* runq the thread is currently on */
#ifdef KTR
char ts_name[TS_NAME_LEN];
@@ -274,6 +275,19 @@
KTR_COUNTER0(KTR_SCHED, "load", "global load", sched_tdcnt);
SDT_PROBE2(sched, , , load__change, NOCPU, sched_tdcnt);
}
+
+static void
+maybe_resched_ast(struct thread *td, int tda)
+{
+ struct td_sched *ts;
+
+ ts = td_get_sched(td);
+ if (ts->ts_needs_resched) {
+ ts->ts_needs_resched = false;
+ ast_scheduler(td, tda);
+ }
+}
+
/*
* Arrange to reschedule if necessary, taking the priorities and
* schedulers into account.
@@ -281,10 +295,15 @@
static void
maybe_resched(struct thread *td)
{
+ struct thread *ctd;
+ struct td_sched *ts;
+ ctd = curthread;
THREAD_LOCK_ASSERT(td, MA_OWNED);
- if (td->td_priority < curthread->td_priority)
- ast_sched_locked(curthread, TDA_SCHED);
+ if (td->td_priority < ctd->td_priority) {
+ ts = td_get_sched(ctd);
+ ts->ts_needs_resched = true;
+ }
}
/*
@@ -621,6 +640,8 @@
/* Account for thread0. */
sched_load_add();
+
+ ast_register(TDA_SCHED_PRIV, ASTR_UNCOND, 0, maybe_resched_ast);
}
/*
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -503,6 +503,7 @@
TDA_SIGSUSPEND,
TDA_MOD3, /* .. and after */
TDA_MOD4,
+ TDA_SCHED_PRIV,
TDA_MAX,
};
#define TDAI(tda) (1U << (tda))
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -188,6 +188,8 @@
curthread->td_pinned--;
}
+void ast_scheduler(struct thread *td, int tda);
+
/* sched_add arguments (formerly setrunqueue) */
#define SRQ_BORING 0x0000 /* No special circumstances. */
#define SRQ_YIELDING 0x0001 /* We are yielding (from mi_switch). */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 2, 12:57 PM (9 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37959259
Default Alt Text
D54945.id170735.diff (2 KB)
Attached To
Mode
D54945: SCHED_4BSD: maybe_resched() cannot schedule ast() for curthread
Attached
Detach File
Event Timeline
Log In to Comment