Commit c52c17a8 authored by Guan Jing's avatar Guan Jing Committed by Xia Fukun
Browse files

sched: Add tracepoint for qos smt expeller

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8O3MY


CVE: NA

--------------------------------

There are two caces that we add tracepoint:
a) while online task of sibling cpu is running, it is running
that offline task of local cpu will be set TIF_NEED_RESCHED;
b) while online task of sibling cpu is running, it will expell
that next picked offline task of local cpu.

Signed-off-by: default avatarGuan Jing <guanjing6@huawei.com>
Signed-off-by: default avatarXia Fukun <xiafukun@huawei.com>
parent 8219143b
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -268,6 +268,61 @@ TRACE_EVENT(sched_switch,
		__entry->next_comm, __entry->next_pid, __entry->next_prio)
);

#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER
/*
 * Tracepoint for a offline task being resched:
 */
TRACE_EVENT(sched_qos_smt_expel,

	TP_PROTO(struct task_struct *sibling_p, int qos_smt_status),

	TP_ARGS(sibling_p, qos_smt_status),

	TP_STRUCT__entry(
		__array(	char,	sibling_comm,	TASK_COMM_LEN	)
		__field(	pid_t,	sibling_pid			)
		__field(	int,	sibling_qos_status		)
		__field(	int,	sibling_cpu			)
	),

	TP_fast_assign(
		memcpy(__entry->sibling_comm, sibling_p->comm, TASK_COMM_LEN);
		__entry->sibling_pid		= sibling_p->pid;
		__entry->sibling_qos_status	= qos_smt_status;
		__entry->sibling_cpu		= task_cpu(sibling_p);
	),

	TP_printk("sibling_comm=%s sibling_pid=%d sibling_qos_status=%d sibling_cpu=%d",
		  __entry->sibling_comm, __entry->sibling_pid, __entry->sibling_qos_status,
		  __entry->sibling_cpu)
);

/*
 * Tracepoint for a offline task being expelled:
 */
TRACE_EVENT(sched_qos_smt_expelled,

	TP_PROTO(struct task_struct *p, int qos_smt_status),

	TP_ARGS(p, qos_smt_status),

	TP_STRUCT__entry(
		__array(	char,	comm,	TASK_COMM_LEN	)
		__field(	pid_t,	pid			)
		__field(	int,	qos_status		)
	),

	TP_fast_assign(
		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
		__entry->pid		= p->pid;
		__entry->qos_status	= qos_smt_status;
	),

	TP_printk("comm=%s pid=%d qos_status=%d",
		  __entry->comm, __entry->pid, __entry->qos_status)
);
#endif

/*
 * Tracepoint for a task being migrated:
 */
+7 −2
Original line number Diff line number Diff line
@@ -9001,13 +9001,17 @@ static bool _qos_smt_check_need_resched(int this_cpu, struct rq *rq)
		*    and current cpu only has SCHED_IDLE tasks enqueued.
		*/
		if (per_cpu(qos_smt_status, cpu) == QOS_LEVEL_ONLINE &&
		    task_group(current)->qos_level < QOS_LEVEL_ONLINE)
		    task_group(current)->qos_level < QOS_LEVEL_ONLINE) {
			trace_sched_qos_smt_expel(cpu_curr(cpu), per_cpu(qos_smt_status, cpu));
			return true;
		}

		if (per_cpu(qos_smt_status, cpu) == QOS_LEVEL_OFFLINE &&
		    rq->curr == rq->idle && sched_idle_cpu(this_cpu))
		    rq->curr == rq->idle && sched_idle_cpu(this_cpu)) {
			trace_sched_qos_smt_expel(cpu_curr(cpu), per_cpu(qos_smt_status, cpu));
			return true;
		}
	}

	return false;
}
@@ -9077,6 +9081,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
	if (qos_smt_expelled(this_cpu)) {
		__this_cpu_write(qos_smt_status, QOS_LEVEL_OFFLINE);
		schedstat_inc(rq->curr->stats.nr_qos_smt_expelled);
		trace_sched_qos_smt_expelled(rq->curr, per_cpu(qos_smt_status, this_cpu));
		return NULL;
	}
#endif