Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29496601rwd; Wed, 5 Jul 2023 12:44:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+4mDAfxj/mpwEZZ9xy+FoTP1kQYd/TCz3kuIgoODlH0cPWdHih/4YR4ruAy1PL4TynF6k X-Received: by 2002:a17:90a:1946:b0:263:ac11:c6d2 with SMTP id 6-20020a17090a194600b00263ac11c6d2mr10037182pjh.25.1688586296085; Wed, 05 Jul 2023 12:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688586296; cv=none; d=google.com; s=arc-20160816; b=xonPvGBw6SuueU/fm3zBKMm0gXJ7Jy8oadVI6R7sWt6k+WR/Zj/cEAOlbCtmv3pXKH X23mJ6QW/7eBpikD22Wx+51TR+lp5BL9fHLQn3Gu4oKeZVkRRKTgYddboyT+NwXoUdCq GGXiyIFDJhuKTy1KE5i99cbrMGFtSqhqLs1qGw/T0/0r9bCgRtpuZ5sp9X84Xeh0Q3Fb 7tKEkbrs7qIlyPLKLJjAg1qa/c6z4FiOU6PAsLl1LXsUpZQH6raZfP8wYJBf4Mu71I7y dyu20t5vjNQ9YLMz/iI5VRPXgUQFNw0m//omg8TW+ftHg8P8ywGST2QDck2ZOWw42aVq bPJQ== 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=PiVQ8ZDEPXhtvkcRdl3bfl3WjN+tGTKZiEw5vKQXRQo=; fh=R37TXGFyrceOULfX8QrRCcMkCYaA26kSsPGi1UG+nBk=; b=FkaUj4wRNqW/ZepvcpA3L7jzPBCzQl3eDSc/TvCEr5FB9epxZEmqDn30WkbrqV6xHz kibdYJVO2eYpaakfxvmhwyzUdVBn5NSBwD5FC8yL50rsPLl0ucumT80i0fTSDA81oLN7 DN/qRN8CeJFuUvEJ8l5d6FVSjQkoovDgMoLXNul86mebCHX/enddVdl/LFBTwVCITRLv FmUokI4iUD2buQtdy3WDOedrJ7Zf+VkwP40ZeKi5dVVs/pbXjm/Ty4txRzbmGEI1nyo/ S6jTTabhEpALHDD6V3ifXTP6eF/RvqA7ZckJOYsVpD+ZODXOPaDRMB9p0me5rNFbIRM0 zfRw== 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 bh21-20020a17090b049500b002637d779bf3si2251534pjb.17.2023.07.05.12.44.40; Wed, 05 Jul 2023 12:44:55 -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 S233276AbjGETAj (ORCPT + 99 others); Wed, 5 Jul 2023 15:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232938AbjGETAg (ORCPT ); Wed, 5 Jul 2023 15:00:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 767611998; Wed, 5 Jul 2023 12:00:20 -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 1449D616D1; Wed, 5 Jul 2023 19:00:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD2C4C433C8; Wed, 5 Jul 2023 19:00:14 +0000 (UTC) Date: Wed, 5 Jul 2023 15:00:13 -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, 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" , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , 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 03/14] tracing/filters: Enable filtering a scalar field by a cpumask Message-ID: <20230705150013.5ba7ddb8@gandalf.local.home> In-Reply-To: <20230705181256.3539027-4-vschneid@redhat.com> References: <20230705181256.3539027-1-vschneid@redhat.com> <20230705181256.3539027-4-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=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 Wed, 5 Jul 2023 19:12:45 +0100 Valentin Schneider wrote: > +/* Optimisation of do_filter_cpumask() for scalar values */ > +static inline int > +do_filter_cpumask_scalar(int op, unsigned int cpu, const struct cpumask *mask) > +{ > + switch (op) { > + case OP_EQ: > + return cpumask_equal(mask, cpumask_of(cpu)); > + case OP_NE: > + return !cpumask_equal(mask, cpumask_of(cpu)); The above two can be optimized much more if the cpu is a scalar. If mask is anything but a single CPU, then EQ will always be false, and NE will always be true. If the mask contains a single CPU, then we should convert the mask into the scalar CPU and just do: case OP_EQ: return mask_cpu == cpu; case op_NE: return maks_cpu != cpu; -- Steve > + case OP_BAND: > + return cpumask_test_cpu(cpu, mask); > + default: > + return 0; > + } > +}