Message ID | 20230720163056.2564824-8-vschneid@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 C148FEB64DA for <linux-mm@archiver.kernel.org>; Thu, 20 Jul 2023 16:33:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64791280135; Thu, 20 Jul 2023 12:33:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D0A828004C; Thu, 20 Jul 2023 12:33:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4237C280135; Thu, 20 Jul 2023 12:33:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2D1A928004C for <linux-mm@kvack.org>; Thu, 20 Jul 2023 12:33:06 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C9E87160210 for <linux-mm@kvack.org>; Thu, 20 Jul 2023 16:33:05 +0000 (UTC) X-FDA: 81032534730.03.708B7E1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id E6F70A0025 for <linux-mm@kvack.org>; Thu, 20 Jul 2023 16:33:03 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HydDn72C; spf=pass (imf15.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=1689870783; 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=eoYdZ3j5mn2MTw1iUVYlPJSnwNWgHj3M8L9iz2kPLwU=; b=eI8c9v4AXJmUnxSKzphLh4heUXZvZKotRHiRq4sbioLO510RKbqycovZCI8MnnITDhB7Ex S80Z2sBVGzSJHnkexsqcWsnyN1SURafJ7ql48X6KqcL38qdxF0kuq0rTtUU6/K12BbyIta EG5DdqYJfULIJZ6qPuToh29JjIjn/2k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689870784; a=rsa-sha256; cv=none; b=M3/4igfOIo68isEM7HN1dq0PJszeX1EGYyZbYfy48txd2k3V0wrz5KJoATYno/eDjCUh18 EYBcicmZC56VsOeM/9j+KdJM0rKyM1RAieVGU2PdfpAXe5E/haYr4m/9OLrYFr2VxT+AT3 Mqi5VHIjQ5+29s6qHckWu+ILivxDIn4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HydDn72C; spf=pass (imf15.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=1689870783; 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=eoYdZ3j5mn2MTw1iUVYlPJSnwNWgHj3M8L9iz2kPLwU=; b=HydDn72CehzrZvIyJPDBlvtdLiM6MpixhN2qMqtTinigwG/7HU4e0olqgpIn9cuSSQLoGb C5MmBi5fFL+l/9EY0pJ/fkQA5rt04R8VqJnFuIe/daNQRYTS1LLMjJblGUPa7xwlvT4lR0 JpOWIcbZIvhcQu2fXLAfo6Du0t/UFCc= 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-646-xF48V0OiM2SJcrNgAEdCkA-1; Thu, 20 Jul 2023 12:32:57 -0400 X-MC-Unique: xF48V0OiM2SJcrNgAEdCkA-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 C1AF3936D28; Thu, 20 Jul 2023 16:32:54 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1F9740C206F; Thu, 20 Jul 2023 16:32:46 +0000 (UTC) From: Valentin Schneider <vschneid@redhat.com> 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 <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org>, Jonathan Corbet <corbet@lwn.net>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, Paolo Bonzini <pbonzini@redhat.com>, Wanpeng Li <wanpengli@tencent.com>, Vitaly Kuznetsov <vkuznets@redhat.com>, Andy Lutomirski <luto@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Frederic Weisbecker <frederic@kernel.org>, "Paul E. McKenney" <paulmck@kernel.org>, Neeraj Upadhyay <quic_neeraju@quicinc.com>, Joel Fernandes <joel@joelfernandes.org>, Josh Triplett <josh@joshtriplett.org>, Boqun Feng <boqun.feng@gmail.com>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Lai Jiangshan <jiangshanlai@gmail.com>, Zqiang <qiang.zhang1211@gmail.com>, Andrew Morton <akpm@linux-foundation.org>, Uladzislau Rezki <urezki@gmail.com>, Christoph Hellwig <hch@infradead.org>, Lorenzo Stoakes <lstoakes@gmail.com>, Josh Poimboeuf <jpoimboe@kernel.org>, Jason Baron <jbaron@akamai.com>, Kees Cook <keescook@chromium.org>, Sami Tolvanen <samitolvanen@google.com>, Ard Biesheuvel <ardb@kernel.org>, Nicholas Piggin <npiggin@gmail.com>, Juerg Haefliger <juerg.haefliger@canonical.com>, Nicolas Saenz Julienne <nsaenz@kernel.org>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Nadav Amit <namit@vmware.com>, Dan Carpenter <error27@gmail.com>, Chuang Wang <nashuiliang@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, Petr Mladek <pmladek@suse.com>, "Jason A. Donenfeld" <Jason@zx2c4.com>, Song Liu <song@kernel.org>, Julian Pidancet <julian.pidancet@oracle.com>, Tom Lendacky <thomas.lendacky@amd.com>, Dionna Glaze <dionnaglaze@google.com>, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= <linux@weissschuh.net>, Juri Lelli <juri.lelli@redhat.com>, Daniel Bristot de Oliveira <bristot@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>, Yair Podemsky <ypodemsk@redhat.com> Subject: [RFC PATCH v2 07/20] tracing/filters: Optimise CPU vs cpumask filtering when the user mask is a single CPU Date: Thu, 20 Jul 2023 17:30:43 +0100 Message-Id: <20230720163056.2564824-8-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-Rspamd-Queue-Id: E6F70A0025 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: mpachqug9ekfua3cphjfiarctpqfnwo6 X-HE-Tag: 1689870783-436012 X-HE-Meta: U2FsdGVkX19cadC6isKIWs3o5YN3inuyOmqb2uF4Pv1MMssgrVTV+8BStRAjaAgqoEsPHul81d2IbM0+Fb5ktoViuYRcIlnwbF/Y8ma+qnW97Piqe9CcBUhsnGsba6KMyY5kJo5E83jnsVhOXacWu7d/NmPiEV6/xcFpOQgfFeVWBPghcM1hBU0MFSlocnVKJxfk5L1tGW2UqP+5BbM8FZMax/YHBuJ2QwcCmXZVTY6jIXLMxPYhXfOnNeDIoueM/rZukXMsafhunPe3bViHQWSLLBRBhQs2EBc/GXLqVFTeatB0wH7mSSSuxNxOs7KJN56cnbh77sR7WgCcK2W6Sg/Rg9JirE+D8sc3+RBgr4IS58yJIqb385O12czoUm76jBUxLmU2qZ6psQoy81AfK0IghjNePZTh62EFKMa9cN54086ocpe9E7fFubsC7gahO1xYRv5VpDifIxL8h7QjIo+RU033LW0zFg+OMxbgj06mc8GUaVAjgzbz64zssGglYAEzKP+ikp5ZAWVzb2nmwTBuXY2SXLAOdLkOlcVHutPxPKHP6KbWLl0KRuk3uUaNKscMV0daluE4/Er6/cF0rldzHEHxUysmSURpTHTU7XrYKI0uOSZVGi24xmPfXfDP9G6IwIH6fOfMBmqXaJPQWI52dIVETYI+zbOBndeBCm9tuxdpyL322fNdgkFLkBlaNcsZYzcvwJMWvcmxmhy4hGRSTLbiM+WbCQDp9KfdHKMD7EtyWz8GZv4yhhZ+ZLqp3VT57sPooP6fDR6G1QWjNTLyY9JYfdYUZINuecYN0J6ejneSC5rzYqbXMVbOy+cnIoJbw+qaP+NBYi7ukzW8Y3GeQWICRuW5KfFZnp6MUSE/1PLlQBdmo//zy+DGdjozbVHub+Zd37a/IQSAHajRtpmC9cpCSz2nH+CZbnFN64gKR1HwNleMENgL5fW5jX9xaq8j/TOX5QUH7uUkr7T ZABqgMJF Z7upb5zpPiPGPon8JkfOfEGskPDGIOtlR6Ffile/hksT4MI0unJc9dluK3oQR4DWJHc99aDTECmNCM2mMsvS5xtZnUo0tPlkDu00Z5Ts6+m84EBgfIpF08uEkfH8F7ENzJjqtaMDTJfyqED6B0u2M0PDobSrfOvis9P/6d9541Vu+SqqQHCenFkv3gayXOcXJrq9R/7DflRTb5DlCD9WV+vNmlJPeCrr5YVioDlCGSNNqljma4JEWWGLLhNZ9b+kydyYkUl5M+YmDNyiuLLW3kmARkk4YynBqmQ6OTOGMWn/LtBeGXvxOTLIWQ+okppGLxLb6Np9DYBrU41FdpeX4iFS562fcJ2LpI2pZ5EnQtA0vd77BYaYD8BwBOg== 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: <linux-mm.kvack.org> |
Series |
context_tracking,x86: Defer some IPIs until a user->kernel transition
|
expand
|
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 54d642fabb7f1..fd72dacc5d1b8 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_CPU) { + if (single) { pred->val = cpumask_first(pred->mask); kfree(pred->mask); } @@ -1760,7 +1760,12 @@ static int parse_pred(const char *str, void *data, FILTER_PRED_FN_CPUMASK_CPU : FILTER_PRED_FN_CPUMASK; } else if (field->filter_type == FILTER_CPU) { - pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK; + if (single) { + pred->op = pred->op == OP_BAND ? OP_EQ : pred->op; + pred->fn_num = FILTER_PRED_FN_CPU; + } else { + 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);
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. In this case we can directly re-use filter_pred_cpu(), we just need to transform '&' into '==' before executing it. Suggested-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Valentin Schneider <vschneid@redhat.com> --- kernel/trace/trace_events_filter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)