Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9819844rwp; Thu, 20 Jul 2023 10:06:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlGP19bsmszUDvIGfSdGn5Yf9GZOPYjJGdxnfRUoZoc3I5p8xbQGCfrBeLcrY83lQWUfsnA6 X-Received: by 2002:a05:6512:23a5:b0:4f8:710c:e2c7 with SMTP id c37-20020a05651223a500b004f8710ce2c7mr2353146lfv.33.1689872801615; Thu, 20 Jul 2023 10:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689872801; cv=none; d=google.com; s=arc-20160816; b=PsTERlIOF0N8P3vlbPfRYo/Sd5N0L3zGmDNcohR2+sZ/VnVFBLL94zGSvrCmEFqyoz Sz2NYA7lXDAhSliuziqaDZ7ZBuD5TSg3KJW1+Aa6nDCfDzK5bG7myVJhvTQc08nTVX92 2cd3VSfBP3Cforcj5ugHng18BYn5onSQ+XL5G3JL+LI1hq+CkZM0bmuCmjEHF24u2rgk D75ycdaHATglNB7ZRBzizzrlNuVUzbImbLoLw0Ur+9p6Fgv7faQLdTtWX2VnyC4zohil dVhsTxeVXc0JlDTgCQ/+a2fZOfcArbZJHgvHWTEHTJFnNFoQ+WwY0Saw9xVjNM5uydKY gdpg== 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=PtaPM/evcxdC1AWAoNYkNA7d0RyqsevCG9x/XhoE/I4=; b=igAa1+MehImPEeJV6ycNuX07SRC9WtZX/nGCn1l6Kw7VBfFbSTJOv6gHMvNFETv6nW AjEh0lmwBKvIMv68jf+VPCYz/qiepGxT6xWK4hvhvjqHY38GbTnRXNUcJ64kmHGu2LWd KMIW8gy2h60BYVTmB0/ZoVXcQYG9FegZLdyZzUwqJBWlYdEiKaFwX2E/9bxGPAN8mzxt hXUH2KYaMrFj3UppERQjCRRs9JyXZTUUEydhe/oRBCWLaspfQL07ZGlMnsH5bpYI/CRd ZBSEGN3tNH/G9xs1KD6shklDhANllx24B5fiQ0PhkaCrx4L6NHrNtfpXYJt12o3mSUDT UY4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XWfFkNjF; 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 k8-20020aa7c048000000b0051e0fa84ec8si969798edo.183.2023.07.20.10.06.00; Thu, 20 Jul 2023 10:06:41 -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=XWfFkNjF; 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 S231614AbjGTQd6 (ORCPT + 99 others); Thu, 20 Jul 2023 12:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231556AbjGTQds (ORCPT ); Thu, 20 Jul 2023 12:33:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA43A19B5 for ; Thu, 20 Jul 2023 09:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689870773; 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=XWfFkNjFh9W1M2PllnU/1UWFnlbphgIrFBv3NEVA8Qtk8yvikWDNsuJXcBpnt9j+VMtuBp YPSEMbBp5U+Kkkkh5INe2ZlaUFU6sCBBsxZakCwSYGX/r0zkVm1nJPdJzdlC+mVVmQ/iOK Yf0ltBHhj1XC7ll+JrfET0QrpyesGuc= 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-660-hS_t_EPEMJWOi3NXCeMnHQ-1; Thu, 20 Jul 2023 12:32:51 -0400 X-MC-Unique: hS_t_EPEMJWOi3NXCeMnHQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91B94901848; Thu, 20 Jul 2023 16:32:46 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8DB640C206F; Thu, 20 Jul 2023 16:32:38 +0000 (UTC) From: Valentin Schneider To: 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 Cc: Steven Rostedt , 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 , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: [RFC PATCH v2 06/20] tracing/filters: Optimise scalar vs cpumask filtering when the user mask is a single CPU Date: Thu, 20 Jul 2023 17:30:42 +0100 Message-Id: <20230720163056.2564824-7-vschneid@redhat.com> In-Reply-To: <20230720163056.2564824-1-vschneid@redhat.com> References: <20230720163056.2564824-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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. 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: -- 2.31.1