From patchwork Thu Jul 20 16:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13320790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8299CEB64DA for ; Thu, 20 Jul 2023 16:32:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B3C9280134; Thu, 20 Jul 2023 12:32:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13D4E28004C; Thu, 20 Jul 2023 12:32:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED1F9280134; Thu, 20 Jul 2023 12:32:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DC66A28004C for ; Thu, 20 Jul 2023 12:32:58 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 878C31A01DC for ; Thu, 20 Jul 2023 16:32:58 +0000 (UTC) X-FDA: 81032534436.03.954668E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 807E140021 for ; Thu, 20 Jul 2023 16:32:56 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MYaenlVL; spf=pass (imf11.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689870776; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Aip5VpUJA7qveL6maeQFBeNCXZHRxiQ1qBeFLUBOMzY=; b=bOTmlnxZCpZZQTin/+kcYK+OoC6xZK0BC+Wf4+zCQSS08qSCuJnRhavezcVBpGSgzIgO77 Yt4V26LamLEHSLmKBQojQya/8hD9/+M8yDPGfh0stFUEJlrU/fpcA/flEa2bze+y3WAeJr kWo5sAANl8IEWGXMKkOChvpoBE5Iblc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689870776; a=rsa-sha256; cv=none; b=7bRu3521Ed+ZnbCrLLySaEp80IOgBm3ky1RiFziy6zAmApWO8Ux9vkeRwIIMYpGIyF348p hNvIJL1xlSw+XiUen3awBG3RA5aKKKk1V2JbMptUhs6wrt31bd21G22EVDE6b4xhiWsn7T niuTQ5Snc48XLm+uHvfz/mtup8KW1ws= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MYaenlVL; spf=pass (imf11.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689870775; 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=MYaenlVLJkgcNBDivtjWTMItStcvi/LlnUuEw8Ha4HMnoBJ+tYi6Zzb3czG3xCXbIYRe8N jZVvIm9XFJfHBF3ViE4LwzuC0I7Gc5XS5M5U09cWBWKjmRYAlHNDyDb36PuFNbvaHWqVsv Rq+UC1gypSGq3gPgcolG/Y1s+9eT3mM= 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_Wei=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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: 807E140021 X-Rspam-User: X-Stat-Signature: jfjetgg1fn5kcoggtscuokefgwsc1a6e X-Rspamd-Server: rspam03 X-HE-Tag: 1689870776-21522 X-HE-Meta: U2FsdGVkX195fagqgsKGJl6iZ2ntpMggOe/VinDgMSFcE90zRi9Ykc/pt/doITaZZ3F6IdQ5Y5WsO954JNPS99wytq/a+qmyb9Tu8aSK/wuJBM5iHGA3SV7Ci/c4Xz+0ASC2SJmTr1BwdZzS8USjXVMnf94Ebvsc6z2leLYlc3DwB1nbge4/k2e0+MhH02Z174Yhe5erJXJp96faLh6nYxL+917A83t1ulz4LeUUbcFbjVwZmSww9Wim0E0Nf28yhp0UsL6YNPIEJzhBi1PToRpInDQ8QBWPncghqbaRTEM2uvJFh0JxbYNDueBg6p+CCe3FiQkhyZmnP9QlK6tp4WZjziPzkls/XRNzMPaDcio1zBjdfccUI98cR/e63/MhjGsRVkL4zHBy81/Xkit2s/kpStNrwH75n1WjVN7IHXSUgcFEDYPr/JbDBdL1kMvdjTd5+K3fO6iq+X0uDlsicFo+1/DnN2ZM1U6QO3+rBTozPxQxuy79CYnYYbtVdiZFUfE+Ixyku3VeSKqdGQE4U2chh3yiDAOYDf8Ctaj9bNE/Vbd/lFi7uQEdpD/fwYG+COM8fHnCOxRz41xKxq2JkyFeNkhWzzbdrCMIFOgbTkOvCNgReT4w92OVtEZRzWZNmt0b2I6lipkLffN6XfpNEZlcTs+HIEupvvm1K87qISoduyJ9kQg6cqHV0JvmNiAS6rubNKbvcOQ1UM97X8JrmYffwUyfUEp0d++2VoiFNaeNULR4sQWUbqy3YzVzwmhWRsYmM2SRS8VcltvAa5UDgCpdC7plsXAxwc2Gi4V+kxpXz+/LkhGWMzIgTHDGJVfJ4X9eeQkQ3EvkHBCkxjTl76UDZ2ixgmUARyhQqRY+uuGSruUrN+V/SXKnmsIyHNOJGhcU7EKoQuybeDCCfxx3/ERkbK3jkPtU9pVy344PqnPtWAf9BhoTY8+QZ2B1T7Lrra3xpRMAQKTn6BpFa5c XgC5dP+R xmX8C6t1ix8QAdKPO0vi0Xa2W7/XpPyEJ7CDuqEdYK9R8FjDGeBRavLSD1Zfqu9LSViCvSjZr2svk5fANaPoReaMTI+4UdwlBCzEJUCT9772X+ix52VHKh6BbH4uHYTajy6q3nWmpUQnlRf5Oataes/VtiBgIaq8694i67Tix/Y0Vi0UnSkc8tuURG1+51w2K3ld6ibpk473lKU+tJYBuYdbPZ8lkJXzQ66sG1lh2titED1AdtzgQTJlZP/pSfwypB2gM47MgiFR6zJr6m7vEU28Wp2EwzlkKllcqgQGiYwbHR+5al9DcizktMoJUUIxJCv/ebIqLreSMeOlyK3mxkQaXJUfGiKZC+dTVJawIsRGkjO5BppUFczBRwg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: