Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp744542pxb; Mon, 25 Oct 2021 17:59:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgrgyLe32KhDGx0wB68CCNcy3pZdAHp26/F0AaAHcmwb0ob91M9GGCwZ9xEffD6Sw9iX1A X-Received: by 2002:a05:6402:22f4:: with SMTP id dn20mr30564582edb.201.1635209948311; Mon, 25 Oct 2021 17:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635209948; cv=none; d=google.com; s=arc-20160816; b=K/PLOJI5/i1ktcL7Y1AeJrxFgoZjowJJ1I9nBOXblKZBETIRcMNHgaCtNyTvdv6kcc FF6MzdqZGP3urOlcx5G6P/l0csbdXkNRh3lZA8REuXvqsb1zsMQYAUNO5WCw5HULew7Y Mg3RGjm2vYoYFnQn52G0vorfKkwNmZ2sF05ADUU1X1C+vQw3qPp1oho5vSNsnexuTTis 4BCQNUUQzMB8EeJAIgU+kOcS8RAvqrg7kD3jhA6q5OS8RjlgNe8yGfIwjkFPVEwWtSzF AfoPzZjzX69Pyyw8da+YCD1T/OEhlIjn0MEJo5cGgRTK+vdmotEhD63PzMBSHHDG+8ZD +Htw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:cc:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=kE3Nv1lKwT793xJwq+iC3RoCHqpYdQS3Tip3semgyOw=; b=OaiGM1blIlxhYvbX4NmG46PDgP/ciODtebYt+eln5um5AC53rE2qRF5HSF9yokxxt5 AtpaIIt9oHUFg4cWDKTF71QIKRWSCrBPC3+Dw9eFReIr/qcEB4+6MgecTbbCsbPOZx3T Se93356kphfFXNxvHrpDRJCpBGjsWVByOHtV7j8vGahv2Vf9q9olYfdpO65Xi+J2B/Fo fBX9qoYQ7a9U29R1iG2Zqe2ntATwuF0yOLgWHG4hhh9a9KE29TXM3WYu2AAlXP4Lg9DT bAy8ArpYrggCoNWH5suHvE5m19Re5/woFkREzQCS2oQXeSbpM6E2moxejc0vOEYBW4ar UwEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gbn9eg90; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id az7si8679544ejc.10.2021.10.25.17.58.44; Mon, 25 Oct 2021 17:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gbn9eg90; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237901AbhJYUHR (ORCPT + 99 others); Mon, 25 Oct 2021 16:07:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238785AbhJYUF1 (ORCPT ); Mon, 25 Oct 2021 16:05:27 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28156C036D6D for ; Mon, 25 Oct 2021 12:26:04 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id l27-20020a05620a211b00b0045fbe374e2dso9733877qkl.10 for ; Mon, 25 Oct 2021 12:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:cc; bh=kE3Nv1lKwT793xJwq+iC3RoCHqpYdQS3Tip3semgyOw=; b=gbn9eg9008NdXKZ1/pxplWbq1W+HOEpi3W3HkUpPW4ebJu/REMlQr1QF8rl6mQIeob euAGzvS+dOzo0OLG8Dvw/ls/OC6sl5N7rY/bFIaEZ6MMC/DFS3XjRDLrySKoPcl0Onwf TR3XD9K2yr65MzjufGS4Maq/H7ORSIxQQeGN/v+vTFrEH7F7Uo1xD6t4IqUj10V2a6GA RwWq00Ic7WNkanKG1SVkDRvdAP398xy1awfqdfjX+8zrnFqsgafTBYlGR+ZD+rxq8olq Qlsg3CtIduhiPG9cLfEDQ56Rujasnsz4EppRxtlTl7M8mxnvBNOn73lnj4mIxM1QQ5/s TgbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:cc; bh=kE3Nv1lKwT793xJwq+iC3RoCHqpYdQS3Tip3semgyOw=; b=mr5w8O4W3YK60wdRTNoPZYiRlQB5u0z8yomQ1XIZj61X4L6uKOIHljgxsuoZ72pen/ r//cBX+PZSgSwAiO6h2E+O17In7+ahIPIsHZPGJ4SApujZQ+ImJAxQZLF0mebUdx/57T QxHDsoY0+i7QD5HOXnVvxv/Lc77EGc5Gu+sIGe/fkIYzKC+geQQhnvtS+mgPJmGkPlq2 oKkZ1grFHijdNe2QRYCiRDkmQLNPEqxAWguvNkI7ExL02etkvzDoktKVVmujcrpIX7wH oydcuCqsAe+yV6m2Zpwy+PWrQwwGHHjiLZw6zVBN2eDf+5nAW2EuaS/QwHWsTHldk0Xp mjpg== X-Gm-Message-State: AOAM532untn6U9vEOVQI/gd2IJQYlN+1w0TKS8qK7y9UBVbrXHIzKGWp YK/eaFWg1fmukGftaJl2rsDaGpx2PO8d1QOm1A== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:b783:5702:523e:d435]) (user=kaleshsingh job=sendgmr) by 2002:a05:622a:1a0b:: with SMTP id f11mr19780649qtb.133.1635189963298; Mon, 25 Oct 2021 12:26:03 -0700 (PDT) Date: Mon, 25 Oct 2021 12:23:19 -0700 In-Reply-To: <20211025192330.2992076-1-kaleshsingh@google.com> Message-Id: <20211025192330.2992076-9-kaleshsingh@google.com> Mime-Version: 1.0 References: <20211025192330.2992076-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog Subject: [PATCH v3 8/8] tracing/histogram: Document expression arithmetic and constants From: Kalesh Singh Cc: surenb@google.com, hridya@google.com, namhyung@kernel.org, kernel-team@android.com, Kalesh Singh , Jonathan Corbet , Steven Rostedt , Ingo Molnar , Shuah Khan , Masami Hiramatsu , Tom Zanussi , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Histogram expressions now support division, and multiplication in addition to the already supported subtraction and addition operators. Numeric constants can also be used in a hist trigger expressions or assigned to a variable and used by refernce in an expression. Signed-off-by: Kalesh Singh Reviewed-by: Namhyung Kim --- Changes in v2: - Add Namhyung's Reviewed-by Documentation/trace/histogram.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/trace/histogram.rst b/Documentation/trace/histogram.rst index 533415644c54..e12699abaee8 100644 --- a/Documentation/trace/histogram.rst +++ b/Documentation/trace/histogram.rst @@ -1763,6 +1763,20 @@ using the same key and variable from yet another event:: # echo 'hist:key=pid:wakeupswitch_lat=$wakeup_lat+$switchtime_lat ...' >> event3/trigger +Expressions support the use of addition, subtraction, multiplication and +division operators (+-*/). + +Note that division by zero always returns -1. + +Numeric constants can also be used directly in an expression:: + + # echo 'hist:keys=next_pid:timestamp_secs=common_timestamp/1000000 ...' >> event/trigger + +or assigned to a variable and referenced in a subsequent expression:: + + # echo 'hist:keys=next_pid:us_per_sec=1000000 ...' >> event/trigger + # echo 'hist:keys=next_pid:timestamp_secs=common_timestamp/$us_per_sec ...' >> event/trigger + 2.2.2 Synthetic Events ---------------------- -- 2.33.0.1079.g6e70778dc9-goog