Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29413468rwd; Wed, 5 Jul 2023 11:26:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRciBd3/E6TsjimCy3feWSNNpx+vb3LW90j1TMk/MG2LSX1jcsVNBX67OhI43yxjnzL0Nf X-Received: by 2002:a05:6a20:7f9b:b0:12e:b02c:99e3 with SMTP id d27-20020a056a207f9b00b0012eb02c99e3mr10631819pzj.50.1688581569774; Wed, 05 Jul 2023 11:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688581569; cv=none; d=google.com; s=arc-20160816; b=LWNQvHVObZ7xbgwzI/jOzFCDWSqjBhgEFVHbvf8BJdDBjLjP9eDr+6+0IR0RZQ9FMh UDz5UkBkSqjf2xZQPtwM+cIBJ8CKwl4yv7Tp0aKxWR9cRR5PCcTwJUlQrwggNWetAEBV ftTyfcAyP7bQF+dQLx07WBbqRD305TqHbRLdYzaV9lHKvO3cOAsG8zJzwlYrJw0hSdvD VVz0BYmTcpNjYghnXIQduT1+kbxQ3MPVfEO7xrcm0+RQVdR6Uxz4k62WUNlXnOmMNLhg ymxhxBH9F45NF9fxR22GRWT8VTu585JKbZDbE3KwPL5m1W6hcvRIzYwZS1ptuFSfIUtg Erfg== 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=HhCGDFDeE6330wjTb7+eVdOM5sDQ6eAc/Pd0Q124xLM=; fh=dVCMRuKhK2aqTEuWethYlqkP4G2sINJQEE+rq5xoO1c=; b=SdX2NRkOFVzHIlc/1mQEyABhr3JD58ifCgx6+3LLGPcORx5QH5R7kirvRqbBmGfhBK PifgBOql7B5ggujP+2y8M8q4BgnBVnaMJFrSDJ0LB3qOIA83u+eBNZgdsVF6Rn5FgSte XyWsI4jGqW+WmLKExujMixXnKmAa6ZG/WkTHYmnys35JnBthpX8RRtUesTdq4EIhJi0k sRfFFObsv1Dw95yV6StIx2Y6uOoYhZg9Vxfd4BNcAguCmGarCmKSYOyf2dVhTGIYBFl9 Ou0okzW1O5qsfd/z6X6ydj0ywPMK1lyiHPMRGfhhEHsy46dG+399LF+akzNroEMgFfe6 DYdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JXLEHIrX; 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 w8-20020a1709026f0800b001b8ba6a45d2si118589plk.245.2023.07.05.11.25.55; Wed, 05 Jul 2023 11:26:09 -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=JXLEHIrX; 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 S233413AbjGESRd (ORCPT + 99 others); Wed, 5 Jul 2023 14:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233364AbjGESRX (ORCPT ); Wed, 5 Jul 2023 14:17:23 -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 6E4681996 for ; Wed, 5 Jul 2023 11:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688580990; 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=HhCGDFDeE6330wjTb7+eVdOM5sDQ6eAc/Pd0Q124xLM=; b=JXLEHIrXZ8qSc83jvJFjrhnw4PSubmsefZZkcKlG3RA6GBOiwTPvWvGq//pY60d7HUoo3w G/ZWUW56KM5lSQ5VVzp5DoYJ0clhliPBL4yIj86B5w3eLyESLpIJnQgSE/GErxFIpUc6TG 4cIjxWoNWix2dhXpSrx0Hf1+nwcfVec= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-630-9fom_J9fNdKBOQiCT3xrlw-1; Wed, 05 Jul 2023 14:16:26 -0400 X-MC-Unique: 9fom_J9fNdKBOQiCT3xrlw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 930C32808E6D; Wed, 5 Jul 2023 18:16:24 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E602BF5CFB; Wed, 5 Jul 2023 18:15:54 +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 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" , 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 , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: [RFC PATCH 04/14] tracing/filters: Enable filtering the CPU common field by a cpumask Date: Wed, 5 Jul 2023 19:12:46 +0100 Message-Id: <20230705181256.3539027-5-vschneid@redhat.com> In-Reply-To: <20230705181256.3539027-1-vschneid@redhat.com> References: <20230705181256.3539027-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=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 The tracing_cpumask lets us specify which CPUs are traced in a buffer instance, but doesn't let us do this on a per-event basis (unless one creates an instance per event). A previous commit added filtering scalar fields by a user-given cpumask, make this work with the CPU common field as well. This enables doing things like $ trace-cmd record -e 'sched_switch' -f 'CPU & MASK{12-52}' \ -e 'sched_wakeup' -f 'target_cpu & MASK{12-52}' Signed-off-by: Valentin Schneider --- kernel/trace/trace_events_filter.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 99e111c237a93..b3d2612d4670a 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -68,6 +68,7 @@ enum filter_pred_fn { FILTER_PRED_FN_PCHAR_USER, FILTER_PRED_FN_PCHAR, FILTER_PRED_FN_CPU, + FILTER_PRED_FN_CPU_CPUMASK, FILTER_PRED_FN_CPUMASK, FILTER_PRED_FN_FUNCTION, FILTER_PRED_FN_, @@ -933,6 +934,13 @@ static int filter_pred_cpu(struct filter_pred *pred, void *event) } } +static int filter_pred_cpu_cpumask(struct filter_pred *pred, void *event) +{ + int cpu = raw_smp_processor_id(); + + return do_filter_cpumask_scalar(pred->op, cpu, pred->mask); +} + /* Filter predicate for cpumasks. */ static int filter_pred_cpumask(struct filter_pred *pred, void *event) { @@ -1436,6 +1444,8 @@ static int filter_pred_fn_call(struct filter_pred *pred, void *event) return filter_pred_pchar(pred, event); case FILTER_PRED_FN_CPU: return filter_pred_cpu(pred, event); + case FILTER_PRED_FN_CPU_CPUMASK: + return filter_pred_cpu_cpumask(pred, event); case FILTER_PRED_FN_CPUMASK: return filter_pred_cpumask(pred, event); case FILTER_PRED_FN_FUNCTION: @@ -1654,6 +1664,7 @@ static int parse_pred(const char *str, void *data, char *tmp; if (field->filter_type != FILTER_CPUMASK && + field->filter_type != FILTER_CPU && field->filter_type != FILTER_OTHER) { parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); goto err_free; @@ -1698,6 +1709,8 @@ static int parse_pred(const char *str, void *data, i++; if (field->filter_type == FILTER_CPUMASK) { pred->fn_num = FILTER_PRED_FN_CPUMASK; + } else if (field->filter_type == FILTER_CPU) { + pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK; } else { switch (field->size) { case 8: -- 2.31.1