Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp617599iof; Mon, 6 Jun 2022 09:27:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBO1poihjttr9cpxl2ddJCIrwuI1jLH6+FDHk6lQgsmZdU3fcxTABlu05XBT4UCvPTzj9V X-Received: by 2002:a17:90b:180b:b0:1e3:25f6:6475 with SMTP id lw11-20020a17090b180b00b001e325f66475mr40255090pjb.208.1654532846503; Mon, 06 Jun 2022 09:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654532846; cv=none; d=google.com; s=arc-20160816; b=YmNicRXk5z4QNktjc0+jwh8NIA8m8C5LF9KslPADo5Njhuh0fLx6NLfUqj2Tn4X5Ns 8grdomEzc3RjeradZE99SIpcnEnmMMQkIO4fMHLxZ1osyeidGMJMhLM4wOFjG/EGzA1W n70QeOiZnISCxk6tVfw2bZdIiIL+ZwZB305mQjQji1z/CVeLm/uItGhIxSTIOSqB+sgg gL8RIp6hwuzMumpbnc9R7l8+RDfttJrcvccCmCDYvNIV93er8DrIyLRUOCCmJtyei9KG 22uPpxLAzZGYtuQtChcFTC2R+Cuxk2Z2men+UrHph63hT0gw12M0kfPrEiw5mggVj8iE d+ow== 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:date:subject:cc:to:from :dkim-signature; bh=DekJ8UcrLNS24H0kwzTpTKU7qq2O3Iea6VLoLOi4nfQ=; b=E5oZFAzAeFBa6N/bAYPeUp5T/KBPiXpK4wMk2oA210T8l70gHV9aW9216DWZ67unf8 /I8Qvw2yLF6WYn4VCqZnVvJtLv4jD2DiOy8WXfVlGE74cxD25EHyhA2xmYmYAG0aaom/ T3LUaV3wfNs5AQgbOICf4LcK6pnof/U60ggfb6L3yhp6oblbLv7vkpEQcFAmRD4rXJVa SnkjNRwMaZesNl7FMNe9t1//JI/uRcXJBgrGbcmISsNfUvU7KHtPIOlG3rumvrRq++nn RwFL6j7aaFvE3Ao0zJpz6RLChPSD8YpkqjgPuaAzdh5EiT+dJYqLSOJ8Kk8DzfbMWuOu yS4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bu7wWVYc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s3-20020a632c03000000b003fbe6ace027si21736448pgs.806.2022.06.06.09.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 09:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bu7wWVYc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B3C691B176B; Mon, 6 Jun 2022 09:11:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241363AbiFFQKu (ORCPT + 99 others); Mon, 6 Jun 2022 12:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241540AbiFFQKc (ORCPT ); Mon, 6 Jun 2022 12:10:32 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C38B1A883A for ; Mon, 6 Jun 2022 09:10:29 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id e66so13248220pgc.8 for ; Mon, 06 Jun 2022 09:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DekJ8UcrLNS24H0kwzTpTKU7qq2O3Iea6VLoLOi4nfQ=; b=bu7wWVYcjOQSQKi7SnHoL6sjJYrgSy5K6UTaS9kEaKOBgryxcpCZA3X5eS0O4BKlik ByFF3pCxvbLwZyp/GtyO0Q4AmCHVQjIxoUBS3DxvUfKj91nHUTdusGjHjmWA7Spri52b qV9Qfq+AGWHZhBbb1tiTKQfWfCKQP/ySwuCH1Q9ATGafdVP3jj8v16bYdJRBydDEHJOF ET36U4byA4rpxPUP7WLM2bxYeMEDvKN8eceHoIAkgAr5HFzq7bLKS05vq7W34Vqt8kG+ dt5rM7wg6vSNTLFM8xiaU4olJuxt6ArHHCJ+py/wBeJ+ra6T1bSBd9jKA1UTvFSR51SE i1hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DekJ8UcrLNS24H0kwzTpTKU7qq2O3Iea6VLoLOi4nfQ=; b=6xrQ+XjQIDylAOj+F30heoWDsjIGjJ8TFZRzT1TBhtuePgkSHiHh5QsYkiJxfet4ZS enj5WAezCMyc49A8qhbZOT9ufyiZlFhOjIZHH/WACSBABuXiADAoElDdP90w+dMqg7ti RVzBUp4ZLSpXseE0fImgKULaZkpau928+F5+YR41UqsJfbaKPi4pTaFifEYzE2To1tgh zXMuJqdfMmA5Z70Te58poX2coGGDX8RuzBqJqJvD/yvjKHrJ7jzuVrNmaHT93JMzRgyw 3Ud6H0h6rLnhkM4LCdZfhIMgJKGnw0OApzqZqP+hvA4p/kZ2QNb3hu7Rc1sk5P9yXhUM cjoQ== X-Gm-Message-State: AOAM532U2BC/X07yNx8mjeSuKgBGwx//Ys8QCWlbxtOdL0xrpj8RUvV8 3SdRQ/nwHifNTLjVRIEMyUg= X-Received: by 2002:a63:90c1:0:b0:3fc:7de1:b2b9 with SMTP id a184-20020a6390c1000000b003fc7de1b2b9mr21576878pge.440.1654531828669; Mon, 06 Jun 2022 09:10:28 -0700 (PDT) Received: from localhost.localdomain (li567-56.members.linode.com. [192.155.81.56]) by smtp.gmail.com with ESMTPSA id l63-20020a632542000000b003fc4001fd5fsm10777246pgl.10.2022.06.06.09.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 09:10:28 -0700 (PDT) From: Jeff Xie To: rostedt@goodmis.org Cc: mingo@redhat.com, mhiramat@kernel.org, zanussi@kernel.org, linux-kernel@vger.kernel.org, Jeff Xie Subject: [PATCH v12 4/4] trace/objtrace: Add documentation for objtrace Date: Tue, 7 Jun 2022 00:09:43 +0800 Message-Id: <20220606160943.663180-5-xiehuan09@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220606160943.663180-1-xiehuan09@gmail.com> References: <20220606160943.663180-1-xiehuan09@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Added documentation explaining how to use objtrace trigger to get the value of the object. Signed-off-by: Jeff Xie --- Documentation/trace/events.rst | 83 ++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/Documentation/trace/events.rst b/Documentation/trace/events.rst index c47f381d0c00..0dc475160133 100644 --- a/Documentation/trace/events.rst +++ b/Documentation/trace/events.rst @@ -546,6 +546,89 @@ The following commands are supported: See Documentation/trace/histogram.rst for details and examples. +- objtrace + + This command provides a way to get the value of any object, The object + can be obtained from the dynamic event(kprobe_event/uprobe_event) or the + static event(tracepoint). + + Usage: + When using the kprobe event, only need to set the objtrace(a new trigger), + we can get the value of the object. The object is from the setting of the + kprobe event. + + For example: + For the function bio_add_page(): + + int bio_add_page(struct bio *bio, struct page *page, + unsigned int len, unsigned int offset) + + Firstly, we can set the base of the object, thus the first string "arg1" + stands for the value of the first parameter of this function bio_add_gage(), + + # echo 'p bio_add_page arg1=$arg1' > ./kprobe_events + + Secondly, we can get the value dynamically based on above object. + + find the offset of the bi_size in struct bio: + $ gdb vmlinux + (gdb) p &(((struct bio *)0)->bi_iter.bi_size) + $1 = (unsigned int *) 0x28 + + # echo 'objtrace:add:arg1,0x28:u32:1 if comm == "cat"' > ./events/kprobes/ \ + p_bio_add_page_0/trigger + + # cd /sys/kernel/debug/tracing/ + # echo 'p bio_add_page arg1=$arg1' > ./kprobe_events + # echo 'objtrace:add:arg1,0x28:u32:1 if comm == "cat"' > ./events/kprobes/p_bio_add_page_0/trigger + + # du -sh /test.txt + 12.0K /test.txt + + # cat /test.txt > /dev/null + # cat ./trace + # tracer: nop + # + # entries-in-buffer/entries-written: 128/128 #P:4 + # + # _-----=> irqs-off/BH-disabled + # / _----=> need-resched + # | / _---=> hardirq/softirq + # || / _--=> preempt-depth + # ||| / _-=> migrate-disable + # |||| / delay + # TASK-PID CPU# ||||| TIMESTAMP FUNCTION + # | | | ||||| | | + cat-117 [002] ...1. 1.602243: __bio_try_merge_page <-bio_add_page object:0xffff88811bee4000 value:0x0 + cat-117 [002] ...1. 1.602244: __bio_add_page <-bio_add_page object:0xffff88811bee4000 value:0x0 + cat-117 [002] ...2. 1.602244: bio_add_page <-ext4_mpage_readpages object:0xffff88811bee4000 value:0x1000 + cat-117 [002] ...1. 1.602245: __bio_try_merge_page <-bio_add_page object:0xffff88811bee4000 value:0x1000 + cat-117 [002] ...1. 1.602245: __bio_add_page <-bio_add_page object:0xffff88811bee4000 value:0x1000 + cat-117 [002] ...2. 1.602245: bio_add_page <-ext4_mpage_readpages object:0xffff88811bee4000 value:0x2000 + cat-117 [002] ...1. 1.602245: __bio_try_merge_page <-bio_add_page object:0xffff88811bee4000 value:0x2000 + cat-117 [002] ...1. 1.602245: __bio_add_page <-bio_add_page object:0xffff88811bee4000 value:0x2000 + cat-117 [002] ...1. 1.602245: submit_bio <-ext4_mpage_readpages object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602245: submit_bio_noacct <-ext4_mpage_readpages object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602246: __submit_bio <-submit_bio_noacct object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602246: submit_bio_checks <-__submit_bio object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602246: __cond_resched <-submit_bio_checks object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602246: should_fail_bio <-submit_bio_checks object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602246: blk_mq_submit_bio <-submit_bio_noacct object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602246: blk_attempt_plug_merge <-blk_mq_submit_bio object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602246: blk_mq_sched_bio_merge <-blk_mq_submit_bio object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602247: __rcu_read_lock <-blk_mq_submit_bio object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602247: __rcu_read_unlock <-blk_mq_submit_bio object:0xffff88811bee4000 value:0x3000 + cat-117 [002] ...1. 1.602247: __blk_mq_alloc_requests <-blk_mq_submit_bio object:0xffff88811bee4000 value:0x3000 + -0 [002] d..3. 1.602298: bio_endio <-blk_update_request object:0xffff88811bee4000 value:0x0 + -0 [002] d..3. 1.602298: mpage_end_io <-blk_update_request object:0xffff88811bee4000 value:0x0 + -0 [002] d..3. 1.602298: __read_end_io <-blk_update_request object:0xffff88811bee4000 value:0x0 + -0 [002] d..3. 1.602300: bio_put <-blk_update_request object:0xffff88811bee4000 value:0x0 + -0 [002] d..3. 1.602300: bio_free <-blk_update_request object:0xffff88811bee4000 value:0x0 + -0 [002] d..3. 1.602300: mempool_free <-blk_update_request object:0xffff88811bee4000 value:0x0 + -0 [002] d..3. 1.602300: mempool_free_slab <-blk_update_request object:0xffff88811bee4000 value:0x0 + -0 [002] d..3. 1.602300: kmem_cache_free <-blk_update_request object:0xffff88811bee4000 value:0x0 + ... + 7. In-kernel trace event API ============================ -- 2.25.1