Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2755212rwb; Sat, 29 Jul 2023 13:20:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlFHqK7ogzYswDoBiWFXPekBTacs4MDlidcFjEvoZ/LlniQZBSj1vEyh1w5oCo6mdflm5rUl X-Received: by 2002:a05:6a00:cd1:b0:67f:3dcd:bc00 with SMTP id b17-20020a056a000cd100b0067f3dcdbc00mr7443534pfv.2.1690662020697; Sat, 29 Jul 2023 13:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690662020; cv=none; d=google.com; s=arc-20160816; b=ZaqIOgx2ogFowvx9PCaJvi5zWI9QGl/IgGDKRLQmwc7ZUIQxfLHKffZ54mLao0iJtd XYEnPnTMIKz60nKmY6tp8L7qECLYNcMM7FKh7AMYpIpgoyEjLEgNYQnus3cM1klGqZWH /dlg90qndkAbzoaniR6iJgmxJXInS7NmQFRoQRgMyC0QaWvvBl/u0LB9wR9tBqqoE22h nlo1iKuAIdcy2udbhaNdXs+gOUaDIQCmOLs97BiLUjyXQcqgofqvuRA5YzK8/vmjCjz5 VJ0KN45pjx3gGGrHv1OOT2DFmtWauHhFPcyw1QacfGgUXSxZMxZKZgRQxs2jgtIu8bv/ bnTw== 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:subject:cc:to:from:date; bh=h6miVVzjsO87Gxv82Zzfj8Yza+IeNbksTDhhqv517Mk=; fh=3KuZ0M+Yi+tte/s7IQ3weUkTaeJvZGvlQtl/qM5CMHE=; b=S5DWKDnEplqV3zE9Fe2QmG2sIH7b1rDGrN9ApbD5XWYUuSP3CSQSViED8ahd+ZXKwy Cgc7l3ZBhfxyadXGf3g+PUwTlTmWhRtWSCHleXm6bZj8QSMUjQQJxETRaKQQqo4ZD1xL utK8utp0IKKOyKvPeyFJQ+vK6e91tYJLn0AZlR13uGRhaAY49THrBRDIAqqZsLouV7lY VI4u8ELLUqhK8ffRxObI7SF/kbKtGYW543J5PiLn9Fu1e2dRW0ZseOrTgC7Ai9Oimb3n GLAy4TnTGJ4dN/Ul6DHWs2ZLE2EBC3lOSRhXipL2oFqaJmXjqiLWFuA8/KTTN8bm7pIp vbzg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a056a0023d000b0068715271fe9si2621864pfc.111.2023.07.29.13.20.09; Sat, 29 Jul 2023 13:20:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229932AbjG2Tz7 (ORCPT + 99 others); Sat, 29 Jul 2023 15:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjG2Tz5 (ORCPT ); Sat, 29 Jul 2023 15:55:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3343730DC; Sat, 29 Jul 2023 12:55:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A52AE6066F; Sat, 29 Jul 2023 19:55:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA441C433C7; Sat, 29 Jul 2023 19:55:48 +0000 (UTC) Date: Sat, 29 Jul 2023 15:55:47 -0400 From: Steven Rostedt To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , Jason Baron , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Nadav Amit , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: Re: [RFC PATCH v2 06/20] tracing/filters: Optimise scalar vs cpumask filtering when the user mask is a single CPU Message-ID: <20230729155547.35719a1f@rorschach.local.home> In-Reply-To: <20230720163056.2564824-7-vschneid@redhat.com> References: <20230720163056.2564824-1-vschneid@redhat.com> <20230720163056.2564824-7-vschneid@redhat.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, 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 On Thu, 20 Jul 2023 17:30:42 +0100 Valentin Schneider wrote: > 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; Nit, the above can be written as: pred->op = pret->op != OP_BAND ? : OP_EQ; -- Steve > + 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: