From patchwork Fri Dec 16 09:03:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 33914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp857435wrn; Fri, 16 Dec 2022 01:12:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+ymLg1plu4DNfJByjnqh2c+woU/jEDNoYfU8PHry5tEp4Bc8sKOJNYmMqqBfWtEVp9Dxh X-Received: by 2002:a17:902:e194:b0:189:aab9:cd80 with SMTP id y20-20020a170902e19400b00189aab9cd80mr27830068pla.64.1671181937470; Fri, 16 Dec 2022 01:12:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671181937; cv=none; d=google.com; s=arc-20160816; b=NYo/08ORQqiarT7TZqO5dmXdur9d87cgtll7O9twm4MzgfkhJQUcQ6hwSTO9o4NdCy mQvfFdGuDutJ273KoojMK+Xz6QpyOPMyBluful7ezCdLveqc9Y4S3JSjsVMrs7LyRPY8 BTwpDYZA4+6dSYh2P34ExtvBe95cHW0nIK7m1DETUBnqatXNPhcnrlZR6ODDsayRwv/P gSiVFbL1dLFHm6gx9FEQ7RRbwfhs8nG7QHUcssiMQUshnJFlwyT/TDz/qy2rtOS8OwkB dH6lTgBdZvpR0udPYvsN8ucrttPzZiUjlGlmN2dZd0GSUaWVYmNm8fsv8Z92pgNmEqru 6pNQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=uN90QK0p8l/NyeG5HqD5ZfOY7c8FWepxnORbFTP1+AA=; b=SZJoWYv4npvWnF3NAo8hi2lInTGilq8ncGCapqSGa3PivT0sPtUxr9Ws4pASGVSs8F cHIwnBPco7OMrdZhXVr2u53m6EH6J2jjas5QGmf1nudujej15QH+djtschjlwcRfJlqX zzG8Ldno8qFPiJjTcOiSjchCpidlhHwf/WQ5eQXE5WZc5rhScBUA5Xp2QhOqmd/KAq74 5UkqS5us6YVJY1EGYbAjR2OYPi+gEbxFRASMcWSiiUmbAZuskAeGSpZgUWIBh9ggQ0Hg 8KWzgA4q4fsuJZEkrPb0bavk90Reojsiv1FNw4x1dbQevcGOErOmUS8Ygme1QZnmYEs0 3ysA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IkCEUZM7; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a170902e74100b00189684c7c79si2209690plf.293.2022.12.16.01.12.03; Fri, 16 Dec 2022 01:12:17 -0800 (PST) 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=@quicinc.com header.s=qcppdkim1 header.b=IkCEUZM7; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiLPJDW (ORCPT + 99 others); Fri, 16 Dec 2022 04:03:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbiLPJDQ (ORCPT ); Fri, 16 Dec 2022 04:03:16 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E237B1EC5C; Fri, 16 Dec 2022 01:03:15 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BG4oHH9025767; Fri, 16 Dec 2022 09:03:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=uN90QK0p8l/NyeG5HqD5ZfOY7c8FWepxnORbFTP1+AA=; b=IkCEUZM7jHzbjhU6P4h1TyrUrHs4QWddgW6axhNyqk0iRlkVZr8R2bqeHLOT0a/7oYZr kwW98nuYu8BNH53VBTkUQ1s5rFJLcGtv4K2Mcx6VzkfO3vJg4j2w1tujjcjImW495L9E CnjX0bVDXcUBzx+Bvfdb6YgwdlGIpZuOWmkzCCkA5Jkcom31jTB3gf2ftA04G2nDZBle FjxdqbYnWeFQRko9P3ilGci8weXShL6zO7Ya0z7D1XkiLwIOX3xTm0vrTHN9y8qQ2rTP bY5yCTBJBZxRgq9TSVdNmQMGvY+XNVz7YCJmrRxM0hLPp5gmA7PbYr3cr25beCX4om/z dw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mg6y7tabm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Dec 2022 09:03:12 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BG93B2O012045 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Dec 2022 09:03:11 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 16 Dec 2022 01:03:09 -0800 From: Linyu Yuan To: Steven Rostedt , Masami Hiramatsu CC: , , Linyu Yuan Subject: [PATCH v4 1/2] trace: add new file under include/trace/stages/ for perf/bpf Date: Fri, 16 Dec 2022 17:03:04 +0800 Message-ID: <1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: qlb_WoX0sHOLF1IEIB58ecnySwxuF31L X-Proofpoint-GUID: qlb_WoX0sHOLF1IEIB58ecnySwxuF31L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-16_04,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 impostorscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 suspectscore=0 spamscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212160078 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752358168500412464?= X-GMAIL-MSGID: =?utf-8?q?1752361271065551120?= when experiment change for trace operation, the files under include/trace/stages/ will be changed, perf/bpf trace may compile fail. add new file stage8_perf_call.h and stage9_bpf_call.h under include/trace/stages/, it will make sure no missing change when expriment. Signed-off-by: Linyu Yuan --- v4: fix build isse due to file rename v3: consider perf as stage 8, bpf as stage 9, file name purpose only. v2: not exist include/trace/bpf_probe.h | 51 +------------------------------ include/trace/perf.h | 52 +------------------------------- include/trace/stages/stage8_perf_call.h | 53 +++++++++++++++++++++++++++++++++ include/trace/stages/stage9_bpf_call.h | 52 ++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 101 deletions(-) create mode 100644 include/trace/stages/stage8_perf_call.h create mode 100644 include/trace/stages/stage9_bpf_call.h diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 155c495..dfa39f5 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -4,56 +4,7 @@ #ifdef CONFIG_BPF_EVENTS -#undef __entry -#define __entry entry - -#undef __get_dynamic_array -#define __get_dynamic_array(field) \ - ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) - -#undef __get_dynamic_array_len -#define __get_dynamic_array_len(field) \ - ((__entry->__data_loc_##field >> 16) & 0xffff) - -#undef __get_str -#define __get_str(field) ((char *)__get_dynamic_array(field)) - -#undef __get_bitmask -#define __get_bitmask(field) (char *)__get_dynamic_array(field) - -#undef __get_cpumask -#define __get_cpumask(field) (char *)__get_dynamic_array(field) - -#undef __get_sockaddr -#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) - -#undef __get_rel_dynamic_array -#define __get_rel_dynamic_array(field) \ - ((void *)(&__entry->__rel_loc_##field) + \ - sizeof(__entry->__rel_loc_##field) + \ - (__entry->__rel_loc_##field & 0xffff)) - -#undef __get_rel_dynamic_array_len -#define __get_rel_dynamic_array_len(field) \ - ((__entry->__rel_loc_##field >> 16) & 0xffff) - -#undef __get_rel_str -#define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field)) - -#undef __get_rel_bitmask -#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) - -#undef __get_rel_cpumask -#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) - -#undef __get_rel_sockaddr -#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) - -#undef __perf_count -#define __perf_count(c) (c) - -#undef __perf_task -#define __perf_task(t) (t) +#include "stages/stage9_bpf_call.h" /* cast any integer, pointer, or small struct to u64 */ #define UINTTYPE(size) \ diff --git a/include/trace/perf.h b/include/trace/perf.h index 8f3bf1e..57e1661 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -4,57 +4,7 @@ #ifdef CONFIG_PERF_EVENTS -#undef __entry -#define __entry entry - -#undef __get_dynamic_array -#define __get_dynamic_array(field) \ - ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) - -#undef __get_dynamic_array_len -#define __get_dynamic_array_len(field) \ - ((__entry->__data_loc_##field >> 16) & 0xffff) - -#undef __get_str -#define __get_str(field) ((char *)__get_dynamic_array(field)) - -#undef __get_bitmask -#define __get_bitmask(field) (char *)__get_dynamic_array(field) - -#undef __get_cpumask -#define __get_cpumask(field) (char *)__get_dynamic_array(field) - -#undef __get_sockaddr -#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) - -#undef __get_rel_dynamic_array -#define __get_rel_dynamic_array(field) \ - ((void *)__entry + \ - offsetof(typeof(*__entry), __rel_loc_##field) + \ - sizeof(__entry->__rel_loc_##field) + \ - (__entry->__rel_loc_##field & 0xffff)) - -#undef __get_rel_dynamic_array_len -#define __get_rel_dynamic_array_len(field) \ - ((__entry->__rel_loc_##field >> 16) & 0xffff) - -#undef __get_rel_str -#define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field)) - -#undef __get_rel_bitmask -#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) - -#undef __get_rel_cpumask -#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) - -#undef __get_rel_sockaddr -#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) - -#undef __perf_count -#define __perf_count(c) (__count = (c)) - -#undef __perf_task -#define __perf_task(t) (__task = (t)) +#include "stages/stage8_perf_call.h" #undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ diff --git a/include/trace/stages/stage8_perf_call.h b/include/trace/stages/stage8_perf_call.h new file mode 100644 index 0000000..54c8045 --- /dev/null +++ b/include/trace/stages/stage8_perf_call.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#undef __entry +#define __entry entry + +#undef __get_dynamic_array +#define __get_dynamic_array(field) \ + ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) + +#undef __get_dynamic_array_len +#define __get_dynamic_array_len(field) \ + ((__entry->__data_loc_##field >> 16) & 0xffff) + +#undef __get_str +#define __get_str(field) ((char *)__get_dynamic_array(field)) + +#undef __get_bitmask +#define __get_bitmask(field) ((char *)__get_dynamic_array(field)) + +#undef __get_cpumask +#define __get_cpumask(field) ((char *)__get_dynamic_array(field)) + +#undef __get_sockaddr +#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) + +#undef __get_rel_dynamic_array +#define __get_rel_dynamic_array(field) \ + ((void *)__entry + \ + offsetof(typeof(*__entry), __rel_loc_##field) + \ + sizeof(__entry->__rel_loc_##field) + \ + (__entry->__rel_loc_##field & 0xffff)) + +#undef __get_rel_dynamic_array_len +#define __get_rel_dynamic_array_len(field) \ + ((__entry->__rel_loc_##field >> 16) & 0xffff) + +#undef __get_rel_str +#define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field)) + +#undef __get_rel_bitmask +#define __get_rel_bitmask(field) ((char *)__get_rel_dynamic_array(field)) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) ((char *)__get_rel_dynamic_array(field)) + +#undef __get_rel_sockaddr +#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) + +#undef __perf_count +#define __perf_count(c) (__count = (c)) + +#undef __perf_task +#define __perf_task(t) (__task = (t)) diff --git a/include/trace/stages/stage9_bpf_call.h b/include/trace/stages/stage9_bpf_call.h new file mode 100644 index 0000000..6dbcbdf --- /dev/null +++ b/include/trace/stages/stage9_bpf_call.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#undef __entry +#define __entry entry + +#undef __get_dynamic_array +#define __get_dynamic_array(field) \ + ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) + +#undef __get_dynamic_array_len +#define __get_dynamic_array_len(field) \ + ((__entry->__data_loc_##field >> 16) & 0xffff) + +#undef __get_str +#define __get_str(field) ((char *)__get_dynamic_array(field)) + +#undef __get_bitmask +#define __get_bitmask(field) ((char *)__get_dynamic_array(field)) + +#undef __get_cpumask +#define __get_cpumask(field) ((char *)__get_dynamic_array(field)) + +#undef __get_sockaddr +#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) + +#undef __get_rel_dynamic_array +#define __get_rel_dynamic_array(field) \ + ((void *)(&__entry->__rel_loc_##field) + \ + sizeof(__entry->__rel_loc_##field) + \ + (__entry->__rel_loc_##field & 0xffff)) + +#undef __get_rel_dynamic_array_len +#define __get_rel_dynamic_array_len(field) \ + ((__entry->__rel_loc_##field >> 16) & 0xffff) + +#undef __get_rel_str +#define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field)) + +#undef __get_rel_bitmask +#define __get_rel_bitmask(field) ((char *)__get_rel_dynamic_array(field)) + +#undef __get_rel_cpumask +#define __get_rel_cpumask(field) ((char *)__get_rel_dynamic_array(field)) + +#undef __get_rel_sockaddr +#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) + +#undef __perf_count +#define __perf_count(c) (c) + +#undef __perf_task +#define __perf_task(t) (t) From patchwork Fri Dec 16 09:03:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 33916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp858884wrn; Fri, 16 Dec 2022 01:16:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf4uO3bJMpOJRfelpjkOScz/agYR1dNn75RmAx3NRhIwv69H3Q3lt+8mzwz0PCyihPY5kiDC X-Received: by 2002:a17:902:c40f:b0:189:ea22:6d6a with SMTP id k15-20020a170902c40f00b00189ea226d6amr49565768plk.60.1671182168011; Fri, 16 Dec 2022 01:16:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671182167; cv=none; d=google.com; s=arc-20160816; b=rWOQbCbdxKQjesFrnsT3ttEl4JuhlFmnUzAxASv9tUvu4N1D6yYmzBgprk9ih5O506 rTZ6bC2xfMxx9A//mXd5HRgr9orKbVezzDsJGLAuyJ5dqiOfWoEwVHDTk5kI2ee4LI4Q sC/uq7JJInrJvcHFH56yjypPFziBWXjQTUiG3NahBXM4YsQgKo0/Dbg6H3FzLzAtpd8w GZHpCevUu5uUD8fblBKgCAvbMFkpWxFvejbYZ5mISL4yDDCVm/0PzvQr5fT6W1Eg7V6I 2VvpUD972tFXGyB2aHaVrlkHe0QB7a8yQxYs7xLe1b6KemMofDrRSZcYU7w5dnjMwbGl KgZw== 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=MCHxJJgIqWX4kNoe0ebDzRZHM0zd874VF1CmfxJQ6Fk=; b=LFDZ7IMigRjjdttTNA8k6N/qXbxNZZ7bWrBm+uWm8/O6t/1w+WPh7jESlBnIBkz22e axaBnHkb2kMkz+1BUNTIdOV3z0dfU8QvcM+NDUMYIMJz+9NuVrT5WAeLHh60IexGdP1t ULWItF5quy4Cyd36N/UBdMSKK3fKLb1/6dsREoF/P+f26JV3gCVC1/JLb7DOLdW1pNm+ E0q1oOoFMO/SMy2wrbgVI8lPl5jrbTu800AVxppmqMnhSwB/yDQFZKzQz/W2ETa1zHPK ajZ4NHEB7Fi2lAPi4oKj1qyS4Q53FfIv3HLGo0VJvC2KL2QhBp76xIPzh+rfW34zGU3T oIVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=C29sc6CH; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a17090322d000b00189b7f50e78si2389082plg.134.2022.12.16.01.15.54; Fri, 16 Dec 2022 01:16:07 -0800 (PST) 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=@quicinc.com header.s=qcppdkim1 header.b=C29sc6CH; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230039AbiLPJDY (ORCPT + 99 others); Fri, 16 Dec 2022 04:03:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbiLPJDT (ORCPT ); Fri, 16 Dec 2022 04:03:19 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48E501EEC4; Fri, 16 Dec 2022 01:03:18 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BG6DsIV003485; Fri, 16 Dec 2022 09:03:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=MCHxJJgIqWX4kNoe0ebDzRZHM0zd874VF1CmfxJQ6Fk=; b=C29sc6CHD7yl22yPrvryU3oDgEeTaStmY2H+RbvbRhLARgE0DJWFc8gt7H5YJQMvX6xt 6gpde1ZHrZIsNP6k535DLMN6PW2l8rcy9QV9L5Q1MrRLKz88XD8tJSAROmcCk0WThc0J DQ5YDHOl0B5S1QnNmm3ELlOo7pg0Jjjmg++y8EWacoTEh0QgbdD/4HQejos59WL9uFZr arEBykEGjoAa64fhEfhH94DeC/ot4B5TLUP8THPTlHQib20a8qkGgZSpg/KpiSgqlmoB iEl6d/ZBEXQzA/P9KI4q9hja0pQPO0r3ryqqZlIXVfCdqL2UqpJ2NPkMWKqq7HXmqrgT sg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mg6tetk7w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Dec 2022 09:03:14 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BG93DrB001768 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Dec 2022 09:03:13 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 16 Dec 2022 01:03:11 -0800 From: Linyu Yuan To: Steven Rostedt , Masami Hiramatsu CC: , , Linyu Yuan Subject: [PATCH v4 2/2] trace: acquire buffer from temparary trace sequence Date: Fri, 16 Dec 2022 17:03:05 +0800 Message-ID: <1671181385-5719-2-git-send-email-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com> References: <1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: NndQ8hU9bNZO7siWX7Sv_L4x6sWtR09b X-Proofpoint-GUID: NndQ8hU9bNZO7siWX7Sv_L4x6sWtR09b X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-16_04,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1015 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212160078 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752361512964382632?= X-GMAIL-MSGID: =?utf-8?q?1752361512964382632?= there is one dwc3 trace event declare as below, DECLARE_EVENT_CLASS(dwc3_log_event, TP_PROTO(u32 event, struct dwc3 *dwc), TP_ARGS(event, dwc), TP_STRUCT__entry( __field(u32, event) __field(u32, ep0state) __dynamic_array(char, str, DWC3_MSG_MAX) ), TP_fast_assign( __entry->event = event; __entry->ep0state = dwc->ep0state; ), TP_printk("event (%08x): %s", __entry->event, dwc3_decode_event(__get_str(str), DWC3_MSG_MAX, __entry->event, __entry->ep0state)) ); the problem is when trace function called, it will allocate up to DWC3_MSG_MAX bytes from trace event buffer, but never fill the buffer during fast assignment, it only fill the buffer when output function are called, so this means if output function are not called, the buffer will never used. add __get_buf(len) which acquiree buffer from iter->tmp_seq when trace output function called, it allow user write string to acquired buffer. the mentioned dwc3 trace event will changed as below, DECLARE_EVENT_CLASS(dwc3_log_event, TP_PROTO(u32 event, struct dwc3 *dwc), TP_ARGS(event, dwc), TP_STRUCT__entry( __field(u32, event) __field(u32, ep0state) ), TP_fast_assign( __entry->event = event; __entry->ep0state = dwc->ep0state; ), TP_printk("event (%08x): %s", __entry->event, dwc3_decode_event(__get_buf(DWC3_MSG_MAX), DWC3_MSG_MAX, __entry->event, __entry->ep0state)) );. Signed-off-by: Linyu Yuan --- v4: no change v3: fix comment from maintainer in v2 include/linux/trace_seq.h | 6 ++++++ include/trace/stages/stage3_trace_output.h | 8 ++++++++ include/trace/stages/stage7_class_define.h | 1 + kernel/trace/trace_seq.c | 22 ++++++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 5a2c650..4a3bbab 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -95,6 +95,7 @@ extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, extern int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str, int prefix_type, int rowsize, int groupsize, const void *buf, size_t len, bool ascii); +char *trace_seq_acquire(struct trace_seq *s, size_t len); #else /* CONFIG_TRACING */ static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) @@ -138,6 +139,11 @@ static inline int trace_seq_path(struct trace_seq *s, const struct path *path) { return 0; } + +static inline char *trace_seq_acquire(struct trace_seq *s, size_t len) +{ + return NULL; +} #endif /* CONFIG_TRACING */ #endif /* _LINUX_TRACE_SEQ_H */ diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index 66374df..f60c453 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -139,3 +139,11 @@ u64 ____val = (u64)(value); \ (u32) do_div(____val, NSEC_PER_SEC); \ }) + +/* Macros with flow control statements should be avoided */ +#undef __get_buf +#define __get_buf(len) \ + ({ \ + WARN_ON_ONCE(seq_buf_buffer_left(&p->seq) < (len)); \ + trace_seq_acquire(p, (len)); \ + }) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8795429..bcb960d 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -23,6 +23,7 @@ #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump +#undef __get_buf /* * The below is not executed in the kernel. It is only what is diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c index 9c90b3a..c900b7c 100644 --- a/kernel/trace/trace_seq.c +++ b/kernel/trace/trace_seq.c @@ -403,3 +403,25 @@ int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str, return 1; } EXPORT_SYMBOL(trace_seq_hex_dump); + +/** + * trace_seq_acquire - acquire seq buffer with size len + * @s: trace sequence descriptor + * @len: size of buffer to be acquired + * + * acquire buffer with size of @len from trace_seq for output usage, + * user can fill string into that buffer. + * + * Returns start address of acquired buffer. + * + * it allow multiple usage in one trace output function call. + */ +char *trace_seq_acquire(struct trace_seq *s, size_t len) +{ + char *ret = trace_seq_buffer_ptr(s); + + seq_buf_commit(&s->seq, len); + + return ret; +} +EXPORT_SYMBOL(trace_seq_acquire);