From patchwork Wed Oct 7 18:44:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 11821595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29416109B for ; Wed, 7 Oct 2020 18:44:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B9DAC21775 for ; Wed, 7 Oct 2020 18:44:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="EvHdwN6Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9DAC21775 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 501ED6B0068; Wed, 7 Oct 2020 14:44:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 48A2A6B006E; Wed, 7 Oct 2020 14:44:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B6826B0070; Wed, 7 Oct 2020 14:44:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id D82536B0068 for ; Wed, 7 Oct 2020 14:44:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6B955362A for ; Wed, 7 Oct 2020 18:44:15 +0000 (UTC) X-FDA: 77346004470.02.pie74_48145e8271d1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 78C4610175D6B for ; Wed, 7 Oct 2020 18:44:12 +0000 (UTC) X-Spam-Summary: 1,0,0,531d1fd63e018996,d41d8cd98f00b204,3ewx-xw0kci4sfw39sa4caaw5y66y3w.u64305cf-442dsu2.69y@flex--axelrasmussen.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3866:3867:3868:3870:3871:3872:3873:4321:5007:6119:6261:6653:7903:8603:9969:10004:10400:11026:11658:11914:12043:12048:12297:12555:12895:12986:13069:13138:13161:13229:13231:13311:13357:14096:14097:14181:14394:14659:14721:21080:21220:21444:21627:21740:21990:30054:30056,0,RBL:209.85.219.74:@flex--axelrasmussen.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yfo15zdgkake1kww5os8w4xinbkyp4o8mipkz5yryr1nhjutdqgfh474p59ze.u8bb1rg9kjzzxcmacs9wn74ncextic5egp11nncyos1rqy7bxcxofkdzt8kh7uj.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custo m_rules: X-HE-Tag: pie74_48145e8271d1 X-Filterd-Recvd-Size: 4769 Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Wed, 7 Oct 2020 18:44:12 +0000 (UTC) Received: by mail-qv1-f74.google.com with SMTP id bo17so2025343qvb.2 for ; Wed, 07 Oct 2020 11:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=8I3vIcrMV5Zu6Hhqx7rsCDTZKSKCCDLk+NRUTUtCArI=; b=EvHdwN6QEoSSTRp9Gx+IDUr0457JMOACZ6z4Kk1NaukYrw0zsHpHUsc0nTWng/QB+J 8i3JP1kd2Rc81mBUzXF8p9kaB7vh+OKfpMqOiwmLTHse+HwcvZEtOmuV7GU7OqvEl2VH /8CckH/DkeDYJ4jxTYTYnVNGBpiq9gVO+hsgY4S8xGjETNvNtMk4hx8CBxcrAIahliMl wTiKf3N/GqmgBYUwfVPGgmg40m0xPAlUOINUu7PzAjaDxakVD5tK7m1abbcoPcmmbuYn RsLeEZk5ET1WFM4f1UqC7lVRpzdVO451wIIXirjs/U/I/OOQm+u25HqZS7OV8MjrtdGS 14Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8I3vIcrMV5Zu6Hhqx7rsCDTZKSKCCDLk+NRUTUtCArI=; b=O4bD/Ux/CoJg9dblKoVlQKDjtkG/3TMmjSsE7D06gDX4pfwE1ZCflAnpGnMpsy2+E4 m3OKB+jCL81k9x4mfGqe43SR+QbGVYHgcnQYu71nrBPy+Xj65VcUFTA42QTvQL8tXcKG D8+20YVhCBMhmT4UiAO3Wbyysgx0OQZbIn4KxPEtSmtKDKh6ZUulCSe8U4MKubPMUBQV 5XyELOlglHEgsV1bnuM8KBGL4nNjfNjfO+WSmPnecAm1FAX/0Vm5Ib+aktRUqiPWTNj7 BLDm2Ad0t+E8BfTF2Bq378naUrQYFDL8y/Rqko1eL3Dn13qjyNhNiZCgQyG70tkHviky a2fA== X-Gm-Message-State: AOAM532rD5EsKnVb3TjXTRtEjwsJdGEDKWCSLBg7onKnDg3w/bwltjrJ qz9Xqp1OEx58qfmrMJ5oY2Ij4tFk2KYD9C6OBupQ X-Google-Smtp-Source: ABdhPJzgcOpNapDJXobR6oBhvoqgjcOsqXNBjp7J045y+FXg+z5qRgJ31WJhxSOMgSjC1NJlcmv4bzgqELn9TzamQduA X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:f693:9fff:feef:c8f8]) (user=axelrasmussen job=sendgmr) by 2002:ad4:42ae:: with SMTP id e14mr4498331qvr.44.1602096251082; Wed, 07 Oct 2020 11:44:11 -0700 (PDT) Date: Wed, 7 Oct 2020 11:44:02 -0700 In-Reply-To: <20201007184403.1902111-1-axelrasmussen@google.com> Message-Id: <20201007184403.1902111-2-axelrasmussen@google.com> Mime-Version: 1.0 References: <20201007184403.1902111-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.28.0.806.g8561365e88-goog Subject: [PATCH v2 1/2] tracing: support "bool" type in synthetic trace events From: Axel Rasmussen To: Steven Rostedt , Ingo Molnar , Andrew Morton , Michel Lespinasse , Vlastimil Babka , Daniel Jordan , Laurent Dufour , Axel Rasmussen , Jann Horn , Chinwen Chang Cc: Yafang Shao , linux-kernel@vger.kernel.org, linux-mm@kvack.org X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It's common [1] to define tracepoint fields as "bool" when they contain a true / false value. Currently, defining a synthetic event with a "bool" field yields EINVAL. It's possible to work around this by using e.g. u8 (assuming sizeof(bool) is 1, and bool is unsigned; if either of these properties don't match, you get EINVAL [2]). Supporting "bool" explicitly makes hooking this up easier and more portable for userspace. [1]: grep -r "bool" include/trace/events/ [2]: check_synth_field() in kernel/trace/trace_events_hist.c Signed-off-by: Axel Rasmussen Acked-by: Michel Lespinasse --- kernel/trace/trace_events_synth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c index 742ce5f62d6d..92eb530ec287 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -187,6 +187,8 @@ static int synth_field_size(char *type) size = sizeof(long); else if (strcmp(type, "unsigned long") == 0) size = sizeof(unsigned long); + else if (strcmp(type, "bool") == 0) + size = sizeof(bool); else if (strcmp(type, "pid_t") == 0) size = sizeof(pid_t); else if (strcmp(type, "gfp_t") == 0) @@ -229,6 +231,8 @@ static const char *synth_field_fmt(char *type) fmt = "%ld"; else if (strcmp(type, "unsigned long") == 0) fmt = "%lu"; + else if (strcmp(type, "bool") == 0) + fmt = "%d"; else if (strcmp(type, "pid_t") == 0) fmt = "%d"; else if (strcmp(type, "gfp_t") == 0)