org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel;
x-friends:="org.eclipse.tracecompass.analysis.os.linux.core.tests,
org.eclipse.tracecompass.analysis.os.linux.ui,
- org.eclipse.tracecompass.lttng2.kernel.core.tests,
- org.eclipse.tracecompass.lttng2.kernel.core",
+ org.eclipse.tracecompass.lttng2.kernel.core.tests",
org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;x-friends:="org.eclipse.tracecompass.analysis.os.linux.core.tests",
org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics;x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui,org.eclipse.tracecompass.analysis.os.linux.core.tests"
* resolve to something that is not an event
*
* @param module
- * The lttng kernel analysis instance to run this method on
+ * The kernel analysis instance to run this method on
* @param cpuId
* The CPU number the process is running on
* @param ts
* Get the TIDs of the threads from an analysis
*
* @param module
- * The lttng kernel analysis instance to run this method on
+ * The kernel analysis instance to run this method on
* @return The set of TIDs corresponding to the threads
*/
public static Collection<Integer> getThreadIds(KernelAnalysisModule module) {
* Get the parent process ID of a thread
*
* @param module
- * The lttng kernel analysis instance to run this method on
+ * The kernel analysis instance to run this method on
* @param threadId
* The thread ID of the process for which to get the parent
* @param ts
* name the thread has taken, or {@code null} if no name is found
*
* @param module
- * The lttng kernel analysis instance to run this method on
+ * The kernel analysis instance to run this method on
* @param threadId
* The thread ID of the process for which to get the name
* @return The last executable name of this process, or {@code null} if not
return null;
}
+ /**
+ * Get the priority of this thread at time ts
+ *
+ * @param module
+ * The kernel analysis instance to run this method on
+ * @param threadId
+ * The ID of the thread to query
+ * @param ts
+ * The timestamp at which to query
+ * @return The priority of the thread or <code>-1</code> if not available
+ */
+ public static int getThreadPriority(KernelAnalysisModule module, int threadId, long ts) {
+ ITmfStateSystem ss = module.getStateSystem();
+ if (ss == null) {
+ return -1;
+ }
+ int prioQuark = ss.optQuarkAbsolute(Attributes.THREADS, String.valueOf(threadId), Attributes.PRIO);
+ if (prioQuark == ITmfStateSystem.INVALID_ATTRIBUTE) {
+ return -1;
+ }
+ try {
+ return ss.querySingleState(ts, prioQuark).getStateValue().unboxInt();
+ } catch (AttributeNotFoundException | StateSystemDisposedException e) {
+ return -1;
+ }
+ }
+
/**
* Get the status intervals for a given thread with a resolution
*
* @param module
- * The lttng kernel analysis instance to run this method on
+ * The kernel analysis instance to run this method on
* @param threadId
* The ID of the thread to get the intervals for
* @param start
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelThreadInformationProvider;
import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
import org.eclipse.tracecompass.common.core.NonNullUtils;
-import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
-import org.eclipse.tracecompass.internal.lttng2.kernel.core.Activator;
import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecGraphProvider.ProcessStatus;
-import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
-import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
-import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
-import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
@SuppressWarnings("null")
@Override
public @NonNull Map<@NonNull String, @NonNull String> getWorkerInformation(long t) {
+ int tid = fHostTid.getTid();
+ if (tid == -1) {
+ return Collections.EMPTY_MAP;
+ }
+ Optional<@Nullable KernelAnalysisModule> kam = TmfTraceManager.getInstance().getActiveTraceSet()
+ .stream()
+ .filter(trace -> trace.getHostId().equals(getHostId()))
+ .map(trace -> TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID))
+ .filter(mod -> mod != null)
+ .findFirst();
+ if (!kam.isPresent()) {
+ return Collections.EMPTY_MAP;
+ }
+ KernelAnalysisModule module = kam.get();
+
+ Map<String, String> info = new HashMap<>();
- try {
- int tid = fHostTid.getTid();
- if (tid == -1) {
- return Collections.EMPTY_MAP;
- }
- Optional<@Nullable KernelAnalysisModule> kam = TmfTraceManager.getInstance().getActiveTraceSet().stream()
- .filter(trace -> trace.getHostId().equals(getHostId()))
- .map(trace -> TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID))
- .filter(mod -> mod != null)
- .findFirst();
- if (!kam.isPresent()) {
- return Collections.EMPTY_MAP;
- }
- ITmfStateSystem ss = kam.get().getStateSystem();
- if (ss == null) {
- return Collections.EMPTY_MAP;
- }
- int quark;
- Map<String, String> info = new HashMap<>();
- quark = ss.getQuarkAbsolute(Attributes.THREADS, Integer.toString(tid), Attributes.PRIO);
- ITmfStateInterval interval = ss.querySingleState(t, quark);
- ITmfStateValue stateValue = interval.getStateValue();
- if (stateValue.getType().equals(ITmfStateValue.Type.INTEGER)) {
- info.put(NonNullUtils.nullToEmptyString(Messages.LttngWorker_threadPriority), Integer.toString(stateValue.unboxInt()));
- }
- return info;
- } catch (AttributeNotFoundException | StateSystemDisposedException e) {
- Activator.getDefault().logError(e.getMessage(), e);
+ int priority = KernelThreadInformationProvider.getThreadPriority(module, tid, t);
+ if (priority != -1) {
+ info.put(NonNullUtils.nullToEmptyString(Messages.LttngWorker_threadPriority), Integer.toString(priority));
}
- return Collections.EMPTY_MAP;
+ return info;
}
/**