From nobody Mon Feb 9 17:37:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1710779779; cv=none; d=zohomail.com; s=zohoarc; b=XIOrxYiPal9UO3pwMUNKKeE/zvFT2Oc9FHuxZQ2POkVX9WoJ8Ve/li1Mv5AVLT1vqdUddyJa+zBmT0s6EdPF/tCQWGzffQ8anvLERzO2AZMQKmjCaoMmZ6X2HiBcZ7A1dryHY398GQrxTvn/+m68yV9j8imL6wwXRZLRwdeN5ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710779779; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Cpzmmaoi0pJueucz7Za6oBj+S2IXaqOnagU2yAyCJ44=; b=LlfsoTVHnZEIa7IC6YcTc12Y2YwqKIefcDCy5t1YTizAo/WVvPBM8xJ40FEXGCv9weL3Gnxx4GKefJEYBSRJ9ivrxzEoXIg6L9dpVekg3FJc2Q7Jbx4yUAlftBIFUjXp5z5Iy1opHfKhuXN5wQVLVKKirMlvc0oYTzCiY1KSpb8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 171077977928572.95705840787593; Mon, 18 Mar 2024 09:36:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.694891.1084109 (Exim 4.92) (envelope-from ) id 1rmFxw-0005LR-A4; Mon, 18 Mar 2024 16:36:00 +0000 Received: by outflank-mailman (output) from mailman id 694891.1084109; Mon, 18 Mar 2024 16:36:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rmFxw-0005L7-5P; Mon, 18 Mar 2024 16:36:00 +0000 Received: by outflank-mailman (input) for mailman id 694891; Mon, 18 Mar 2024 16:35:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rmFxu-0005JO-W2 for xen-devel@lists.xenproject.org; Mon, 18 Mar 2024 16:35:58 +0000 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [2a00:1450:4864:20::632]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 98c415ae-e545-11ee-afdd-a90da7624cb6; Mon, 18 Mar 2024 17:35:57 +0100 (CET) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a468004667aso469316066b.2 for ; Mon, 18 Mar 2024 09:35:57 -0700 (PDT) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id j22-20020a170906051600b00a441a7a75b5sm4988894eja.209.2024.03.18.09.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 09:35:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 98c415ae-e545-11ee-afdd-a90da7624cb6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1710779756; x=1711384556; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cpzmmaoi0pJueucz7Za6oBj+S2IXaqOnagU2yAyCJ44=; b=JP9orS50tij7AR5qSry6psj3uSxN+dqggrNruuOGAo5lKFRepM6iDtccLLDS4d9j00 VnwGA6p4Td7d7Wv54zs+62zDQWslgbV73ZJ9fLnovz8D5dq7o+cvrrQAC28b+kWRgbOJ bXoHqmAIInr8qAHHC18zjjlx7sw8l978xW9Q0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710779756; x=1711384556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cpzmmaoi0pJueucz7Za6oBj+S2IXaqOnagU2yAyCJ44=; b=if/w0DYXDIzTg/uEBxgo1+1IBfN40KJ8/Z/LPFHMMMkynANIpJiO7XAVlBn9i4zQRo PMtKLrddf0vcjaE4JXNPczYDpdo/Y2ZoADBv+hL5hCEtduryqgpICM/U+0YVWOa0xJKN wp8uakLmSi2metjuiOQ2rNrdSuswiPQcufLVC+4Dii7VwD4/lmvVEx975QdEbXL+nDi2 LmSCb70opR1dLL23R8E+2/uxIMaVFjX0+P2IFA5oqZyoMs/lEBJqlkPYCFA1dfyA5AhU 0FlXY5h/LLRHutSHGzeab8/WO4a8k0uV7lyuNgQ3FDPXJrG3lP/zTdBoWtS3BdqLW+gs YIPw== X-Gm-Message-State: AOJu0YytK9Pjhfss0KWzSNRlBdbA9nLO7tCn8HH/V89oz8zDfmv+m9e1 slZzXZIPM1zZBsMB37rC/PAOGoNl2jfr+IoSvp4fU8MOqt0IUU6+ZenX2EiRHR6tv7X2OyblJW9 k X-Google-Smtp-Source: AGHT+IFlFP6MCdOoAYd9kZM9daEwNdNvAgjw0dy0gDaSkJUU2uztyqS390yRXY9RR7dsxHNJEWQejw== X-Received: by 2002:a17:906:81d0:b0:a46:d304:fce2 with SMTP id e16-20020a17090681d000b00a46d304fce2mr617114ejx.35.1710779756410; Mon, 18 Mar 2024 09:35:56 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Julien Grall , Nicola Vetrini , "consulting @ bugseng . com" Subject: [PATCH 1/7] xen/trace: Introduce new API Date: Mon, 18 Mar 2024 16:35:46 +0000 Message-Id: <20240318163552.3808695-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240318163552.3808695-1-andrew.cooper3@citrix.com> References: <20240318163552.3808695-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1710779779980100004 Content-Type: text/plain; charset="utf-8" trace() and trace_time(), in function form for struct arguments, and macro form for simple uint32_t list arguments. This will be used to clean up the mess of macros which exists throughout the codebase, as well as eventually dropping __trace_var(). There is intentionally no macro to split a 64-bit parameter in the new API, for MISRA reasons. Signed-off-by: Andrew Cooper Reviewed-by: George Dunlap --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Julien Grall CC: Nicola Vetrini CC: consulting@bugseng.com v3: * Extend with trace() and trace_time() * Delete TRACE_PARAM64() for MISRA reasons. --- xen/common/trace.c | 5 +++++ xen/include/xen/trace.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/xen/common/trace.c b/xen/common/trace.c index 4e7b080e6154..c94ce1f7dc90 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -808,6 +808,11 @@ void __trace_var(u32 event, bool cycles, unsigned int = extra, tasklet_schedule(&trace_notify_dom0_tasklet); } =20 +void trace(uint32_t event, unsigned int extra, const void *extra_data) +{ + __trace_var(event, event & TRC_HD_CYCLE_FLAG, extra, extra_data); +} + void __trace_hypercall(uint32_t event, unsigned long op, const xen_ulong_t *args) { diff --git a/xen/include/xen/trace.h b/xen/include/xen/trace.h index 055883287e8c..f184844e1b55 100644 --- a/xen/include/xen/trace.h +++ b/xen/include/xen/trace.h @@ -37,6 +37,9 @@ int tb_control(struct xen_sysctl_tbuf_op *tbc); =20 int trace_will_trace_event(u32 event); =20 +/* Create a trace record, with pre-constructed additional parameters. */ +void trace(uint32_t event, unsigned int extra, const void *extra_data); + void __trace_var(uint32_t event, bool cycles, unsigned int extra, const vo= id *); =20 static inline void trace_var(uint32_t event, bool cycles, unsigned int ext= ra, @@ -66,6 +69,9 @@ static inline int trace_will_trace_event(uint32_t event) return 0; } =20 +static inline void trace( + uint32_t event, unsigned int extra, const void *extra_data) {} + static inline void trace_var(uint32_t event, bool cycles, unsigned int ext= ra, const void *extra_data) {} static inline void __trace_var(uint32_t event, bool cycles, unsigned int e= xtra, @@ -74,6 +80,30 @@ static inline void __trace_hypercall(uint32_t event, uns= igned long op, const xen_ulong_t *args) {} #endif /* CONFIG_TRACEBUFFER */ =20 +/* Create a trace record with time included. */ +static inline void trace_time( + uint32_t event, unsigned int extra, const void *extra_data) +{ + trace(event | TRC_HD_CYCLE_FLAG, extra, extra_data); +} + +/* + * Create a trace record, packaging up to 7 additional parameters into a + * uint32_t array. + */ +#define TRACE(_e, ...) \ + do { \ + if ( unlikely(tb_init_done) ) \ + { \ + uint32_t _d[] =3D { __VA_ARGS__ }; \ + BUILD_BUG_ON(ARRAY_SIZE(_d) > TRACE_EXTRA_MAX); \ + trace(_e, sizeof(_d), sizeof(_d) ? _d : NULL); \ + } \ + } while ( 0 ) + +/* Create a trace record with time included. */ +#define TRACE_TIME(_e, ...) TRACE((_e) | TRC_HD_CYCLE_FLAG, ##__VA_ARGS__) + /* Convenience macros for calling the trace function. */ #define TRACE_0D(_e) \ do { \ --=20 2.30.2