Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8741153rwd; Tue, 20 Jun 2023 20:46:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gNdwSLyZSfQog+m20b3zHYjtJfD6hv25An4kI/1M6wPna+n1DYnr9+OanX5yvoCkRvi8s X-Received: by 2002:a05:6a20:734a:b0:122:cb18:2e8c with SMTP id v10-20020a056a20734a00b00122cb182e8cmr4047457pzc.6.1687319202429; Tue, 20 Jun 2023 20:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687319202; cv=none; d=google.com; s=arc-20160816; b=To8oLdP5XyVoC/xeKx8tcQB7CVSK2rWBpSASQQX82w393hyLoIy4ETuIHqzH8NnISd 33/NvQKQUu7XZFwjEi22Yk3YoJvavCwtrxINDgw/Hy42QNh9KDPXlgdgjCpdCkkHZbi+ JZzGpJqtuoNj59+0CK3ociwwPZDqrykFLFTNX6Cmz89n30rcDMDAgQBrRHLLiJ9IGA30 M9wjwBcWTYQBUA5MI1icM7U5pi1WfhsB1uw3SKgy0Co8Azgdps4Q/yh1mZGn8peNiX4s 4SqopyaY6llDj74hdu+ssI83fjZsfSEYjh3esJ4nLoR6hO7NAvhqrBMJuLSoT106aLJr OwxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=DTUavU7hKrWgcNI8yo9PuaxVVskMEM0wGEpA7fOZABw=; b=gIzRt9hNlz3bvbkiZ8/T9bNrlIXfBJKsDcDJQCDhj1ViOk/9id5P/fOzhtSILTGddf zEOAHH9eD6BMwpXiLWT4m7N0WI7uaMAyzTz73QYHwoNV7b7GGvJyoi/aIm/V8bqXEBaa 9QXr3jK+IBgIWlbOwTJ2RwT9OEiGLp6nSIlY3lhvjnl7S+abIuB2ndHncB9Aamb2ZsmO 7Fai4u0056kCsa+iqZlJqVMSkEfRE5KCm8YSG+T+mDhJ0z4RBBMBd2yUB3qtNKc1Eruc fNUecTw1/dDS68Odn/P52ciFslMkud1i4RTZNS0xAwaBriGpripm/SK1I9ioGYM8ALeK /DSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A9yw8wR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020aa79d08000000b0066733d71d01si2990072pfp.317.2023.06.20.20.46.27; Tue, 20 Jun 2023 20:46:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A9yw8wR5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbjFUD1T (ORCPT + 99 others); Tue, 20 Jun 2023 23:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbjFUD0f (ORCPT ); Tue, 20 Jun 2023 23:26:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CAF7199C; Tue, 20 Jun 2023 20:25:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5B63D6145D; Wed, 21 Jun 2023 03:25:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E800C433C0; Wed, 21 Jun 2023 03:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687317918; bh=NGs11l/3B8YfeCe/z4oIs1N3Mm5E/col3XvNEFUUXn0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=A9yw8wR5gnNbP8vG+w1Ktt1f/FkaFUuyC2Seh1jsOkpYmmGwJFH8lgQ7I7G8Qn4Mn XL6xH5Ne75d8izn4HSWmrNlOdFBGAqIH8zIKdMjpmRlOLfs9vh08Dh3C5DUi+T1E+i 9kJu80fipHNPqIXfbbKEsFU7Wr+N+PBVbOPGfNTXC/OwQcRZB7QzJkwi+2/+PM0ART TD28FaVAqStqrTgUUx1GliFn+0vcB5t4/eeEMqgUUeQWEXybygBgM+z8bGCXzVJrIG 7X+KNCM8c+zqKavirD9ZL+uoc4o5XvWgy69IK+gcHDesZXLR8207zoHuqR3bcCQZw5 3dRW4J/tJGbyg== Date: Wed, 21 Jun 2023 12:25:13 +0900 From: Masami Hiramatsu (Google) To: Qais Yousef Cc: Lukasz Luba , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, rafael@kernel.org, linux-pm@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, delyank@fb.com, qyousef@google.com Subject: Re: [RESEND][PATCH v2 1/3] sched/tp: Add new tracepoint to track uclamp set from user-space Message-Id: <20230621122513.2aa3bc0d29321197e3d38441@kernel.org> In-Reply-To: <20230531182629.nztie5rwhjl53v3d@airbuntu> References: <20230522145702.2419654-1-lukasz.luba@arm.com> <20230522145702.2419654-2-lukasz.luba@arm.com> <20230531182629.nztie5rwhjl53v3d@airbuntu> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 May 2023 19:26:29 +0100 Qais Yousef wrote: > On 05/22/23 15:57, Lukasz Luba wrote: > > The user-space can set uclamp value for a given task. It impacts task > > placement decisions made by the scheduler. This is very useful information > > and helps to understand the system behavior or track improvements in > > middleware and applications which start using uclamp mechanisms and report > > better performance in tests. > > Do you mind adding a generic one instead please? And explain why we can't just > attach to the syscall via kprobes? I think you want to bypass the permission > checks, so maybe a generic tracepoint after that might be justifiable? Could you tell me more about this point? I would like to know what kind of permission checks can be bypassed with tracepoints. > Then anyone can use it to track how userspace has changed any attributes for > a task, not just uclamp. I guess Uclamp is not controlled by syscall but from kernel internal sched_setattr/setscheduler() too. Anyway I agree that it can be more generic tracepoint, something like trace_sched_set_scheduer(task, attr). Thank you, > > > Thanks > > -- > Qais Yousef > > > > > Signed-off-by: Lukasz Luba > > --- > > include/trace/events/sched.h | 4 ++++ > > kernel/sched/core.c | 5 +++++ > > 2 files changed, 9 insertions(+) > > > > diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h > > index fbb99a61f714..dbfb30809f15 100644 > > --- a/include/trace/events/sched.h > > +++ b/include/trace/events/sched.h > > @@ -735,6 +735,10 @@ DECLARE_TRACE(sched_update_nr_running_tp, > > TP_PROTO(struct rq *rq, int change), > > TP_ARGS(rq, change)); > > > > +DECLARE_TRACE(uclamp_update_tsk_tp, > > + TP_PROTO(struct task_struct *tsk, int uclamp_id, unsigned int value), > > + TP_ARGS(tsk, uclamp_id, value)); > > + > > #endif /* _TRACE_SCHED_H */ > > > > /* This part must be outside protection */ > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index 944c3ae39861..7b9b800ebb6c 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -114,6 +114,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp); > > EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp); > > EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_se_tp); > > EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp); > > +EXPORT_TRACEPOINT_SYMBOL_GPL(uclamp_update_tsk_tp); > > > > DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); > > > > @@ -1956,12 +1957,16 @@ static void __setscheduler_uclamp(struct task_struct *p, > > attr->sched_util_min != -1) { > > uclamp_se_set(&p->uclamp_req[UCLAMP_MIN], > > attr->sched_util_min, true); > > + trace_uclamp_update_tsk_tp(p, UCLAMP_MIN, > > + attr->sched_util_min); > > } > > > > if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX && > > attr->sched_util_max != -1) { > > uclamp_se_set(&p->uclamp_req[UCLAMP_MAX], > > attr->sched_util_max, true); > > + trace_uclamp_update_tsk_tp(p, UCLAMP_MAX, > > + attr->sched_util_max); > > } > > } > > > > -- > > 2.25.1 > > -- Masami Hiramatsu (Google)