From patchwork Fri Oct 9 22:05:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 11829721 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 664AF175A for ; Fri, 9 Oct 2020 22:05:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1DC3922258 for ; Fri, 9 Oct 2020 22:05:33 +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="t0+NyCh6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DC3922258 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 268B494000F; Fri, 9 Oct 2020 18:05:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 21BC394000C; Fri, 9 Oct 2020 18:05:33 -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 0954294000F; Fri, 9 Oct 2020 18:05:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id CABA294000C for ; Fri, 9 Oct 2020 18:05:32 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 603B4180AD806 for ; Fri, 9 Oct 2020 22:05:32 +0000 (UTC) X-FDA: 77353769304.20.club84_0004b9e271e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 3F4E4180C07A3 for ; Fri, 9 Oct 2020 22:05:32 +0000 (UTC) X-Spam-Summary: 1,0,0,39e7874319a207de,d41d8cd98f00b204,3qt6axw0kcg0lipwcldxfddpyrzzrwp.nzxwtyfi-xxvglnv.zcr@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:3353: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:13069:13138:13161:13229:13231:13311:13357:14096:14097:14181:14394:14659:14721:21080:21220:21444:21451:21627:21740:21990:30054:30056,0,RBL:209.85.215.202:@flex--axelrasmussen.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04y86f5zydcrtzk9r6mnz1qwqxri1op4o8mipkz5yryr1nhjutdqgfh474p3o7u.8um55b6meqeum3mecs9wn74ncextic5egp1e4bwuz4ts1y7bxcxofk88ww51ep4.6-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,Cust om_rules X-HE-Tag: club84_0004b9e271e4 X-Filterd-Recvd-Size: 4818 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 22:05:31 +0000 (UTC) Received: by mail-pg1-f202.google.com with SMTP id j16so6810835pgi.3 for ; Fri, 09 Oct 2020 15:05:31 -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=P3zh56605aw3etCHRqEnAMV5pM6KCjNDIRD7NDvRgXI=; b=t0+NyCh6jdjxgRPAZG6P+/ltegNieLG9x+vuVTY4RBmE9jAZDh3fHF9zAEpaLn+o0Z F9Ur8Y9cwDZ/TteieT8YZF48CawXHH2kXf9cc3CDCKuNEMYIlL8Ff2QFHZpp28daOsgK pm1IF0D9k4kW/k+dlf8ezx2dfyGqqoDjAhgXvRQwH+aLOBw/b6VT0QTv87fDOFpmbkBL GR0NuuRQy6UZzYEJMOx5E+ahPBW+UkfYtBM7zqan4Fty3jvjCnfZW0eMAoMqYkw0Ypr6 Ol2VLRIi8qPzvovHeAXHuVCp+0zF0X10+oJNmXycEkv1k1YY40IJkgXvFZlImwyx8LjI pbBg== 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=P3zh56605aw3etCHRqEnAMV5pM6KCjNDIRD7NDvRgXI=; b=KQIYiqDC9y3wFbtMbDN9OyTqpPXw500UECHXawx/ujRNSuhkTsVkSlJwlkoE6+3E3r uJqKMlBPAuDtsLNkuJjlzniWkoSkkDGUsCxilmc7cV2wB1Uu3RFs4rMRTxEFyHIYxp5c MwAf+cQbC6iLKFniU0hb/WGRp4EMd8alYp4S5oZRhBLFLer6Pzpsn079ue6XfuOmgV5T kxdXiL8zEk+wzYu3XEeSkD6iTG08W5xXGrVge/mg9DzPGfpYGKdRe+2ngy5c21Vhi3bk Ivb3ef8poiUiWwhNz+LmYMfOLX+igxGB741qOtKV2CTBeOJq1QfG//g/AMdXOXrnkc38 Umqw== X-Gm-Message-State: AOAM533pvkxNA5JyYqDufrLHKLzCJPwrWxFeGt3gXO1C8MCwPp4qt2Eu eO67Nbh2SxDy0887EzY+/FPKJ5sCw/YhtycJ95yq X-Google-Smtp-Source: ABdhPJy9z+/rA1j7Repb1JxRjQy2PvR0s/646IIzv9KPrPXcBJo38uYMWZ7o4gIo0ScfSy/L1jQh+IwgU4G9nrr3AD1m X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:f693:9fff:feef:c8f8]) (user=axelrasmussen job=sendgmr) by 2002:a65:5b48:: with SMTP id y8mr4907900pgr.67.1602281130575; Fri, 09 Oct 2020 15:05:30 -0700 (PDT) Date: Fri, 9 Oct 2020 15:05:23 -0700 In-Reply-To: <20201009220524.485102-1-axelrasmussen@google.com> Message-Id: <20201009220524.485102-2-axelrasmussen@google.com> Mime-Version: 1.0 References: <20201009220524.485102-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog Subject: [PATCH v3 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 Acked-by: Michel Lespinasse Signed-off-by: Axel Rasmussen Acked-by: Tom Zanussi Acked-by: David Rientjes --- kernel/trace/trace_events_synth.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.28.0.1011.ga647a8990f-goog diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c index 8e1974fbad0e..8f94c84349a6 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -234,6 +234,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) @@ -276,6 +278,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)