Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32241672rwd; Fri, 7 Jul 2023 10:39:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDQJPb1wEkyxAVr9MzfO4Ns36ggrzy3z2ote7N7dJkuBonS36UlUs9j4GFsQtjE6t5lSAY X-Received: by 2002:a2e:b041:0:b0:2b5:8a21:5627 with SMTP id d1-20020a2eb041000000b002b58a215627mr4264326ljl.51.1688751552227; Fri, 07 Jul 2023 10:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688751552; cv=none; d=google.com; s=arc-20160816; b=QS/AI10YPZDtmtusfxfaWlvskkYQjsNNStvLTkuqb4VF0hQvN4Y4i5NVpEfFRlO1En bnhsSBHo5Uqz4H2LJQk6IRWOs+YWrM/cPKFIGodiw6xhCSv4Gx2jX2a3HFPs92ZLDM2Y HIjjy1w0Ab1eUcacELKY7Cbm6PjVAV4xzV7O/2Oe+x3lehUeJqrj6B+L2RCycv3nCwXl 5uxM38azxYsvcDI8bGmg6VVNHlGbPlq9t1kfU5I6qyM4CDCjxBMjH8zjZ9fN78DGQkOP Bkf88ePwXEXrNnTACJp1ML/nkOx5p763TZj1n0iyobW9uCx/CBYbynAfZrVOcv8A1I1i rQ2A== 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=eoYdZ3j5mn2MTw1iUVYlPJSnwNWgHj3M8L9iz2kPLwU=; fh=P6Lk1G73ziXorgHY2pwMlBudbMoKnFNDjI5Fiv+tnlo=; b=O3YifdTdJN4r9++uK+sCZZ/X7nJnuCAS24bVgUdX20Sh9OE+rfyMNTNM1N6Ef31nrf FGWTKoUtD3HsNMB983OnakLshHMPAAuNkxMzVIikTAhRQTm7vI2Hs13ZOhLan0Yd3/ix fhoRaaRhZUZgvaPD0K7If0Tk2q5fePx2mfjRAszdN7hUd1eKdR0kGZP1jRhdkCzUlhxt kxfntjkIOrpyHI5qgJLD6zJGvIiZFKuwO4ySo6hHcwTYzNYCEJ2c9hxAVh1lujCnCeqJ hHtHQR1/JlObXs51tT7d7dUx2Ae8xeFsWFW+kIPsd1IvkSipjkSe/q4z7Eh07dmZSNcd LBhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="h2/rPVvG"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020aa7c54e000000b0051df3a080besi2652919edr.72.2023.07.07.10.38.47; Fri, 07 Jul 2023 10:39:12 -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="h2/rPVvG"; 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 S232879AbjGGRYA (ORCPT + 99 others); Fri, 7 Jul 2023 13:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232855AbjGGRXt (ORCPT ); Fri, 7 Jul 2023 13:23:49 -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 C95CA268D for ; Fri, 7 Jul 2023 10:22:29 -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=eoYdZ3j5mn2MTw1iUVYlPJSnwNWgHj3M8L9iz2kPLwU=; b=h2/rPVvGzM4GGOlFwV4rIr8J5lY+oOlyBndA7MkeH+CPH22Oss9CGml+2nMKWj+YyUz2Da 35vve46yiNh7+sebE10s3KEIatNitIekuDGhJbLW9PRf898njChQv5Ik+erAnA5K9YhKtS DyBKM5fgn2QMPOroecL9ubwk4T8ALwQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-473-8Elu-Jy4N9m2zwot3temYw-1; Fri, 07 Jul 2023 13:22:25 -0400 X-MC-Unique: 8Elu-Jy4N9m2zwot3temYw-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 44CBF83FC20; Fri, 7 Jul 2023 17:22:25 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BDADB1454142; Fri, 7 Jul 2023 17:22:23 +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 7/9] tracing/filters: Optimise CPU vs cpumask filtering when the user mask is a single CPU Date: Fri, 7 Jul 2023 18:21:53 +0100 Message-Id: <20230707172155.70873-8-vschneid@redhat.com> In-Reply-To: <20230707172155.70873-1-vschneid@redhat.com> References: <20230707172155.70873-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=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 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. In this case we can directly re-use filter_pred_cpu(), we just need to transform '&' into '==' before executing it. Suggested-by: Steven Rostedt Signed-off-by: Valentin Schneider --- kernel/trace/trace_events_filter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 54d642fabb7f1..fd72dacc5d1b8 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_CPU) { + if (single) { pred->val = cpumask_first(pred->mask); kfree(pred->mask); } @@ -1760,7 +1760,12 @@ static int parse_pred(const char *str, void *data, FILTER_PRED_FN_CPUMASK_CPU : FILTER_PRED_FN_CPUMASK; } else if (field->filter_type == FILTER_CPU) { - pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK; + if (single) { + pred->op = pred->op == OP_BAND ? OP_EQ : pred->op; + pred->fn_num = FILTER_PRED_FN_CPU; + } else { + 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); -- 2.31.1