Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4425586rwb; Mon, 31 Jul 2023 06:48:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlH4GJH8sD5oWRwMRcuUjWFX43TvOC6FKBf7GJw5R9esx90OtSDAMCdtrVDxYLAdSJi1xjXN X-Received: by 2002:a17:906:32d2:b0:99b:4378:a5ab with SMTP id k18-20020a17090632d200b0099b4378a5abmr6596424ejk.74.1690811312978; Mon, 31 Jul 2023 06:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690811312; cv=none; d=google.com; s=arc-20160816; b=K5crOFpbN5ujwK4bdx5Jkq2/oS4Ip5lwNto4fstlDnzpAKpqgwkXJoRimDAb6+TLWj Kuc4B7/4RtqZcoSVt8TQXns4mDHJ9e2Y1KYgYj7Vv/zMMj9WPk+HRn5dkI9/iuwcFX21 GPbaXhEmcMJ2ZSIDODuTgrPQ9j5R9dLivvK9aQSKyvGL8mfvF0E/43Bini5GjPWnA1t0 DzrCfNrJSL8q1dW6Q9uGVFAAEdZ+fvYwV7Rt7OiqKXpN7Hv6VBIGMIqIRSKio3mbTF9A h8h7Nyc8KrOblVfYPFLJV6YJTriBTUwrx8OWku0CCPlXx0kqRMSmy2ZT/QoPVqJJKvtX K+Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=47HAhqvJlrFOjF3d3mT+sXNh9SqjQbM0s/wrTjkOtJg=; fh=Ejtt3dFxnxi3yKhXZZY2OGvzdqp9Pq+UrfnS0/l9k7Q=; b=K9RF27y2W1THSR+ppI81Qd7UZbHLGSPxZmgm3FmpCccSOkrjQEk3g+hxklQDLk07Yj F9ul3wfWjMTIVmb2DdouRbxB8X9XHylHYF8MB6YtXwHU9NTULg0AyRhoBGllub76h8qP l38s5eOhvFNSJ3bs4MKBU0J9q2ymwsN9nXv2Pi5ITI1njsa9uPVu0dN3jzCHCxKHc2ug wOpPd52t7I6C0L8K7cwyzT6HHTNDV6z7hCuhoLNnOr/x3YTFbZvqHOqAfMjq9uImcLcA xFA+RNRbYoktbTJYQ2BawBTNuTOWAaicx3hThPp0dQZLZh7gif+wz14Y8tWiA5AZwEZD 2TpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="i884zA/q"; 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 z17-20020a170906815100b0098d9dfee9c7si7160621ejw.493.2023.07.31.06.48.08; Mon, 31 Jul 2023 06:48:32 -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="i884zA/q"; 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 S232387AbjGaLV5 (ORCPT + 99 others); Mon, 31 Jul 2023 07:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232550AbjGaLVq (ORCPT ); Mon, 31 Jul 2023 07:21:46 -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 4FC7910CA for ; Mon, 31 Jul 2023 04:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690802454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=47HAhqvJlrFOjF3d3mT+sXNh9SqjQbM0s/wrTjkOtJg=; b=i884zA/q0qcP8cVnklnRkqGFucfkUGfvK7wvaYeRfGvH0v5btCjeJko+jL59jUXEjgv2qJ MPRE9bRchFfjhtldOnlZjW/z4MQfoKk9X3i254FEmWGuMp6bis0uH3kD2TJVA9OVvafBdu cvHkLTqJEERxMkTOxNDOZBYeEqHfCf8= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-333-hK5rRkUDPQi-qvdSn2CHoA-1; Mon, 31 Jul 2023 07:20:52 -0400 X-MC-Unique: hK5rRkUDPQi-qvdSn2CHoA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-63d09e8bc06so33398406d6.0 for ; Mon, 31 Jul 2023 04:20:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690802452; x=1691407252; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=47HAhqvJlrFOjF3d3mT+sXNh9SqjQbM0s/wrTjkOtJg=; b=jrOhfHz1VpWTg6brCxcz5BDV5WDHWuNzJSucRInd8zL5surDtCJTQz4bf5mjMyMsfP IgGTY8G64FIDhG4PvTtUIvkGXxf7cBwY3KkfHDWOWAv3/aBtZ4DIp9un4CDVP406l4sK 0MzMY1iKM9gcT+ZnwSc9mnZW3OEpk59BR+iJLrUu9sKCCwNNlcqJAb85g9lrv4whMcbD nbtDRlpbWEc5C7Sp1tlVjUEO1ipbY35cxQnviAEbLIee37mn06Ml2c2i0oTxuef/PMKb bcbt+jBpy2gQ89lIdK15dGNrJXLFgZa/uX6wASpIWFBC03mvDdgA6k1Q5mAa3J7CbUYf tuyg== X-Gm-Message-State: ABy/qLbWsOryvyBF3YN7tWTz6hnC2wK+Ldlpm0v4xjmbzsWdOllGRLJ8 mprxOGrezEODmEl9vRwupKLlOQJejhkxxtzLyJARlcAFmyTly5IHb7O5sC/80yIQGicLW5Wzydn PW/xR/twboGp2wp/0B3xKSbFL X-Received: by 2002:a0c:e14d:0:b0:634:20f:471c with SMTP id c13-20020a0ce14d000000b00634020f471cmr6609355qvl.14.1690802451988; Mon, 31 Jul 2023 04:20:51 -0700 (PDT) X-Received: by 2002:a0c:e14d:0:b0:634:20f:471c with SMTP id c13-20020a0ce14d000000b00634020f471cmr6609334qvl.14.1690802451661; Mon, 31 Jul 2023 04:20:51 -0700 (PDT) Received: from vschneid.remote.csb ([149.12.7.81]) by smtp.gmail.com with ESMTPSA id n2-20020a0ce542000000b0061b5dbf1994sm3583834qvm.146.2023.07.31.04.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 04:20:51 -0700 (PDT) From: Valentin Schneider To: Steven Rostedt 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?Q?Wei=C3=9Fschuh?= , 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 In-Reply-To: <20230729155547.35719a1f@rorschach.local.home> References: <20230720163056.2564824-1-vschneid@redhat.com> <20230720163056.2564824-7-vschneid@redhat.com> <20230729155547.35719a1f@rorschach.local.home> Date: Mon, 31 Jul 2023 12:20:41 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain 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_BLOCKED,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 On 29/07/23 15:55, Steven Rostedt wrote: > 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; > That's neater, thanks! > -- 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: