mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-07 00:00:09 +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(
|
||||
tokio_unstable,
|
||||
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]
|
||||
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(
|
||||
tokio_unstable,
|
||||
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() {
|
||||
println!("task dumps are not available")
|
||||
|
||||
+7
-2
@@ -488,12 +488,17 @@ compile_error!("The `taskdump` feature requires `--cfg tokio_unstable`.");
|
||||
not(doc),
|
||||
not(all(
|
||||
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!(
|
||||
"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.
|
||||
|
||||
@@ -517,7 +517,8 @@ macro_rules! cfg_taskdump {
|
||||
any(
|
||||
target_arch = "aarch64",
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64"
|
||||
target_arch = "x86_64",
|
||||
target_arch = "s390x"
|
||||
)
|
||||
))]
|
||||
#[cfg_attr(
|
||||
@@ -530,7 +531,8 @@ macro_rules! cfg_taskdump {
|
||||
any(
|
||||
target_arch = "aarch64",
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64"
|
||||
target_arch = "x86_64",
|
||||
target_arch = "s390x"
|
||||
)
|
||||
)))
|
||||
)]
|
||||
@@ -550,7 +552,8 @@ macro_rules! cfg_not_taskdump {
|
||||
any(
|
||||
target_arch = "aarch64",
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64"
|
||||
target_arch = "x86_64",
|
||||
target_arch = "s390x"
|
||||
)
|
||||
)))]
|
||||
$item
|
||||
|
||||
@@ -69,7 +69,12 @@ struct Context {
|
||||
feature = "taskdump",
|
||||
feature = "rt",
|
||||
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,
|
||||
}
|
||||
@@ -113,7 +118,8 @@ tokio_thread_local! {
|
||||
any(
|
||||
target_arch = "aarch64",
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64"
|
||||
target_arch = "x86_64",
|
||||
target_arch = "s390x"
|
||||
)
|
||||
))]
|
||||
trace: trace::Context::new(),
|
||||
|
||||
@@ -355,7 +355,12 @@ impl Handle {
|
||||
feature = "taskdump",
|
||||
feature = "rt",
|
||||
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);
|
||||
|
||||
@@ -382,7 +387,12 @@ impl Handle {
|
||||
feature = "taskdump",
|
||||
feature = "rt",
|
||||
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);
|
||||
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
||||
@@ -411,7 +421,12 @@ impl Handle {
|
||||
feature = "taskdump",
|
||||
feature = "rt",
|
||||
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);
|
||||
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
||||
@@ -597,7 +612,7 @@ cfg_taskdump! {
|
||||
///
|
||||
/// ## 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
|
||||
///
|
||||
|
||||
@@ -234,7 +234,12 @@ impl LocalRuntime {
|
||||
feature = "taskdump",
|
||||
feature = "rt",
|
||||
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);
|
||||
|
||||
|
||||
@@ -353,7 +353,12 @@ impl Runtime {
|
||||
feature = "taskdump",
|
||||
feature = "rt",
|
||||
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);
|
||||
|
||||
|
||||
@@ -533,7 +533,12 @@ impl Handle {
|
||||
tokio_unstable,
|
||||
feature = "taskdump",
|
||||
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 {
|
||||
use crate::runtime::dump;
|
||||
|
||||
@@ -400,15 +400,10 @@ impl<S: 'static> Task<S> {
|
||||
unsafe { Task::new(RawTask::from_raw(ptr)) }
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
tokio_unstable,
|
||||
feature = "taskdump",
|
||||
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
|
||||
cfg_taskdump! {
|
||||
pub(super) fn as_raw(&self) -> RawTask {
|
||||
self.raw
|
||||
}
|
||||
}
|
||||
|
||||
fn header(&self) -> &Header {
|
||||
@@ -510,18 +505,13 @@ impl<S: Schedule> LocalNotified<S> {
|
||||
raw.poll();
|
||||
}
|
||||
|
||||
/// Returns a `WakerRef` borrowing from this task.
|
||||
///
|
||||
/// `WakerRef` derefs to `Waker` without bumping the task's refcount.
|
||||
#[cfg(all(
|
||||
tokio_unstable,
|
||||
feature = "taskdump",
|
||||
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())
|
||||
cfg_taskdump! {
|
||||
/// Returns a `WakerRef` borrowing from this task.
|
||||
///
|
||||
/// `WakerRef` derefs to `Waker` without bumping the task's refcount.
|
||||
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
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
tokio_unstable,
|
||||
feature = "taskdump",
|
||||
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
|
||||
cfg_taskdump! {
|
||||
pub(super) fn header_ptr_ref(&self) -> &NonNull<Header> {
|
||||
&self.ptr
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn trailer_ptr(&self) -> NonNull<Trailer> {
|
||||
|
||||
@@ -277,28 +277,23 @@ impl State {
|
||||
})
|
||||
}
|
||||
|
||||
/// Transitions the state to `NOTIFIED`, unconditionally increasing the ref
|
||||
/// count.
|
||||
///
|
||||
/// Returns `true` if the notified bit was transitioned from `0` to `1`;
|
||||
/// otherwise `false.`
|
||||
#[cfg(all(
|
||||
tokio_unstable,
|
||||
feature = "taskdump",
|
||||
feature = "rt",
|
||||
target_os = "linux",
|
||||
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
|
||||
))]
|
||||
pub(super) fn transition_to_notified_for_tracing(&self) -> bool {
|
||||
self.fetch_update_action(|mut snapshot| {
|
||||
if snapshot.is_notified() {
|
||||
(false, None)
|
||||
} else {
|
||||
snapshot.set_notified();
|
||||
snapshot.ref_inc();
|
||||
(true, Some(snapshot))
|
||||
}
|
||||
})
|
||||
cfg_taskdump! {
|
||||
/// Transitions the state to `NOTIFIED`, unconditionally increasing the ref
|
||||
/// count.
|
||||
///
|
||||
/// Returns `true` if the notified bit was transitioned from `0` to `1`;
|
||||
/// otherwise `false.`
|
||||
pub(super) fn transition_to_notified_for_tracing(&self) -> bool {
|
||||
self.fetch_update_action(|mut 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.
|
||||
|
||||
@@ -431,7 +431,8 @@ cfg_rt! {
|
||||
any(
|
||||
target_arch = "aarch64",
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64"
|
||||
target_arch = "x86_64",
|
||||
target_arch = "s390x"
|
||||
)
|
||||
))]
|
||||
let future = task::trace::Trace::root(future);
|
||||
|
||||
@@ -200,7 +200,8 @@ cfg_rt! {
|
||||
any(
|
||||
target_arch = "aarch64",
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64"
|
||||
target_arch = "x86_64",
|
||||
target_arch = "s390x"
|
||||
)
|
||||
))]
|
||||
let future = task::trace::Trace::root(future);
|
||||
|
||||
+6
-1
@@ -2,7 +2,12 @@
|
||||
tokio_unstable,
|
||||
feature = "taskdump",
|
||||
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;
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
tokio_unstable,
|
||||
feature = "taskdump",
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user