diff --git a/examples/dump.rs b/examples/dump.rs index 2211e3ed4..b6821f1cb 100644 --- a/examples/dump.rs +++ b/examples/dump.rs @@ -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> { @@ -82,7 +87,12 @@ async fn main() -> Result<(), Box> { #[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") diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 51f1cfc34..50b273442 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -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. diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index efbd163c7..5ff5a934a 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -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 diff --git a/tokio/src/runtime/context.rs b/tokio/src/runtime/context.rs index 3bf991940..09034c60f 100644 --- a/tokio/src/runtime/context.rs +++ b/tokio/src/runtime/context.rs @@ -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(), diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs index 79fea39da..27706bac0 100644 --- a/tokio/src/runtime/handle.rs +++ b/tokio/src/runtime/handle.rs @@ -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 /// diff --git a/tokio/src/runtime/local_runtime/runtime.rs b/tokio/src/runtime/local_runtime/runtime.rs index 0d79f6f1d..41121622f 100644 --- a/tokio/src/runtime/local_runtime/runtime.rs +++ b/tokio/src/runtime/local_runtime/runtime.rs @@ -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); diff --git a/tokio/src/runtime/runtime.rs b/tokio/src/runtime/runtime.rs index b0091bc4b..7bd076c52 100644 --- a/tokio/src/runtime/runtime.rs +++ b/tokio/src/runtime/runtime.rs @@ -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); diff --git a/tokio/src/runtime/scheduler/current_thread/mod.rs b/tokio/src/runtime/scheduler/current_thread/mod.rs index f0b072d57..d97a2c89c 100644 --- a/tokio/src/runtime/scheduler/current_thread/mod.rs +++ b/tokio/src/runtime/scheduler/current_thread/mod.rs @@ -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; diff --git a/tokio/src/runtime/task/mod.rs b/tokio/src/runtime/task/mod.rs index 6f964c1de..82bebdbf7 100644 --- a/tokio/src/runtime/task/mod.rs +++ b/tokio/src/runtime/task/mod.rs @@ -400,15 +400,10 @@ impl Task { 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 LocalNotified { 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::(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::(self.task.raw.header_ptr_ref()) + } } } diff --git a/tokio/src/runtime/task/raw.rs b/tokio/src/runtime/task/raw.rs index a9d143f74..7d423aeea 100644 --- a/tokio/src/runtime/task/raw.rs +++ b/tokio/src/runtime/task/raw.rs @@ -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
{ - &self.ptr + cfg_taskdump! { + pub(super) fn header_ptr_ref(&self) -> &NonNull
{ + &self.ptr + } } pub(super) fn trailer_ptr(&self) -> NonNull { diff --git a/tokio/src/runtime/task/state.rs b/tokio/src/runtime/task/state.rs index 942d96539..032088224 100644 --- a/tokio/src/runtime/task/state.rs +++ b/tokio/src/runtime/task/state.rs @@ -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. diff --git a/tokio/src/task/local.rs b/tokio/src/task/local.rs index cf75097a8..fe0b2f5aa 100644 --- a/tokio/src/task/local.rs +++ b/tokio/src/task/local.rs @@ -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); diff --git a/tokio/src/task/spawn.rs b/tokio/src/task/spawn.rs index cd26c6d76..149665a4d 100644 --- a/tokio/src/task/spawn.rs +++ b/tokio/src/task/spawn.rs @@ -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); diff --git a/tokio/tests/dump.rs b/tokio/tests/dump.rs index 56aab8f2b..e9d095652 100644 --- a/tokio/tests/dump.rs +++ b/tokio/tests/dump.rs @@ -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; diff --git a/tokio/tests/task_trace_self.rs b/tokio/tests/task_trace_self.rs index 6553a0a1f..723088ab2 100644 --- a/tokio/tests/task_trace_self.rs +++ b/tokio/tests/task_trace_self.rs @@ -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;