From patchwork Thu Dec 15 04:33:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 33478 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp139909wrn; Wed, 14 Dec 2022 20:43:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf6LbQALtnifOLtp8QzR/iih/RF8hcXVG1UAagMaKg8Lb1xY5KwqktAV6+gLSeQxaiMEmxIp X-Received: by 2002:a17:906:e54:b0:7c1:23f7:623a with SMTP id q20-20020a1709060e5400b007c123f7623amr21557586eji.66.1671079393030; Wed, 14 Dec 2022 20:43:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671079393; cv=none; d=google.com; s=arc-20160816; b=WxWBmXobt4CpxEPEvjPa98al7JeG2t+OBNhEB5i0MQ2HsqAm9rAaRQqcxqEzc7NvJL aqQo7GBE0fHWCVvS4OXGYmYUdcfOX8Va2xcH2VB/Iey7MHpDzw4b8E5LHDSV+YGArzfj IHr5MrCKeQIeSzsuvsVDf5C+S2KstkSWVWJLVEczK5aPUONszTXfG5ILySAQeSeDMtqI /2PlWOMenbyp5LE8K73HdjKtKtXJ/CsRv4aY64Oi/XiemK42vmv/FqL34ujx1UC45wwy vav5Qa55HtEp5BWvkuUc2n0xu43sfPq7ZS2jOWFBuzBJGyfFYsNlNkPPJduvlYmtfxfe mW3Q== 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=oL6JKXXrslbXUvwLoHaym9HJ6v4B9FKe1acxHJChhjQ=; b=uWU30O26SjvkRWhWKNAGu/n7uZS/ie8VzDwubVelM6MsK9ddXPWsxBmEmvMMQFt7Vd F8jDMUUIfFJN/DJi/cUlv6HVToA+61a55me7HNLqSMbEeRAKUU8CJV8X1moof1v4Vqxk I3G65ZgkiexZZKsFDZumgBahRwPWv3Jbb9JSsmwbKBbnVZvwSQ8s+erhIqmgtU5kzpxQ hEHWrn2QjAiDmTSvre3NXjKw4jtsf+fRhl04ZqRvOW7dGW9ZP+DKnEBpkloWYhMOhaJZ pGk7/THlewCq0PDBTJWgee31rVYQmx6IZThf5SDAa02yFmYhP9bD3SrXLLPNA1GQaVum QMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oYOkBcbR; 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 dp14-20020a170906c14e00b007c89c44ec77si536704ejc.169.2022.12.14.20.42.49; Wed, 14 Dec 2022 20:43:13 -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=oYOkBcbR; 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 S229551AbiLOEdr (ORCPT + 99 others); Wed, 14 Dec 2022 23:33:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiLOEdk (ORCPT ); Wed, 14 Dec 2022 23:33:40 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A980531DC1; Wed, 14 Dec 2022 20:33:38 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BF4KiDg009520; Thu, 15 Dec 2022 04:33:34 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=oL6JKXXrslbXUvwLoHaym9HJ6v4B9FKe1acxHJChhjQ=; b=oYOkBcbRKIcWQ/rwgmvEkmAUs93BHQmBY3gBpUwXD8rrioFXSIFVDnEh63c1U5PI24Ca snCYNm98of336HYnUZfv6L7UrkRxPZCFXHfOCDnTfhE010vMIzjQeZ0K6s+FJ3vlNFo0 Wa+vR0ZjnFAna6E1X2q07hfqXVCdVOZF9z7GfSR9DwwBxLGTMC1SwvP0xclzjrxiS35r xRApx5VJKpce8SxkA7GZNyNKe0N3lViQxc6yeC8yXpobC+8M3Q8P6ovFZzpkSCkX3jbU pmycERGOaaRIAyckvWAjRCILcXXgpUhM2SEF95Jbk1HuXJl3e2aVu7T8tCXrHTz4AgQw ag== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mf6rtk6jk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 04:33:34 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BF4XXJF032178 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 04:33:33 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; Wed, 14 Dec 2022 20:33:31 -0800 From: Linyu Yuan To: Steven Rostedt , Masami Hiramatsu CC: , , Linyu Yuan Subject: [PATCH v1 1/2] trace: add new file under include/trace/stages/ for perf/bpf Date: Thu, 15 Dec 2022 12:33:26 +0800 Message-ID: <1671078807-20748-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: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: dNNYiuEssxi75mYZKQPX0Zy_go8pq-xb X-Proofpoint-ORIG-GUID: dNNYiuEssxi75mYZKQPX0Zy_go8pq-xb 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-15_02,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 impostorscore=0 phishscore=0 mlxlogscore=984 mlxscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212150031 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?1752253745733698385?= X-GMAIL-MSGID: =?utf-8?q?1752253745733698385?= when experiment change for trace operation, the files under include/trace/stages/ will be changed, perf/bpf trace may compile fail. add new file stage_perf_call.h and stage_bpf_call.h under include/trace/stages, it will make sure no missing change when expriment. Signed-off-by: Linyu Yuan --- include/trace/bpf_probe.h | 51 +------------------------------- include/trace/perf.h | 52 +------------------------------- include/trace/stages/stage_bpf_call.h | 53 +++++++++++++++++++++++++++++++++ include/trace/stages/stage_perf_call.h | 54 ++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 101 deletions(-) create mode 100644 include/trace/stages/stage_bpf_call.h create mode 100644 include/trace/stages/stage_perf_call.h diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index 155c495..a6eeb9e 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/stage_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..e899bf7 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/stage_perf_call.h" #undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ diff --git a/include/trace/stages/stage_bpf_call.h b/include/trace/stages/stage_bpf_call.h new file mode 100644 index 0000000..0e6c4e9 --- /dev/null +++ b/include/trace/stages/stage_bpf_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->__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) + diff --git a/include/trace/stages/stage_perf_call.h b/include/trace/stages/stage_perf_call.h new file mode 100644 index 0000000..718db55 --- /dev/null +++ b/include/trace/stages/stage_perf_call.h @@ -0,0 +1,54 @@ +/* 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)) + From patchwork Thu Dec 15 04:33:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 33477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp139705wrn; Wed, 14 Dec 2022 20:42:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4PrKvgBglVsWR/hz0GlR01upSQfe+mFHQsNy6AGH3ReyS2lscXSqAlZdOMEodUGqmXThCd X-Received: by 2002:a17:906:2a55:b0:7a2:7226:6c2d with SMTP id k21-20020a1709062a5500b007a272266c2dmr21100530eje.22.1671079353675; Wed, 14 Dec 2022 20:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671079353; cv=none; d=google.com; s=arc-20160816; b=pS6s7C+DapbHesXp1WvkDueejnxamQj5FsCGmaOlHVptTagHmh7Xwho8F5eIE/QAYN l2FHjC8WqwqQj/bHqCNwGz2ukSQtr2x+Vuubg+CtvyAL28wERYhefSpCde8Hu34t0sjj 9vdBH5MxVSTTw6kMz3Slpj/AsjhdTWvrhKTPhdFevIUhRa5bjLgpndKm9l3rhXcCZ23l zViPbF+QM4jtlpwBLi7Sa3onbqleYzVlU1qQQROr1z6yTtjwi+SAh5XKMpfsY0RBUbxD leDR8dcQmkhYhgsio9K2MswLZ4z9nhXJfIwNqidUpFFMLut95gexZA4o9dd6+EQ6pSIL OKXg== 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=4SyvjD4ieCepab01OFVgY8QodNiTFNDXr+06YcqMjXQ=; b=0F3zFS9m8SFOB/CQ7p7yH42u9KzPCbqYC5NDwHEp/rCO00Dc/zDOFl2vgvwV2jN1AP 5kDW1Rm48ob6qURwXJzXLfodgCqR3ZQIYHxOGEK/t5cjPoopKbHDR9DKxWLi7JnSRoDf yAzqmClgBDWAhfa2R6ZPl6H26w2L1tJwncJDjMKycVfdm1GeeS05lLtHUuZpDv8WtDkH I4JXCQaJSdzhBZWvlAJi3XSg0MhpZ/BSGw1PE16bBeg+MDogrPZTPH1mvBlpbg/X6+1E iIfVM6tnz7NruT6gZQ8jROZK/T35/xtpr4zLbwVfFw+yzWxmSMWfQ1XwoBD5Rg33xMY6 43og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=P68ENG1I; 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 ji2-20020a170907980200b0078d49f0df9csi15677037ejc.453.2022.12.14.20.42.07; Wed, 14 Dec 2022 20:42:33 -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=P68ENG1I; 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 S229616AbiLOEdx (ORCPT + 99 others); Wed, 14 Dec 2022 23:33:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiLOEdk (ORCPT ); Wed, 14 Dec 2022 23:33:40 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A10132A27A; Wed, 14 Dec 2022 20:33:39 -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 2BF2RZYR029046; Thu, 15 Dec 2022 04:33:36 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=4SyvjD4ieCepab01OFVgY8QodNiTFNDXr+06YcqMjXQ=; b=P68ENG1It0LNaNWAoitB7lgW4i1ty/ZeUJ4mN/ojHvQWvgYrfXvqLAovjAQw6Kp9syAI XnBREWjzGtr1L2pS35mX89w2ysmkc9mzWawkGviPbMRZDo7Vfur0gmNkKxe1V8bdrZsj 3xMpzHRUgdh55Elv6sZ4/ZJx9Al4tQEk2CelyggfnCjCXZP0cCqtQUXDsSGP9N5btJZp R0NEGd/8Tug5RIhUeP/7dP5Q00WFLUMSKd/uGm7IpFwctopiEExQgh/erWcOJfhKj8Pa d6by/Z/Hk8pbEarKaQjb7ImIZeflaX2B4A+mc5TxvmXiwV1cIgolDFRSuT4QKK+md29f ig== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mf6rrk7g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 04:33:35 +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 2BF4XYNc011171 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 04:33:34 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; Wed, 14 Dec 2022 20:33:33 -0800 From: Linyu Yuan To: Steven Rostedt , Masami Hiramatsu CC: , , Linyu Yuan Subject: [PATCH v2 2/2] trace: allocate space from temparary trace sequence buffer Date: Thu, 15 Dec 2022 12:33:27 +0800 Message-ID: <1671078807-20748-2-git-send-email-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1671078807-20748-1-git-send-email-quic_linyyuan@quicinc.com> References: <1671078807-20748-1-git-send-email-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: BOQB8jZJ_K0wYp_8eJ9B_q5GbWzlYAnb X-Proofpoint-ORIG-GUID: BOQB8jZJ_K0wYp_8eJ9B_q5GbWzlYAnb 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-15_02,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 impostorscore=0 adultscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212150031 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?1752253704485841735?= X-GMAIL-MSGID: =?utf-8?q?1752253704485841735?= 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 allocate space from iter->tmp_seq when trace output function called, it allow user write any data to allocatd space. 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 --- include/linux/trace_seq.h | 6 ++++++ include/trace/stages/stage3_trace_output.h | 4 ++++ include/trace/stages/stage7_class_define.h | 1 + kernel/trace/trace_seq.c | 31 ++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 5a2c650..9703d03 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); +void *trace_seq_alloc_buffer(struct trace_seq *s, int 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 void *trace_seq_alloc_buffer(struct trace_seq *s, int 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..a2921bd 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -139,3 +139,7 @@ u64 ____val = (u64)(value); \ (u32) do_div(____val, NSEC_PER_SEC); \ }) + +#undef __get_buf +#define __get_buf(len) \ + trace_seq_alloc_buffer(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..1501e3b 100644 --- a/kernel/trace/trace_seq.c +++ b/kernel/trace/trace_seq.c @@ -403,3 +403,34 @@ int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str, return 1; } EXPORT_SYMBOL(trace_seq_hex_dump); + +/** + * trace_seq_alloc_buffer - allocate seq buffer with size len + * @s: trace sequence descriptor + * @len: size of buffer to be allocated + * + * allocate space with size of @len from seq buffer for output usage, + * On success, it returns start address of the allocated buffer, + * user can fill data start from the address, user should make sure the + * data length not exceed the @len, if it exceed, behavior is undefined. + * + * Returns NULL if no buffer can be allocated, it also means system will + * crash, it is user responsiblity to make sure total buffer used will + * not exceed PAGE_SIZE. + * + * it allow multiple usage in one trace output function call. + */ +void *trace_seq_alloc_buffer(struct trace_seq *s, int len) +{ + char *buf = trace_seq_buffer_ptr(s); + + seq_buf_commit(&s->seq, len); + + if (unlikely(seq_buf_has_overflowed(&s->seq))) { + s->full = 1; + return NULL; + } + + return (void *)buf; +} +EXPORT_SYMBOL(trace_seq_alloc_buffer);