Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2001976rdb; Mon, 9 Oct 2023 09:24:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYv1rxfgf9On/+It0zto4Bt/yCh3p5IDMx9Ygh1lSfwJ3PQtthj+q0fsYJKDlUMw0qkTKQ X-Received: by 2002:a05:6a20:158e:b0:16a:bcde:397d with SMTP id h14-20020a056a20158e00b0016abcde397dmr14453658pzj.22.1696868645073; Mon, 09 Oct 2023 09:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696868645; cv=none; d=google.com; s=arc-20160816; b=06BL55fMZroXlCjSdTwYw8rz7uTj4XHOTEL3aGPmXjEWPC+ma6qwIbwRCci7wvllIj W1bfeFAnnehMZeHDMSqU8mljSzddYaspun9JWBdUA4oVuHze8gx6QAvNnk5LdcjHg4vI 7BDGGXd2x/mll8u1PBY91SLBmzMsM/yfGI3HFt4glp4cuZ6SyTJU/0n5NK8NurljiE0c 3VyWOfVEA4Z4Jh8chykQrhmRgY+jGs8HMZNx/ooLXDC9gc9w919Ouyx3Qvd0FKCwCBtz CITclQ0a7s9M13DmMkK2625O1fpyvxtR5L0n0yaH9S5OPAHe/+IHf4XpdgyJloeeeR8t 9DEA== 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; bh=e2HyWk1WSwV1MRv7Cc1wh4+NfBWxQNJGFKnKQW4CTgk=; fh=w+vtYee8cuj0AkBdYyG5P9GAr4TpICeYQqfjFL+Ojx4=; b=B+MuK4zGrv2hK9KA59cf7u6NWZEz1ppn3SCldmxJY9f0yPeOq848ZN5JZ0GaB+8Kpt F4BHafaOto7LFAqMObcxofTu6BdkUhJTKLGfJSxQ5gBOeMqf0GCedqdJejJSdFF3CF4l S49Erg8yyaW6VTOD7GC5t9YrCxMuKU6G6FRj7WD2WoCRU9x2Itju1Rp2/+Ua2Y21xuhd u14SDB46ttx/f7cN2qTWVQ1BlyzFN194gU/XAbkOnWdol8jcEuXQ6DkXaECs1bjXXiEy hFGDGHuosWRoywxhIjgEB3R5001Ox9yk+EUQFq3tsxmjof7tKR3IJdxINldpFllFbumm Iopg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u69-20020a638548000000b00573fe49ad3esi9776602pgd.672.2023.10.09.09.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5491E80B4204; Mon, 9 Oct 2023 09:24:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377153AbjJIQXr (ORCPT + 99 others); Mon, 9 Oct 2023 12:23:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376889AbjJIQXq (ORCPT ); Mon, 9 Oct 2023 12:23:46 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C02A9AF for ; Mon, 9 Oct 2023 09:23:43 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66BDDC433C8; Mon, 9 Oct 2023 16:23:42 +0000 (UTC) Date: Mon, 9 Oct 2023 12:25:00 -0400 From: Steven Rostedt To: Jinyu Tang Cc: mhiramat@kernel.org, bristot@kernel.org, ttjjyystupid@163.com, falcon@tinylab.org, wangjiexun@tinylab.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] Ftrace: make sched_wakeup can focus on the target process Message-ID: <20231009122500.69854f94@gandalf.local.home> In-Reply-To: <20231009153714.10743-1-tangjinyu@tinylab.org> References: <20231009153714.10743-1-tangjinyu@tinylab.org> X-Mailer: Claws Mail 3.19.1 (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=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 09:24:01 -0700 (PDT) X-Spam-Level: ** On Mon, 9 Oct 2023 23:37:14 +0800 Jinyu Tang wrote: > When we want to know what happened in kernel when our app > has more latency than we hope, but the larger latency of > our app may be lower than other process in the syetem. > We feel sad after waiting a long time but only get other > process sched_wakeup trace. > > This Patch can let us only trace target process sched-wakeup > time, other process sched-wakeup will be dropped and won't > change tracing_max_latency. > > The patch is tested by the following commands: > > $ mount -t tracefs none /sys/kernel/tracing > $ echo wakeup_rt > /sys/kernel/tracing/current_tracer > # some other stress-ng options are also tested > $ stress-ng --cpu 4 & > $ cyclictest --mlockall --smp --priority=99 & > $ cyclictest_pid=$! > # child thread of cyclictest main process > $ thread_pid=$((cyclictest_pid + 1)) > > $ echo ${thread_pid} > /sys/kernel/tracing/set_wakeup_pid > > $ echo 1 > /sys/kernel/tracing/tracing_on > $ echo 0 > /sys/kernel/tracing/tracing_max_latency > $ wait ${cyclictest_pid} > $ echo 0 > /sys/kernel/tracing/tracing_on > $ cat /sys/kernel/tracing/trace > > The maximum latency and backtrace recorded in the trace file will be only > generated by the target process. > Then we can eliminate interference from other programs, making it easier > to identify the cause of latency. > > Tested-by: Jiexun Wang > Signed-off-by: Jinyu Tang > --- Honestly, the wakeup tracers are obsolete. I haven't used them in years. I use synthetic events instead: # cd /sys/kernel/tracing # echo 'wakeup_lat pid_t pid; u64 delay;' > synthetic_events # echo 'hist:keys=pid:ts=common_timestamp.usecs' if pid==$thread_pid > events/sched/sched_waking/trigger # echo 'hist:keys=next_pid:delta=common_timestamp.usecs-$ts:onmax($delta).trace(wakeup_lat,next_pid,$delta)' > events/sched/sched_switch/trigger # echo 1 > events/synthetic/wakeup_lat/enable # cat trace # tracer: nop # # entries-in-buffer/entries-written: 3/3 #P:8 # # _-----=> irqs-off/BH-disabled # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / _-=> migrate-disable # |||| / delay # TASK-PID CPU# ||||| TIMESTAMP FUNCTION # | | | ||||| | | -0 [000] d..4. 350799.423428: wakeup_lat: pid=59921 delay=1281 -0 [000] d..4. 350800.423441: wakeup_lat: pid=59921 delay=1317 -0 [000] d..4. 350801.423445: wakeup_lat: pid=59921 delay=1331 I could also make it record stack traces, disable tracing, and all sorts of other nifty things. -- Steve