From patchwork Tue Apr 25 09:16:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 87323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3275030vqo; Tue, 25 Apr 2023 02:21:11 -0700 (PDT) X-Google-Smtp-Source: AKy350aQ7YhvBU+yLhb9lFGQF0+R7ctKqe9rydbZvm2fG6MCD7RlaMJB6QEm5uE9fhgSLyZtkYEQ X-Received: by 2002:a17:90a:d985:b0:247:193b:ce84 with SMTP id d5-20020a17090ad98500b00247193bce84mr16792771pjv.15.1682414471574; Tue, 25 Apr 2023 02:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682414471; cv=none; d=google.com; s=arc-20160816; b=Z22256HfBLloaR/LOuy31aDAVmqQpZxliiDU+dcAtWRwm1Qlq9qCVe44Jw3oKaakR7 J8Yi1sV8rv7DDqIGh9odpBQWFDLRMNCcCX93OLxHzR7KE4q9aygKbBxSLdKdqRZ90Gm4 20+YqPOOO/to2OPdAipCMhMMsEADlQGm/DAnuLYpPJapTf85zPT43rf/thYsmlT/kuLk Zus+hxX2+seR7v1faA3XNM6+HWZGACkmn3g3koFb2Q8Ssdswglt1E4OEGIS2dfxQXMUz xzqw1ImnGwYHVtBktEdOFfIvAFYLBGY3RdkQiA4WM8AVDvxUdZYYDlUeHSFbyoiZMnAn u/Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=uEvv3LAyU/zfvFvoOcm942rAaxSYCfXplaAMUlb7W6o=; b=SI8LPkr0UimygqQlZb6/3WuLCQGluQJK2fADJcmf1v4qZfpPxP0U2qBkI06iRUYgIQ F4fdMpd6s+U+C9fTh30WQkfefKP9dUH0tMdp6+JfC3q65cpQMznoPqBXM9GbKQbgQWZ/ YiAcLFfa7LG7yvS4TxGydK4O5NFsK4g3sEN7eLiWV/W3/qT8yr4CRicsKZ230coLOMBp EJ0zyrOVHkFIRMQYMe0p6yBdAmX0aHbQXJq/eTAgNgHQ2xg8hGzzigaDeqL1CkyW25Vd MsBPBz1MvZ70RbWCaKonynwJ74iZ4VPTp/mawz5kQgfKZm/H+r2UF+dw1i/q6yWcBi5D JtzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=1VMGomFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 186-20020a6300c3000000b0051b8ab93411si12211356pga.767.2023.04.25.02.20.59; Tue, 25 Apr 2023 02:21:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=1VMGomFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233674AbjDYJQx (ORCPT + 99 others); Tue, 25 Apr 2023 05:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233428AbjDYJQu (ORCPT ); Tue, 25 Apr 2023 05:16:50 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC8AA2685; Tue, 25 Apr 2023 02:16:49 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33P0i0ZW005234; Tue, 25 Apr 2023 09:16:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=uEvv3LAyU/zfvFvoOcm942rAaxSYCfXplaAMUlb7W6o=; b=1VMGomFVkEsfbBS33eMP4Tk269b1nYwJ687E5J/zysOcG9XQzRAgMkRtDtZkEyfKywVi F0JY9WmLP5savx6SJ5bRNjDmuFASGEhf6WsNFrojt1lDsIegADlryCTiqSHs7lJZlrR+ ieiRbV63zbCfO2xyZEUBpWYZFDdoRF1IGN8izTJmwrXAD1h+wtdg9xFSQ0A2amrbOs+7 /XbJumwzi8VoghLwd5x64ZSMMX8zSfBz62B/mX0sdfMnXNjuBj0/OfNHx6UcjjRXTG98 TzAKQ1vLuuZoYui/tx5uNQ502dqmSCg9kRwuqtn9Gj4cKLaV6HBdihJytH2zn8cF2/02 1Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q476tvun9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 09:16:44 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33P7roOg025226; Tue, 25 Apr 2023 09:16:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3q461cdwcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 09:16:44 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33P93LCR024482; Tue, 25 Apr 2023 09:16:43 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-181-126.vpn.oracle.com [10.175.181.126]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3q461cdwa1-2; Tue, 25 Apr 2023 09:16:43 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Alan Maguire Subject: [PATCH tracing 1/3] tracing: support > 8 byte array filter predicates Date: Tue, 25 Apr 2023 10:16:35 +0100 Message-Id: <1682414197-13173-2-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682414197-13173-1-git-send-email-alan.maguire@oracle.com> References: <1682414197-13173-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-25_03,2023-04-21_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304250082 X-Proofpoint-GUID: LZoWkMPiAxPu9ZSGPpVbSovH5u3HcKa6 X-Proofpoint-ORIG-GUID: LZoWkMPiAxPu9ZSGPpVbSovH5u3HcKa6 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764139437001966440?= X-GMAIL-MSGID: =?utf-8?q?1764139437001966440?= For > 8 byte values, allow simple binary '==', '!=' predicates where the user passes in a hex ASCII representation of the desired value. This representation must match the field size exactly, and a simple memory comparison between predicate and actual values is carried out. This will allow predicates with for example IPv6 addresses to be supported, such as filtering on ::1 cd /sys/kernel/debug/tracing/events/tcp/tcp_receive_reset echo "saddr_v6 == 0x00000000000000000000000000000001" > filter Signed-off-by: Alan Maguire --- kernel/trace/trace_events_filter.c | 55 +++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 1dad64267878..4f4f53b7302d 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -67,6 +67,7 @@ enum filter_pred_fn { FILTER_PRED_FN_FUNCTION, FILTER_PRED_FN_, FILTER_PRED_TEST_VISITED, + FILTER_PRED_FN_MEMCMP, }; struct filter_pred { @@ -622,8 +623,11 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, kfree(op_stack); kfree(inverts); if (prog_stack) { - for (i = 0; prog_stack[i].pred; i++) + for (i = 0; prog_stack[i].pred; i++) { + if (prog_stack[i].pred->fn_num == FILTER_PRED_FN_MEMCMP) + kfree((u8 *)prog_stack[i].pred->val); kfree(prog_stack[i].pred); + } kfree(prog_stack); } return ERR_PTR(ret); @@ -890,6 +894,14 @@ static int filter_pred_function(struct filter_pred *pred, void *event) return pred->op == OP_EQ ? ret : !ret; } +static int filter_pred_memcmp(struct filter_pred *pred, void *event) +{ + u8 *mem = (u8 *)(event + pred->offset); + u8 *cmp = (u8 *)(pred->val); + + return (memcmp(mem, cmp, pred->field->size) == 0) ^ pred->not; +} + /* * regex_match_foo - Basic regex callbacks * @@ -1353,6 +1365,8 @@ static int filter_pred_fn_call(struct filter_pred *pred, void *event) return filter_pred_function(pred, event); case FILTER_PRED_TEST_VISITED: return test_pred_visited_fn(pred, event); + case FILTER_PRED_FN_MEMCMP: + return filter_pred_memcmp(pred, event); default: return 0; } @@ -1631,6 +1645,45 @@ static int parse_pred(const char *str, void *data, /* go past the last quote */ i++; + } else if (str[i] == '0' && tolower(str[i + 1]) == 'x' && + field->size > 8) { + u8 *pred_val; + + /* For sizes > 8 bytes, we store a binary representation + * for comparison; only '==' and '!=' are supported. + * To keep things simple, the predicate value must specify + * a value that matches the field size exactly, with leading + * 0s if necessary. + */ + if (pred->op != OP_EQ && pred->op != OP_NE) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); + goto err_free; + } + + /* skip required 0x */ + s += 2; + i += 2; + + while (isalnum(str[i])) + i++; + + len = i - s; + if (len != (field->size * 2)) { + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + s); + goto err_free; + } + + pred_val = kzalloc(field->size, GFP_KERNEL); + if (hex2bin(pred_val, str + s, field->size)) { + parse_error(pe, FILT_ERR_ILLEGAL_INTVAL, pos + s); + kfree(pred_val); + goto err_free; + } + pred->val = (u64)pred_val; + pred->fn_num = FILTER_PRED_FN_MEMCMP; + if (pred->op == OP_NE) + pred->not = 1; + } else if (isdigit(str[i]) || str[i] == '-') { /* Make sure the field is not a string */ From patchwork Tue Apr 25 09:16:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 87324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3276571vqo; Tue, 25 Apr 2023 02:25:31 -0700 (PDT) X-Google-Smtp-Source: AKy350acXQPUfKSjTQ51BlskDJH9NkaImngBWnSP6Maac4aKKC7rrdXI5vxEB7nlFcoDBdF26TGQ X-Received: by 2002:a05:6a00:1408:b0:63d:3339:e967 with SMTP id l8-20020a056a00140800b0063d3339e967mr20232611pfu.19.1682414731169; Tue, 25 Apr 2023 02:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682414731; cv=none; d=google.com; s=arc-20160816; b=ZIdIVdwq4PzEmHNIRYHSnjqbkNO5MPAPoj+KafrjUOMXILgG5bbyXPIZip1rp6SEus NhVVPxd2VriQbTOsJxqWOG5kgNXJZWL6OlvZVwRw3H6LcA5bGJtMQ7G8y1qXvtigdFMR d5N8T/htD5Sh0zSCeKELMfN7mOYenBQUSuGEQIl/1oQZeeXbOUuWiO7+MfZZ00yMOb44 YV4ognFONSP4V1AHLjxouvHjzIa8kmNrV+nSJFosoW5fUc277+wfvwi+HRLA7ZeVa1dO HwrBS3EGHrlCa17SGftPP99NdzRxp9SHPip5l5uh9O+npBMKyI9O8WUMfjljs0R933Rl Ugaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=sRmZ24TIDSjA4WAmXwcO6eFy6214CYNyXMb+g2Vg14E=; b=Wwh+1EshPaaEBt+T3xqtF7L2KcYXNlGVi2Tgt4LnfodWrLFruEj5RMwrRhPNXIjekb Yo26oSkb+2j5TBkjKbUyxP2xpK5BrP/S51guOm4gWpdqkMyVuLIpYHJKTzvDnXNhL2wQ 6I7lq2TPAHj679co9q9FSi7i1ePv3Rw9y3/WyBSe+02zTcFRc7EgViM7qQlKEGqnbPa2 OnwSLnf7WnD0gBM0vJnGwzGBHkT6x3NWGHNknSy+tipr4oAzHkLS5KK7119K748MoT7F wDJrqNs9CBi2rHuD89xjCNisAAF6FOoEwbWxmF4dNGmiI+OA4/ZjZrKst54J+iKGb5+B 33yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="Ji4/Lbn3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020aa79578000000b0063b754972f4si13511780pfq.159.2023.04.25.02.25.16; Tue, 25 Apr 2023 02:25:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="Ji4/Lbn3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233685AbjDYJQz (ORCPT + 99 others); Tue, 25 Apr 2023 05:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233673AbjDYJQw (ORCPT ); Tue, 25 Apr 2023 05:16:52 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D1C40E0; Tue, 25 Apr 2023 02:16:51 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33P0hxHB005226; Tue, 25 Apr 2023 09:16:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=sRmZ24TIDSjA4WAmXwcO6eFy6214CYNyXMb+g2Vg14E=; b=Ji4/Lbn3A25dUe3MzwNR0xP+dFBeNT6m/QGdMuQZ07/GgiGKjgu2rhSlmpkiRpYavMI0 ZtCjAYyBwj0xX4ZqNoQCGGJh+GdUWiW5AQWviihMEAwMZgBmrptBGb7WcXRU6dnpUS8s EkaxVgClxwpOg+JbNr+w8D7M5fsrLxfFuG4ruL/3om8YV+tp+htbhTiIfhXddYNIbTNv 5LUPwFtZx/+xPzU9M6m/75LKD/z5RrNqNH+nBTuvHt9lLe4tzIsQjddExRlOhw0S+YLZ eFKLqFUNr2MPGUYLIooWO+3P6BNCkj5MFXvJsTviNxUAQs7UeeyDsVfwyHJwyg3LoUGs Mg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q476tvunb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 09:16:47 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33P80Rug024874; Tue, 25 Apr 2023 09:16:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3q461cdwdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 09:16:46 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33P93LCT024482; Tue, 25 Apr 2023 09:16:46 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-181-126.vpn.oracle.com [10.175.181.126]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3q461cdwa1-3; Tue, 25 Apr 2023 09:16:45 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Alan Maguire Subject: [PATCH tracing 2/3] selftests/ftrace: add test coverage for filter predicates Date: Tue, 25 Apr 2023 10:16:36 +0100 Message-Id: <1682414197-13173-3-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682414197-13173-1-git-send-email-alan.maguire@oracle.com> References: <1682414197-13173-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-25_03,2023-04-21_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304250082 X-Proofpoint-GUID: 9YkwjMFnbujJcyCEW1MkI2S4_yYbcsUl X-Proofpoint-ORIG-GUID: 9YkwjMFnbujJcyCEW1MkI2S4_yYbcsUl X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764139709049068768?= X-GMAIL-MSGID: =?utf-8?q?1764139709049068768?= add tests verifying filter predicates work for 1/2/4/8/16 byte values and strings; use predicates at event and subsystem level. Signed-off-by: Alan Maguire --- .../selftests/ftrace/test.d/event/filter.tc | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/event/filter.tc diff --git a/tools/testing/selftests/ftrace/test.d/event/filter.tc b/tools/testing/selftests/ftrace/test.d/event/filter.tc new file mode 100644 index 000000000000..df5c93d5aa4d --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/event/filter.tc @@ -0,0 +1,62 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: event tracing - enable filter predicates +# requires: set_event events/sched +# flags: + +do_reset() { + echo 0 > ${event}/enable + echo 0 > ${event}/filter + clear_trace +} + +fail() { #msg + echo $1 + exit_fail +} + +# verify filter predicates at trace event/subsys level for +# - string (prev_comm) +# - 1-byte value (common_flags) +# - 2-byte value (common_type) +# - 4-byte value (next_pid) +# - 8-byte value (prev_state) + +for event in events/sched/sched_switch events/sched +do + for filter in "prev_comm == 'ping'" \ + "common_flags != 0" \ + "common_type >= 0" \ + "next_pid > 0" \ + "prev_state != 0" + do + echo "$filter" > ${event}/filter + echo 1 > ${event}/enable + yield + count=`grep sched_switch trace|wc -l` + if [ $count -lt 1 ]; then + fail "at least one $event should be recorded for '$filter'" + fi + do_reset + done +done + +# verify '==', '!=' filter predicates for 16-byte array at event/subsys +# level + +LOCALHOST="-6 ::1" +for event in events/fib6/fib6_table_lookup events/fib6 ; do + for filter in "dst == 0x00000000000000000000000000000001" \ + "src != 0x00000000000000000000000000000001" + do + echo "$filter" > ${event}/filter + echo 1 > ${event}/enable + yield + count=`grep fib6_table_lookup trace|wc -l` + if [ $count -lt 1 ]; then + fail "at least one $event should be recorded for '$filter'" + fi + do_reset + done +done +exit 0 From patchwork Tue Apr 25 09:16:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 87325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3279399vqo; Tue, 25 Apr 2023 02:32:26 -0700 (PDT) X-Google-Smtp-Source: AKy350aDisBvrdw8E07ssANK/9V8BWSoSAVkGjofGJ+ReTsGqc1gEwgT6+Zq32H/zxBs6OPo/yDW X-Received: by 2002:a17:902:e752:b0:1a6:955c:6329 with SMTP id p18-20020a170902e75200b001a6955c6329mr22745418plf.22.1682415146489; Tue, 25 Apr 2023 02:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682415146; cv=none; d=google.com; s=arc-20160816; b=jfn8xJHOeZQ8dQxJZxdzIQHWuv8hLVIcFF5ltCDPDW2hOOiO2gKPyqo4KlYDEetP76 9TC5ZEvoC6xT+9KsmKO44VvLjmYW+5rH3pwfXhRlCwM3TXz+VVvf5bldBWaCXbcfUh4C 2QLihKWx2QKBUvq9Iw6qgL+MraBoqngPQZ9oZ/+3SxAOqUN0yPlpk4VNjUXl+slEfPNB tw5u8Jfq0jEPnEhIu8JJ2EnCeCrveQ2J870ThUU+xuSJmXyhModS3PFQXy6G5OQNqMak KGcYwNoNO4C3LTJ9FVj6A3ovv4PlKcPOtIFHLPtLFqHo9WdpL33pF8V6/Q+1fFjhK5lz YqEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=7kgs+lAKCEL9tceQOO9jB+IYOkJ+/3Rc21XPBYFqcac=; b=HfqHrsqHtS7Je9Qtbwnhb8Oplqct6CLI4Xxie96Y0aTj0P/X4jKY7eSkX5lz8iKiBR poVZxz2rXGFRjt8KnvAo10RW7lEt8uYV2GADeEcBlMsdAP/Cp07zkYemY8KmAUtg29xw UJa2DB3UreM8nFXbtqTFX3CnlIg1ouPbl2Z7JQwZrgqIVFyGh3F+qaTopDC1qXhXvrkD 57glNBByPlERwsCdEwfEhs5lE863fszAQtzU15Lh9b7pqthUH2kjNzoWWghd8s5qVJUK i7nC9/tDP0mdCuWfl4JSjnvoYsL3bKgas6UtI8RsSFlQMSpVP0FrPD7zAIGbJk3tA7Gz NbPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=kDIFJZxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb22-20020a170903259600b0019ec2a633f4si12406332plb.505.2023.04.25.02.32.14; Tue, 25 Apr 2023 02:32:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=kDIFJZxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233721AbjDYJRC (ORCPT + 99 others); Tue, 25 Apr 2023 05:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233684AbjDYJQz (ORCPT ); Tue, 25 Apr 2023 05:16:55 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E54210FD; Tue, 25 Apr 2023 02:16:54 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33P0i1Uj026457; Tue, 25 Apr 2023 09:16:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-03-30; bh=7kgs+lAKCEL9tceQOO9jB+IYOkJ+/3Rc21XPBYFqcac=; b=kDIFJZxTAl1eLj5XDF5CH5Cf/94+Z22rYn9mvhHTpvgKCWoq5ZLxQ+4FSTzDAbje6y5H dOg3BwoLsjfWE1XTsqtH0mSKazllWgSuM0QgGQ7HTU9cH4i4oO5dOk/yNpPvu5MiLgff SEHonAEm8IxivW+vsKesbBaudZ708xtIu3mqrN4o2lNR5Y2QFrAo08iZ0a/PomTpOfFi w3EdO6W1Nb9qS53HRazhXDBGldRtnYpL7ZaB3IteCjHVsMluVbYLUwbdC3k1MgT8ZG/3 uNI15g6rr2RXLlBlczsf2Lnlc52B+W4t6yW27mTN9euG2OYbLROiz9pm3Jplkm8Xnf3y 9Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q460d4vfp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 09:16:49 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 33P7erjw024956; Tue, 25 Apr 2023 09:16:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3q461cdwek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 09:16:49 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33P93LCV024482; Tue, 25 Apr 2023 09:16:48 GMT Received: from myrouter.uk.oracle.com (dhcp-10-175-181-126.vpn.oracle.com [10.175.181.126]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3q461cdwa1-4; Tue, 25 Apr 2023 09:16:48 +0000 From: Alan Maguire To: rostedt@goodmis.org, mhiramat@kernel.org Cc: corbet@lwn.net, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Alan Maguire Subject: [PATCH tracing 3/3] tracing: document > 8 byte numeric filtering support Date: Tue, 25 Apr 2023 10:16:37 +0100 Message-Id: <1682414197-13173-4-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682414197-13173-1-git-send-email-alan.maguire@oracle.com> References: <1682414197-13173-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-25_03,2023-04-21_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304250082 X-Proofpoint-GUID: v3ForVluSwZNhxJ_gxxop4bq9qYZi5rU X-Proofpoint-ORIG-GUID: v3ForVluSwZNhxJ_gxxop4bq9qYZi5rU X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764140144298523783?= X-GMAIL-MSGID: =?utf-8?q?1764140144298523783?= For values > 8 bytes in size, only == and != filter predicates are supported; document this. Signed-off-by: Alan Maguire --- Documentation/trace/events.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/trace/events.rst b/Documentation/trace/events.rst index f5fcb8e1218f..0142bf59dc4b 100644 --- a/Documentation/trace/events.rst +++ b/Documentation/trace/events.rst @@ -186,6 +186,15 @@ The operators available for numeric fields are: ==, !=, <, <=, >, >=, & +For numeric fields larger than 8 bytes, only + +==, != + +...are allowed, and values for comparison must match field size exactly. +For example, to match the "::1" IPv6 address: + +"dst == 0x00000000000000000000000000000001" + And for string fields they are: ==, !=, ~