mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-09 00:00:08 +02:00
taskdump: support taskdumps on s390x (#8192)
Signed-off-by: satyamg1620 <[email protected]>
This commit is contained in:
+12
-2
@@ -5,7 +5,12 @@
|
|||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
tokio_unstable,
|
tokio_unstable,
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
@@ -82,7 +87,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
#[cfg(not(all(
|
#[cfg(not(all(
|
||||||
tokio_unstable,
|
tokio_unstable,
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
)))]
|
)))]
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("task dumps are not available")
|
println!("task dumps are not available")
|
||||||
|
|||||||
+7
-2
@@ -488,12 +488,17 @@ compile_error!("The `taskdump` feature requires `--cfg tokio_unstable`.");
|
|||||||
not(doc),
|
not(doc),
|
||||||
not(all(
|
not(all(
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))
|
))
|
||||||
))]
|
))]
|
||||||
compile_error!(
|
compile_error!(
|
||||||
"The `taskdump` feature is only currently supported on \
|
"The `taskdump` feature is only currently supported on \
|
||||||
linux, on `aarch64`, `x86` and `x86_64`."
|
linux, on `aarch64`, `x86`, `x86_64` and `s390x`."
|
||||||
);
|
);
|
||||||
|
|
||||||
// Includes re-exports used by macros.
|
// Includes re-exports used by macros.
|
||||||
|
|||||||
@@ -517,7 +517,8 @@ macro_rules! cfg_taskdump {
|
|||||||
any(
|
any(
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
target_arch = "x86",
|
target_arch = "x86",
|
||||||
target_arch = "x86_64"
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
)
|
)
|
||||||
))]
|
))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
@@ -530,7 +531,8 @@ macro_rules! cfg_taskdump {
|
|||||||
any(
|
any(
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
target_arch = "x86",
|
target_arch = "x86",
|
||||||
target_arch = "x86_64"
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
)
|
)
|
||||||
)))
|
)))
|
||||||
)]
|
)]
|
||||||
@@ -550,7 +552,8 @@ macro_rules! cfg_not_taskdump {
|
|||||||
any(
|
any(
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
target_arch = "x86",
|
target_arch = "x86",
|
||||||
target_arch = "x86_64"
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
)
|
)
|
||||||
)))]
|
)))]
|
||||||
$item
|
$item
|
||||||
|
|||||||
@@ -69,7 +69,12 @@ struct Context {
|
|||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
feature = "rt",
|
feature = "rt",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
trace: trace::Context,
|
trace: trace::Context,
|
||||||
}
|
}
|
||||||
@@ -113,7 +118,8 @@ tokio_thread_local! {
|
|||||||
any(
|
any(
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
target_arch = "x86",
|
target_arch = "x86",
|
||||||
target_arch = "x86_64"
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
)
|
)
|
||||||
))]
|
))]
|
||||||
trace: trace::Context::new(),
|
trace: trace::Context::new(),
|
||||||
|
|||||||
@@ -355,7 +355,12 @@ impl Handle {
|
|||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
feature = "rt",
|
feature = "rt",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
let future = super::task::trace::Trace::root(future);
|
let future = super::task::trace::Trace::root(future);
|
||||||
|
|
||||||
@@ -382,7 +387,12 @@ impl Handle {
|
|||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
feature = "rt",
|
feature = "rt",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
let future = super::task::trace::Trace::root(future);
|
let future = super::task::trace::Trace::root(future);
|
||||||
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
||||||
@@ -411,7 +421,12 @@ impl Handle {
|
|||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
feature = "rt",
|
feature = "rt",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
let future = super::task::trace::Trace::root(future);
|
let future = super::task::trace::Trace::root(future);
|
||||||
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
||||||
@@ -597,7 +612,7 @@ cfg_taskdump! {
|
|||||||
///
|
///
|
||||||
/// ## Platform Requirements
|
/// ## Platform Requirements
|
||||||
///
|
///
|
||||||
/// Task dumps are supported on Linux atop `aarch64`, `x86` and `x86_64`.
|
/// Task dumps are supported on Linux atop `aarch64`, `x86`, `x86_64` and `s390x`.
|
||||||
///
|
///
|
||||||
/// ## Current Thread Runtime Requirements
|
/// ## Current Thread Runtime Requirements
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -234,7 +234,12 @@ impl LocalRuntime {
|
|||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
feature = "rt",
|
feature = "rt",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
let future = crate::runtime::task::trace::Trace::root(future);
|
let future = crate::runtime::task::trace::Trace::root(future);
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,12 @@ impl Runtime {
|
|||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
feature = "rt",
|
feature = "rt",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
let future = super::task::trace::Trace::root(future);
|
let future = super::task::trace::Trace::root(future);
|
||||||
|
|
||||||
|
|||||||
@@ -533,7 +533,12 @@ impl Handle {
|
|||||||
tokio_unstable,
|
tokio_unstable,
|
||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
pub(crate) fn dump(&self) -> crate::runtime::Dump {
|
pub(crate) fn dump(&self) -> crate::runtime::Dump {
|
||||||
use crate::runtime::dump;
|
use crate::runtime::dump;
|
||||||
|
|||||||
@@ -400,15 +400,10 @@ impl<S: 'static> Task<S> {
|
|||||||
unsafe { Task::new(RawTask::from_raw(ptr)) }
|
unsafe { Task::new(RawTask::from_raw(ptr)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
cfg_taskdump! {
|
||||||
tokio_unstable,
|
pub(super) fn as_raw(&self) -> RawTask {
|
||||||
feature = "taskdump",
|
self.raw
|
||||||
feature = "rt",
|
}
|
||||||
target_os = "linux",
|
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
|
||||||
))]
|
|
||||||
pub(super) fn as_raw(&self) -> RawTask {
|
|
||||||
self.raw
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn header(&self) -> &Header {
|
fn header(&self) -> &Header {
|
||||||
@@ -510,18 +505,13 @@ impl<S: Schedule> LocalNotified<S> {
|
|||||||
raw.poll();
|
raw.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a `WakerRef` borrowing from this task.
|
cfg_taskdump! {
|
||||||
///
|
/// Returns a `WakerRef` borrowing from this task.
|
||||||
/// `WakerRef` derefs to `Waker` without bumping the task's refcount.
|
///
|
||||||
#[cfg(all(
|
/// `WakerRef` derefs to `Waker` without bumping the task's refcount.
|
||||||
tokio_unstable,
|
pub(crate) fn waker_ref(&self) -> waker::WakerRef<'_, S> {
|
||||||
feature = "taskdump",
|
waker::waker_ref::<S>(self.task.raw.header_ptr_ref())
|
||||||
feature = "rt",
|
}
|
||||||
target_os = "linux",
|
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
|
||||||
))]
|
|
||||||
pub(crate) fn waker_ref(&self) -> waker::WakerRef<'_, S> {
|
|
||||||
waker::waker_ref::<S>(self.task.raw.header_ptr_ref())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -242,15 +242,10 @@ impl RawTask {
|
|||||||
self.ptr
|
self.ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
cfg_taskdump! {
|
||||||
tokio_unstable,
|
pub(super) fn header_ptr_ref(&self) -> &NonNull<Header> {
|
||||||
feature = "taskdump",
|
&self.ptr
|
||||||
feature = "rt",
|
}
|
||||||
target_os = "linux",
|
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
|
||||||
))]
|
|
||||||
pub(super) fn header_ptr_ref(&self) -> &NonNull<Header> {
|
|
||||||
&self.ptr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn trailer_ptr(&self) -> NonNull<Trailer> {
|
pub(super) fn trailer_ptr(&self) -> NonNull<Trailer> {
|
||||||
|
|||||||
@@ -277,28 +277,23 @@ impl State {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transitions the state to `NOTIFIED`, unconditionally increasing the ref
|
cfg_taskdump! {
|
||||||
/// count.
|
/// Transitions the state to `NOTIFIED`, unconditionally increasing the ref
|
||||||
///
|
/// count.
|
||||||
/// Returns `true` if the notified bit was transitioned from `0` to `1`;
|
///
|
||||||
/// otherwise `false.`
|
/// Returns `true` if the notified bit was transitioned from `0` to `1`;
|
||||||
#[cfg(all(
|
/// otherwise `false.`
|
||||||
tokio_unstable,
|
pub(super) fn transition_to_notified_for_tracing(&self) -> bool {
|
||||||
feature = "taskdump",
|
self.fetch_update_action(|mut snapshot| {
|
||||||
feature = "rt",
|
if snapshot.is_notified() {
|
||||||
target_os = "linux",
|
(false, None)
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
} else {
|
||||||
))]
|
snapshot.set_notified();
|
||||||
pub(super) fn transition_to_notified_for_tracing(&self) -> bool {
|
snapshot.ref_inc();
|
||||||
self.fetch_update_action(|mut snapshot| {
|
(true, Some(snapshot))
|
||||||
if snapshot.is_notified() {
|
}
|
||||||
(false, None)
|
})
|
||||||
} else {
|
}
|
||||||
snapshot.set_notified();
|
|
||||||
snapshot.ref_inc();
|
|
||||||
(true, Some(snapshot))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the cancelled bit and transitions the state to `NOTIFIED` if idle.
|
/// Sets the cancelled bit and transitions the state to `NOTIFIED` if idle.
|
||||||
|
|||||||
@@ -431,7 +431,8 @@ cfg_rt! {
|
|||||||
any(
|
any(
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
target_arch = "x86",
|
target_arch = "x86",
|
||||||
target_arch = "x86_64"
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
)
|
)
|
||||||
))]
|
))]
|
||||||
let future = task::trace::Trace::root(future);
|
let future = task::trace::Trace::root(future);
|
||||||
|
|||||||
@@ -200,7 +200,8 @@ cfg_rt! {
|
|||||||
any(
|
any(
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
target_arch = "x86",
|
target_arch = "x86",
|
||||||
target_arch = "x86_64"
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
)
|
)
|
||||||
))]
|
))]
|
||||||
let future = task::trace::Trace::root(future);
|
let future = task::trace::Trace::root(future);
|
||||||
|
|||||||
+6
-1
@@ -2,7 +2,12 @@
|
|||||||
tokio_unstable,
|
tokio_unstable,
|
||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
|
|
||||||
use std::hint::black_box;
|
use std::hint::black_box;
|
||||||
|
|||||||
@@ -3,7 +3,12 @@
|
|||||||
tokio_unstable,
|
tokio_unstable,
|
||||||
feature = "taskdump",
|
feature = "taskdump",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
any(
|
||||||
|
target_arch = "aarch64",
|
||||||
|
target_arch = "x86",
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_arch = "s390x"
|
||||||
|
)
|
||||||
))]
|
))]
|
||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|||||||
Reference in New Issue
Block a user