From patchwork Fri Jul 7 17:21:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 117229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3423324vqx; Fri, 7 Jul 2023 10:25:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlHaR2wn/uey7kH9mU0bjIhogiJ5tELjVhnPmfzdheJBbp9+oAmhEEec33W8mHEY4GKYC/4K X-Received: by 2002:a05:6a20:8f2a:b0:12f:5f2b:cbb0 with SMTP id b42-20020a056a208f2a00b0012f5f2bcbb0mr12570717pzk.23.1688750734768; Fri, 07 Jul 2023 10:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688750734; cv=none; d=google.com; s=arc-20160816; b=WlpkGkOa448z/QEyTkqwx1vFfyJ5zu0j42ib+wfX+1QS5umWXMEdwCqXb9bLR8JFzC Ww+NLCc+VRUN5sRfPC/8JxbGeHRKiSOi79NrQm8HA/IB8uHVm1hOQUr4hlyP5fwbc+PI l85sRaJKGCf4MtbxRWSmVpb4GLj5qWP9kxlxaaic3L4mHzjAhzYq5WpU/wCKk+SL27+s 9OojZlvOAU+t+/WFbZy+Gn1+R4ypCBGUVjIr7/sKqju1n9S58oudolVsMS6AM78JZlZ9 mZatL16m9N7lCepVOXTNbXn+/s4zsXyCZt63m8PWTSC3wpleduOPM1P1LQlMeNfCsJTW q0ZQ== 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=Aip5VpUJA7qveL6maeQFBeNCXZHRxiQ1qBeFLUBOMzY=; fh=P6Lk1G73ziXorgHY2pwMlBudbMoKnFNDjI5Fiv+tnlo=; b=0c1dbSCMzrtJwaygXbsqW6ixUaHiTkthnFQNPu8zQG7wi3LiLI2ndAo9zR9BiKT39U 5uUcB1Xk6nmOkY2bdcfERf3UzejjgpMmH6SE3qA60p6CSjqPAVawNiGI8T7kOBLEPSFQ 2K+XyJcTPGgBFsw0EuQV/9CFo5tS2n5qjwf26Z3Zqo/LyTAzMY42VeBOOMeNFrO+kCdO KZXmUdJVNXZi6qkxpZSGS0ube8xNS9tEXSz3fjb3I+sZFObt8k5kg9OEkPlZAFNMAgi9 2c54CbwSWlD5sgpmZ6P7buZ4UukV1Ji3d88vlZMtLiL5Ve02B2cHtlucfOq60U5lNSvF b6Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MDxu15Gc; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a632306000000b005486a1e9440si4112496pgj.780.2023.07.07.10.25.20; Fri, 07 Jul 2023 10:25:34 -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=@redhat.com header.s=mimecast20190719 header.b=MDxu15Gc; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232796AbjGGRYR (ORCPT + 99 others); Fri, 7 Jul 2023 13:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbjGGRXx (ORCPT ); Fri, 7 Jul 2023 13:23:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B8EF268E for ; Fri, 7 Jul 2023 10:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688750549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Aip5VpUJA7qveL6maeQFBeNCXZHRxiQ1qBeFLUBOMzY=; b=MDxu15GcpiPzwCEhxSQ7aJV6YH7VW243yWUyUwFgwUGzlh27Xcwzgyt+CGkHX5X9vY+xiH phLhxqPngfivKTxKKwYKnHFZDaWCS5x2zo//Ha0XcoWQFO6qvLRBTK+0U+SWXIsn02W7EW gFIBb6NCnNj30bW7FldqfGS0o/DY9WY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-323-Ux-cWTgLPMWsqex2O4QJDA-1; Fri, 07 Jul 2023 13:22:24 -0400 X-MC-Unique: Ux-cWTgLPMWsqex2O4QJDA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8CE8E2815E36; Fri, 7 Jul 2023 17:22:23 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D78D1454142; Fri, 7 Jul 2023 17:22:22 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Leonardo Bras , Frederic Weisbecker Subject: [PATCH v2 6/9] tracing/filters: Optimise scalar vs cpumask filtering when the user mask is a single CPU Date: Fri, 7 Jul 2023 18:21:52 +0100 Message-Id: <20230707172155.70873-7-vschneid@redhat.com> In-Reply-To: <20230707172155.70873-1-vschneid@redhat.com> References: <20230707172155.70873-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1770783490311283584?= X-GMAIL-MSGID: =?utf-8?q?1770783490311283584?= Steven noted that when the user-provided cpumask contains a single CPU, then the filtering function can use a scalar as input instead of a full-fledged cpumask. When the mask contains a single CPU, directly re-use the unsigned field predicate functions. Transform '&' into '==' beforehand. Suggested-by: Steven Rostedt Signed-off-by: Valentin Schneider --- kernel/trace/trace_events_filter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 2fe65ddeb34ef..54d642fabb7f1 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -1750,7 +1750,7 @@ static int parse_pred(const char *str, void *data, * then we can treat it as a scalar input. */ single = cpumask_weight(pred->mask) == 1; - if (single && field->filter_type == FILTER_CPUMASK) { + if (single && field->filter_type != FILTER_CPU) { pred->val = cpumask_first(pred->mask); kfree(pred->mask); } @@ -1761,6 +1761,11 @@ static int parse_pred(const char *str, void *data, FILTER_PRED_FN_CPUMASK; } else if (field->filter_type == FILTER_CPU) { pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK; + } else if (single) { + pred->op = pred->op == OP_BAND ? OP_EQ : pred->op; + pred->fn_num = select_comparison_fn(pred->op, field->size, false); + if (pred->op == OP_NE) + pred->not = 1; } else { switch (field->size) { case 8: