mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd::ctx: Add nice/ionice values to context.
This commit is contained in:
parent
68a56374e3
commit
78d300b3b7
4 changed files with 46 additions and 0 deletions
|
@ -50,6 +50,8 @@ namespace ircd::ctx
|
||||||
const int32_t ¬es(const ctx &) noexcept; // Peeks at internal semaphore count
|
const int32_t ¬es(const ctx &) noexcept; // Peeks at internal semaphore count
|
||||||
const uint64_t &epoch(const ctx &) noexcept; // Context switching counter
|
const uint64_t &epoch(const ctx &) noexcept; // Context switching counter
|
||||||
const ulong &cycles(const ctx &) noexcept; // Accumulated tsc (not counting cur slice)
|
const ulong &cycles(const ctx &) noexcept; // Accumulated tsc (not counting cur slice)
|
||||||
|
const int8_t &ionice(const ctx &) noexcept; // IO priority nice-value
|
||||||
|
const int8_t &nice(const ctx &) noexcept; // Scheduling priority nice-value
|
||||||
bool interruptible(const ctx &) noexcept; // Context can throw at interruption point
|
bool interruptible(const ctx &) noexcept; // Context can throw at interruption point
|
||||||
bool interruption(const ctx &) noexcept; // Context was marked for interruption
|
bool interruption(const ctx &) noexcept; // Context was marked for interruption
|
||||||
bool termination(const ctx &) noexcept; // Context was marked for termination
|
bool termination(const ctx &) noexcept; // Context was marked for termination
|
||||||
|
@ -59,6 +61,8 @@ namespace ircd::ctx
|
||||||
bool waiting(const ctx &) noexcept; // started() && !finished() && !running()
|
bool waiting(const ctx &) noexcept; // started() && !finished() && !running()
|
||||||
bool queued(const ctx &) noexcept; // !running() && notes() > 0
|
bool queued(const ctx &) noexcept; // !running() && notes() > 0
|
||||||
|
|
||||||
|
int8_t ionice(ctx &, const int8_t &); // IO priority nice-value
|
||||||
|
int8_t nice(ctx &, const int8_t &); // Scheduling priority nice-value
|
||||||
void interruptible(ctx &, const bool &); // False for interrupt suppression.
|
void interruptible(ctx &, const bool &); // False for interrupt suppression.
|
||||||
void interrupt(ctx &); // Interrupt the context.
|
void interrupt(ctx &); // Interrupt the context.
|
||||||
void terminate(ctx &); // Interrupt for termination.
|
void terminate(ctx &); // Interrupt for termination.
|
||||||
|
|
34
ircd/ctx.cc
34
ircd/ctx.cc
|
@ -512,6 +512,22 @@ ircd::ctx::interruptible(ctx &ctx,
|
||||||
ctx.flags |= context::NOINTERRUPT;
|
ctx.flags |= context::NOINTERRUPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t
|
||||||
|
ircd::ctx::nice(ctx &ctx,
|
||||||
|
const int8_t &val)
|
||||||
|
{
|
||||||
|
ctx.nice = val;
|
||||||
|
return ctx.nice;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t
|
||||||
|
ircd::ctx::ionice(ctx &ctx,
|
||||||
|
const int8_t &val)
|
||||||
|
{
|
||||||
|
ctx.ionice = val;
|
||||||
|
return ctx.ionice;
|
||||||
|
}
|
||||||
|
|
||||||
/// !running() && notes > 0
|
/// !running() && notes > 0
|
||||||
[[gnu::hot]]
|
[[gnu::hot]]
|
||||||
bool
|
bool
|
||||||
|
@ -593,6 +609,24 @@ noexcept
|
||||||
return prof::get(ctx, prof::event::CYCLES);
|
return prof::get(ctx, prof::event::CYCLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the IO priority nice-value
|
||||||
|
[[gnu::hot]]
|
||||||
|
const int8_t &
|
||||||
|
ircd::ctx::ionice(const ctx &ctx)
|
||||||
|
noexcept
|
||||||
|
{
|
||||||
|
return ctx.ionice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the context scheduling priority nice-value
|
||||||
|
[[gnu::hot]]
|
||||||
|
const int8_t &
|
||||||
|
ircd::ctx::nice(const ctx &ctx)
|
||||||
|
noexcept
|
||||||
|
{
|
||||||
|
return ctx.nice;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the yield count for `ctx`
|
/// Returns the yield count for `ctx`
|
||||||
[[gnu::hot]]
|
[[gnu::hot]]
|
||||||
const uint64_t &
|
const uint64_t &
|
||||||
|
|
|
@ -52,6 +52,8 @@ struct ircd::ctx::ctx
|
||||||
uint64_t id {++id_ctr}; // Unique runtime ID
|
uint64_t id {++id_ctr}; // Unique runtime ID
|
||||||
string_view name; // User given name (optional)
|
string_view name; // User given name (optional)
|
||||||
context::flags flags; // User given flags
|
context::flags flags; // User given flags
|
||||||
|
int8_t nice {0}; // Scheduling priority nice-value
|
||||||
|
int8_t ionice {0}; // IO priority nice-value (defaults for fs::opts)
|
||||||
int32_t notes {0}; // norm: 0 = asleep; 1 = awake; inc by others; dec by self
|
int32_t notes {0}; // norm: 0 = asleep; 1 = awake; inc by others; dec by self
|
||||||
boost::asio::io_service::strand strand; // mutex/serializer
|
boost::asio::io_service::strand strand; // mutex/serializer
|
||||||
boost::asio::deadline_timer alarm; // acting semaphore (64B)
|
boost::asio::deadline_timer alarm; // acting semaphore (64B)
|
||||||
|
|
|
@ -3987,6 +3987,8 @@ ircd::db::database::env::state::pool::pool(database &d,
|
||||||
{
|
{
|
||||||
pri == Priority::HIGH?
|
pri == Priority::HIGH?
|
||||||
IOPriority::IO_HIGH:
|
IOPriority::IO_HIGH:
|
||||||
|
pri == Priority::BOTTOM?
|
||||||
|
IOPriority::IO_LOW:
|
||||||
IOPriority::IO_LOW
|
IOPriority::IO_LOW
|
||||||
}
|
}
|
||||||
,name
|
,name
|
||||||
|
@ -4002,6 +4004,10 @@ ircd::db::database::env::state::pool::pool(database &d,
|
||||||
0, // initial workers
|
0, // initial workers
|
||||||
-1, // queue hard limit
|
-1, // queue hard limit
|
||||||
-1, // queue soft limit
|
-1, // queue soft limit
|
||||||
|
true, // queue_max_blocking
|
||||||
|
true, // queue_max_dwarning
|
||||||
|
make_nice(iopri), // ionice
|
||||||
|
make_nice(this->pri), // nice
|
||||||
}
|
}
|
||||||
,p
|
,p
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue