WO2012171171A1 - 软件监测方法、装置以及系统 - Google Patents

软件监测方法、装置以及系统 Download PDF

Info

Publication number
WO2012171171A1
WO2012171171A1 PCT/CN2011/075705 CN2011075705W WO2012171171A1 WO 2012171171 A1 WO2012171171 A1 WO 2012171171A1 CN 2011075705 W CN2011075705 W CN 2011075705W WO 2012171171 A1 WO2012171171 A1 WO 2012171171A1
Authority
WO
WIPO (PCT)
Prior art keywords
lock program
address
memory
program
lock
Prior art date
Application number
PCT/CN2011/075705
Other languages
English (en)
French (fr)
Inventor
王超
余加强
陈明宇
黄永兵
张文力
崔泽汉
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2011/075705 priority Critical patent/WO2012171171A1/zh
Priority to CN201180001455.XA priority patent/CN102301343B/zh
Publication of WO2012171171A1 publication Critical patent/WO2012171171A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3612Software analysis for verifying properties of programs by runtime analysis

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a software monitoring method, apparatus, and system. Background technique
  • serial part of the program in the software system becomes the bottleneck of the overall system performance, and the serial part is mainly embodied in various lock programs.
  • Critical sections of protection including semaphores, Mutex, Spinlock, switch interrupts, read-write locks, and more. If you can accurately and accurately count the information about the various lock programs in the serial part, you can provide data basis for the performance optimization of the entire software system.
  • a software monitoring method that is common under the prior art conditions is to use the software itself to perform plugging replacement of the lock program function to calculate the software lock program usage information.
  • Some software software monitoring tools such as Valgrind Mutextrace, commonly use software monitoring technology of such software instrumentation, the process generally replaces or increases a certain instruction of the detected target software (usually the function entry and return) as the detection program. The instruction; then enforce the detection program to obtain information about the lock program.
  • the embodiment of the invention provides a software monitoring method, device and system, which solves the problem that the introduction of excessive system overhead in the analysis process makes it difficult to calculate complete and detailed lock program usage information.
  • Embodiments of the present invention provide a software monitoring method, where a lock program address and a thread identifier using the lock program are recorded when a lock program is invoked or released; the lock program address and a thread using the lock program The identifier is encoded into a memory address, and the memory is accessed through the memory address; the memory bus is sensed to identify the access memory signal of the memory address and the tracking information of the lock program is obtained, and the tracking information of the lock program includes The memory address and the time information are obtained; the usage information of the lock program is obtained according to the tracking information, and the usage information includes the lock program address, a thread identifier using the lock program, and a time when the thread occupies a lock program.
  • An embodiment of the present invention provides a software monitoring apparatus, including a dynamic library module, a communication module, a listening module, and a data analysis module, wherein the dynamic library module is configured to record a lock program address and a thread identifier using the lock program;
  • the communication module is configured to encode the lock program address and a thread identifier using the lock program into a memory address and access the memory through the memory address;
  • the listening module is configured to listen to the memory bus to identify the Accessing the memory signal of the memory address and acquiring the tracking information of the lock program, the tracking information of the lock program includes the memory address and time information; and the data analysis module is configured to obtain the lock program according to the tracking information
  • the usage information includes the lock program address, a thread identifier using the lock program, and a time when the thread occupies a lock program.
  • the software monitoring method, device and system described above only implement the lock program address and the record and code conversion address of the thread identifier through the software part, and the interception, storage and analysis aspects can be implemented by using the bypass hardware, for example, through the memory interface or The card is inserted into the slot to implement the listening, storage and analysis of the memory bus, and the bypass hardware does not need to make any modifications to the target program. Occupying the processing resources of the system does not affect the running environment of the application, so that the software and hardware can be combined to achieve the analysis of the corresponding system performance without additional system overhead.
  • FIG. 1 is a schematic flow chart of a software monitoring method according to an embodiment of the present invention.
  • FIG. 2 is a schematic flow chart showing a part of a software monitoring method according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram showing another part of a software monitoring method according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a software monitoring apparatus according to another embodiment of the present invention. detailed description
  • An embodiment of the invention provides a software monitoring method, which mainly analyzes related information of a serial part of the system, and the analysis method adopts non-instrument analysis, does not make any modification to the target program, and does not depend on specific software or
  • the hardware platform does not introduce additional overhead during the analysis run, so that the information needed for the analysis can be fully recorded.
  • an embodiment of the present invention provides a software monitoring method, including:
  • Step 101 Record a lock program address and a thread identifier, where the thread identifier is used to identify a thread that uses the lock program;
  • Step 102 Obtain a memory address according to the lock program address and using the lock program thread identifier, and access the memory by using the memory address;
  • Step 103 Listening to the memory bus to identify the signal for accessing the memory, and acquiring tracking information of the lock program according to the signal, where the tracking information of the lock program includes the memory address and Access time information;
  • Step 104 Obtain usage information of the lock program according to the tracking information, where the usage information includes the lock program address, a thread identifier that uses the lock program, and a time when the thread occupies a lock program, and the occupation The time of the lock program is determined based on the access time information.
  • the record lock program address and the thread identifier are performed in a process of reloading a function related to the lock program.
  • Reloading the function related to the lock program by dynamic instrumentation or by loading a custom dynamic link library before the program is run, acquiring and recording the lock program address and the thread identifier in the overload function,
  • the overloaded functions can be mutex's pthread_mutex_init, pthread_mutex_lock:, pthread_mutex_imlock:, pthread_mutex_trylock, and thread_mutex_destroy.
  • the access to the lock program in the multi-threaded program may be directly hit in the Cache without accessing the memory, but in the memory bus by listening to the memory bus.
  • the monitoring access memory operation there is no way to capture a lock program variable that does not access the memory.
  • a memory address is obtained according to the address of the lock program and the thread identifier of the lock program.
  • the manner of obtaining the memory address may be mapping or encoding conversion according to a custom encoding rule, and the memory address is set to be non-cacheable, so that the access memory through the memory address can be captured by the bus listening module.
  • the dynamic library module When the lock program is called or released, the dynamic library module is triggered to record the address of the lock program and the occupied thread identifier, and then the communication module converts the lock program address and the thread identifier of the lock program into a memory address, When the lock program is called, the memory is accessed through the memory address, and the memory address is a physical address in the memory.
  • converting the lock program address and the thread identifier using the lock program into a memory address by using a code is also a main mapping table, wherein the specific code is as follows:
  • Thread ID the offset of the thread ID in the thread mapping table
  • Lock Addr The offset of the lock program address in the lock program address mapping table
  • Lock Flag A flag that locks or unlocks a program
  • Reservedl reserved domain, pointing to the first address of the reserved physical memory area
  • Reserved2 Reserved domain, the memory controller masks the lower 3 bits of the physical memory address.
  • the step of listening to the memory bus and acquiring the access information in the memory bus to the access address of the memory address includes:
  • Step 201 Reserve a physical address space to map access memory of the lock program address and a memory address encoded by the thread identifier of the lock program to access memory of the physical address space;
  • Step 202 Listening to an access address in the memory bus and determining whether the access address is mapped in the physical address space;
  • Step 203 Encapsulate the access memory address and the time information mapped in the physical address space into tracking information according to the judgment result;
  • Step 204 Transmitting the tracking information.
  • the physical address space is reserved by the detected host, and is used as a mapping space for capturing an access memory signal of the memory address during the listening process, where the physical address space is composed of a plurality of segment physical addresses.
  • the physical address space is a two-segment physical address.
  • the memory address in the memory bus is identified by the mapping table as the lock program address and the thread identifier code converted by using the lock program, that is, the memory address converted by the code.
  • the access memory is mapped to the memory of the physical address space, and the specific process is: if the access memory address is in the physical address space through the mapping of the mapping table, the access memory address is the encoded conversion The memory address, then capture the access memory address and record the time information for encapsulation. The ID of the thread and the memory address converted by the lock program code.
  • the foregoing step of identifying the lock program address and the memory address converted by the thread identifier of the lock program may be implemented in other embodiments by using a registry, where the registry stores all the lock program addresses and The memory address of the coded conversion is encrypted using the thread of the lock program, and the current access memory address is identified as an address encoded by the lock program related information by traversing the alignment one by one.
  • the access memory address mapped in the physical address space is a lock program address and an encoding result of a thread identifier using the lock program, so the access memory address of the mapping in the physical address space can be inversely decoded into Lock program address and thread ID.
  • the tracking information further includes a serial number (SN) and a read/write information (RW), and the time information is a time stamp (TS), and the tracking information may be in the following format:
  • the sequence number is 12-bit, and the loop count is used to detect whether there is any loss during analysis.
  • the time stamp is 54-bit.
  • the time stamp records the time of the lock program call or lock program and the lock program release or unlock program by clock calibration, so that the lock program is occupied by the thread through the time stamp. time.
  • the recording of the time is triggered by listening to and capturing the signal of the lock program or the unlock program in the memory bus, that is, by monitoring the signal of the lock program state change (call or release) in the memory bus to start the clock record capture.
  • the time of the signal, and then calculate the time difference between the lock program call and release is the time the lock program is occupied.
  • the timestamp is clocked by a 400MHz clock on the board, which can ensure continuous timing for 521 days without overflow. Since this clock frequency is constant, the calculated time information is more accurate, and can be calibrated with the system clock to improve accuracy.
  • Read/Write is l-bit, which indicates whether the memory is read or written. 4. Accessing the memory address (Physical Address), the lock program address and the memory address converted by the thread identifier code.
  • the listening process in step 103 above implements listening to the memory bus by inserting a card on the memory interface or slot.
  • the use information of the lock program is obtained according to the tracking information in step 104, as shown in FIG. 3, wherein the obtaining of the lock program is used.
  • the information includes the following steps:
  • Step 301 Decapsulate the tracking information to obtain the memory address and time information of the lock program.
  • Step 302 De-decode the memory address into a lock program address and use a thread identifier of the lock program to obtain the lock program address, a thread identifier using the lock program, and a time when the thread occupies a lock program. distributed.
  • the usage information includes an address of the lock program, a thread identifier of the lock program, and a time stamp for calling and releasing the lock program.
  • the software monitoring is to perform statistical processing on the use information of the lock program, thereby obtaining time for each thread to occupy the lock program. Distribution, which provides statistical data support for system performance improvement.
  • the software monitoring method further includes storing the lock program before de-decoding the accessed memory information of the address to use the usage information of the lock program to perform performance analysis according to the usage information.
  • the step of tracking information After obtaining the tracking information of the lock program, the tracking information is stored on a storage device such as a hard disk for offline analysis, thereby completing the software of the system without occupying the processing resources of the system and generating no additional overhead. monitor.
  • the software monitoring method of the above embodiment only implements the lock program address and the record and code conversion address of the thread identifier through the software part, and the interception, storage and analysis aspects can be implemented by using the bypass hardware, for example, through the memory interface. Or insert a card on the slot to implement the listening, storage and analysis of the memory bus, and the bypass hardware does not need to make any modifications to the target program, Occupying the processing resources of the system does not affect the running environment of the application, so that the software and hardware can be combined to achieve the analysis of the corresponding system performance without additional system overhead.
  • a software monitoring apparatus includes a dynamic library module, a communication module, a listening module, and a data analysis module, where:
  • the dynamic library module is configured to record a lock program address and a thread identifier using the lock program, and a function related to the lock program by dynamic instrumentation or by loading a customized dynamic link library before the program runs. Reload, get and record the lock program address and thread ID during the overload function.
  • the communication module is configured to encode the lock program address and the thread identifier using the lock program into a memory address to access the memory, and when the lock program is invoked, trigger the dynamic library module to record the address of the lock program and
  • the occupied thread identifier is further converted by the communication module into the lock program address and the thread identifier occupying the lock program into a memory address to access the memory through the memory address when the lock program is called or released.
  • the listening module is configured to listen to the memory bus and identify the access memory signal of the memory address to obtain the tracking information of the lock program.
  • the monitored host or system reserves two pieces of physical address space to pass the mapping table. Establishing a mapping relationship between the lock program address and a memory address converted by the thread identifier of the lock program and the physical address space; and then identifying, by listening, mapping in the memory bus in the physical address space Accessing the address, and encapsulating the access address and time information into tracking information; and finally transmitting the tracking information to the data analysis module.
  • the time information is a time when the listening module captures a signal generated when the lock program is encoded into a memory address to access the memory due to being called or released, that is, a time stamp in which the lock program is called or released.
  • the listening module includes a clock to label time information for the capture of the access address by clock calibration.
  • the data analysis module is configured to decode the tracking information into usage information of the lock program to perform performance analysis according to the usage information, where the tracking information includes the address information and Time information, wherein the data analysis module inversely decodes the address information in the tracking information into the lock program address and the thread identifier of the lock program, to obtain usage information of the lock program, and the use information
  • the device includes a lock program address, a thread identifier of the lock program, and a time stamp for invoking and releasing the lock program.
  • the software monitor performs statistical processing on the use information of the lock program, thereby obtaining a time distribution of each thread occupying the lock program, thereby Performance improvements provide statistical data support.
  • the software monitoring apparatus of another embodiment of the present invention further includes a data storage module for receiving and storing the tracking information generated by the listening module.
  • the data storage module may be a storage device such as a hard disk of a host or a system, and the offline information may be stored by using the hard disk to store the tracking information, thereby separating data collection and analysis, thereby not occupying system processing resources and generating no additional resources. Complete software monitoring of the system in case of overhead.
  • the software monitoring method, apparatus and system of the embodiment of the present invention can only implement the recording and encoding conversion address of the lock program address and the thread identifier through the software part, and the interception, storage and analysis can be implemented by using the bypass hardware, for example, Inserting a card on the memory interface or slot to realize the listening, storage, and analysis of the memory bus.
  • clock calibration can be set on the card to effectively avoid the disorder of the event caused by different clocks in the multi-core environment. The problem.
  • the dedicated bypass hardware does not occupy resources such as the CPU of the system, and the software part only utilizes a small amount of resources of the system, and the resource occupancy rate of the system is generally low, and the bypass hardware does not affect the operating environment of the application, and the application program The interference is small, and the amount of behavioral information captured by the hardware is limited only by the hardware configuration, regardless of the application.
  • a software monitoring system includes a software detecting device and a software executing body, wherein the software monitoring device is configured to monitor a software program running on a software executing body,
  • the software executive body can be the monitored host.
  • the software detecting device is configured to record a lock program address of the software execution body and a thread identifier, where the thread identifier is used to identify a thread that uses the lock program; and obtain a memory address according to the lock program address and the thread identifier And accessing the memory through the memory address; listening to the memory bus to identify the signal accessing the memory and acquiring tracking information of the lock program according to the signal, the tracking information of the lock program including the memory address and access Time information; obtaining usage information of the lock program according to the tracking information, the usage information including the lock program address, a thread identifier using the lock program, and a time when the thread occupies a lock program, the occupation lock The time of the program is determined based on the access time information.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种软件监测方法、装置以及系统,所述方法包括以下步骤:在锁程序被调用或释放时记录锁程序地址以及线程标识,所述线程标识用于标识使用所述锁程序的线程(101);根据所述锁程序地址以及所述线程标识获得内存地址,并通过所述内存地址访问内存(102);侦听内存总线以识别所述访问内存的信号并根据所述信号获取所述锁程序的追踪信息(103),所述锁程序的追踪信息包括所述内存地址以及访问时间信息;根据所述追踪信息获得所述锁程序的使用信息(104),所述使用信息包括所述锁程序地址、使用所述锁程序的线程标识以及所述线程占用锁程序的时间,所述占用锁程序的时间根据所述访问时间信息确定。

Description

软件监测方法、装置以及系统
技术领域 本发明涉及计算机技术领域, 尤其涉及一种软件监测方法、 装置以及 系统。 背景技术
在使用并行技术的软件系统中, 例如应用多线程技术以及多核处理技 术等软件系统, 软件系统中程序的串行部分成为整个系统性能的瓶颈因素, 而串行部分主要体现在各种锁程序所保护的临界区, 包括信号量, 互斥锁 程序 (Mutex) , 自旋锁程序 (Spinlock), 开关中断, 读写锁程序等等 。 如果 能够详细、 准确地统计串行部分中各种锁程序的相关信息, 则可以为整个 软件系统的性能优化提供数据依据。
在现有技术条件下常见的一种软件监测方法是通过软件自身会给锁程 序函数进行插桩替换的方式来统计软件的锁程序使用信息。 一些软件软件 监测工具如 Valgrind Mutextrace等,普遍使用这种软件插桩的软件监测技术, 其过程一般为先替换或增加被检测目标软件的某段指令 (通常为函数的入 口和返回) 为检测程序的指令; 再强制执行检测程序, 以获取锁程序的相 关信息。
然而, 这种软件监测方式需要修改目标程序并强制执行监测程序, 这 样在运行软件系统的同时增加系统的运行负担。 对于较为大型的软件系统 来说, 软件系统具有数量庞大的临界区和对应管理临界区的锁程序, 而利 用现有的插桩方式进行软件分析的话, 插桩的数量也是非常庞大的, 这样 致使软件系统通常会在高负荷的环境下进行测试和数据搜集, 带来较大的 系统开销, 并严重干扰应用程序的正常运行, 追踪导致难以统计出完整而 详细的锁程序使用信息。 发明内容
本发明实施例提供一种软件监测方法、 装置以及系统, 以解决分析过 程中引入过大系统开销而致使难以统计出完整而详细的锁程序使用信息的 问题。
本发明实施例提供一种软件监测方法, 所述方法在锁程序被调用或释 放时记录锁程序地址以及使用所述锁程序的线程标识; 将所述锁程序地址 以及使用所述锁程序的线程标识进行编码转化为内存地址, 并通过所述内 存地址访问内存; 侦听内存总线以识别所述内存地址的访问内存信号并获 取所述锁程序的追踪信息, 所述锁程序的追踪信息包括所述内存地址以及 时间信息; 根据所述追踪信息获得所述锁程序的使用信息, 所述使用信息 包括所述锁程序地址、 使用所述锁程序的线程标识以及所述线程占用锁程 序的时间。
本发明实施例提供一种软件监测装置, 包括动态库模块、 通信模块、 侦听模块以及数据分析模块, 其中所述动态库模块用于记录锁程序地址以 及使用所述锁程序的线程标识; 所述通信模块用于将所述锁程序地址以及 使用所述锁程序的线程标识进行编码转化为内存地址并通过所述内存地址 访问内存; 所述侦听模块用于侦听内存总线以识别所述内存地址的访问内 存信号并获取所述锁程序的追踪信息, 所述锁程序的追踪信息包括所述内 存地址以及时间信息; 所述数据分析模块用于根据所述追踪信息获得所述 锁程序的使用信息, 所述使用信息包括所述锁程序地址、 使用所述锁程序 的线程标识以及所述线程占用锁程序的时间。
上述软件监测方法、 装置以及系统只有锁程序地址以及线程标识的记 录和编码转化地址通过软件部分实现, 而侦听、 存储以及分析方面均可以 利用旁路硬件来实现, 例如, 通过在内存接口或插槽上插卡来实现对内存 总线的侦听、 存储以及分析, 而旁路硬件无需对目标程序做任何修改, 不 占用系统的处理资源, 也不影响应用程序的运行环境, 从而通过这样软硬 结合的方式可以在不带来额外的系统开销的情况下, 实现对应系统性能的 分析。 附图说明
图 1所示为本发明一实施例中软件监测方法的流程示意图。
图 2所示为本发明一实施例中软件监测方法的一部分流程示意图。 图 3所示为本发明一实施例中软件监测方法的另一部分流程示意图。 图 4所示为本发明另一实施例中软件监测装置的示意图。 具体实施方式
下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案进 行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本领域技术人员所获得的 所有其他实施例, 都属于本发明保护的范围。
本发明一实施例提供一种软件监测方法, 主要对系统串行部分的相关 信息进行分析, 所述分析方法采用非插桩式分析, 不对目标程序做任何修 改, 也不依赖于具体的软件或硬件平台, 在分析运行过程中不引入额外的 开销, 从而可以充分记录分析所需的信息。
如图 1所示, 本发明实施例提供一种软件监测方法, 包括:
歩骤 101、记录锁程序地址以及线程标识, 所述线程标识用于标识使用 所述锁程序的线程;
歩骤 102、根据所述锁程序地址以及使用所述锁程序线程标识获得内存 地址, 并通过所述内存地址访问内存;
歩骤 103、侦听内存总线以识别所述访问内存的信号并根据所述信号获 取所述锁程序的追踪信息, 所述锁程序的追踪信息包括所述内存地址以及 访问时间信息;
歩骤 104、根据所述追踪信息获得所述锁程序的使用信息, 所述使用信 息包括所述锁程序地址、 使用所述锁程序的线程标识以及所述线程占用锁 程序的时间, 所述占用锁程序的时间根据所述访问时间信息确定。
上述歩骤 101 中, 所述记录锁程序地址以及线程标识是在重载与所述 锁程序相关的函数的过程中进行。 通过动态插桩的方式或在程序运行前通 过加载自定义的动态连接库的方式, 将与锁程序相关的函数进行重载, 在 重载函数中获取并记录锁程序地址以及线程标识, 所述重载函数可以为 mutex的 pthread_mutex_init、 pthread_mutex_lock:、 pthread—mutex—imlock:、 pthread_mutex_trylock以及 thread_mutex_destroy等函数。
上述歩骤 102中, 由于 Cache (高速缓冲存储器) 的作用, 多线程程序 中对锁程序的访问可能不需要访问内存而直接被在 Cache 中命中, 而通过 对内存总线的侦听而在内存总线上监控访问内存操作, 没有办法捕获到不 访问内存的锁程序变量, 而在本实施例的软硬件协同检测机制中, 根据锁 程序的地址以及使用所述锁程序的线程标识获得一个内存地址, 所述获取 的内存地址的方式可以是映射或者根据自定编码规则进行编码转换, 而所 述内存地址被设置为不可缓存, 这样通过所述内存地址的访问内存均都能 被总线侦听模块捕获到。
当锁程序被调用或释放时, 便触发动态库模块记录锁程序的地址以及 占用的线程标识, 再由通信模块将所述锁程序地址以及占用锁程序的线程 标识转化为内存地址, 以在所述锁程序被调用的时候通过所述内存地址进 行访问内存, 所述内存地址为内存上的物理地址。
其中, 将所述锁程序地址以及使用所述锁程序的线程标识通过编码转 化为内存地址也是主要映射表来实现的, 其中具体的编码如下:
Figure imgf000006_0001
其中字段表示的含义为: Thread ID: 线程标识在线程映射表中的偏移;
Lock Addr: 锁程序地址在锁程序地址映射表中的偏移;
Lock Flag: 加锁程序或解锁程序的标志;
Reservedl: 保留域, 指向预留物理内存区域的首地址;
Reserved2: 保留域, 内存控制器将物理内存地址的低 3位屏蔽。
如图 2所述上述歩骤 103中, 侦听内存总线并获取所述内存总线中访 问地址为所述内存地址的访问信息的歩骤进一歩包括:
歩骤 201、预留物理地址空间, 以将对所述锁程序地址以及使用所述锁 程序的线程标识编码转化的内存地址的访问内存映射为对所述物理地址空 间的访问内存;
歩骤 202、侦听所述内存总线中的访问地址并判断所述访问地址是否映 射在所述物理地址空间内;
歩骤 203、根据判断结果, 将映射在所述物理地址空间内的访问内存地 址以及时间信息封装成追踪信息;
歩骤 204、 传输所述追踪信息。
上述歩骤 201 中, 由被检测主机预留所述物理地址空间, 用于作为在 侦听过程中所述内存地址的访问内存信号捕获的映射空间, 所述物理地址 空间由若干段段物理地址组成, 在本实施例中所述物理地址空间为两段段 物理地址。
上述歩骤 202和 203中, 通过映射表识别出内存总线中访问地址为所 述锁程序地址以及使用所述锁程序的线程标识编码转化的内存地址, 也就 是对所述编码转化的内存地址的访问内存映射为对所述物理地址空间的访 问内存, 具体过程是, 如果所述访问内存地址通过映射表的映射在所述所 述物理地址空间内, 则所述访问内存地址为所述编码转化的内存地址, 则 捕获所述访问内存地址并记录时间信息进行封装。所述线程的 ID以及锁程 序编码转化的内存地址。 上述识别所述锁程序地址以及使用所述锁程序的线程标识编码转化的 内存地址的歩骤在其它实施例中也可以通过注册表来实现, 所述注册表储 存有所有所述锁程序地址以及使用所述锁程序的线程标识编码转化的内存 地址, 通过逐一遍历比对来识别当前访问内存地址是否为由所述锁程序相 关信息编码转换的地址。
所述映射在所述物理地址空间内的访问内存地址为锁程序地址以及使 用所述锁程序的线程标识的编码结果, 因此所述映射在所述物理地址空间 内的访问内存地址可以反解码为锁程序地址以及线程标识。 所述追踪信息 还包括序列号 (SN)与读写信息 (RW), 所述时间信息为时间戳(TS), 所述追 踪信息可采用如下格式:
Figure imgf000008_0001
1、 序列号 (Sequence Number)为 12-bit, 采用循环计数, 用于在分析的 时候检测有没有丢失。
2、 时间戳 (Time Stamp)为 54-bit, 所述时间戳通过时钟校准来记录锁程 序调用或加锁程序以及锁程序释放或解锁程序的时间, 从而通过时间戳统 计锁程序被线程占用的时间。 所述时间的记录是通过侦听并捕获内存总线 中加锁程序或解锁程序的信号来触发的, 也就是通过侦听内存总线中锁程 序状态变化 (调用或释放) 的信号来启动时钟记录捕获信号的时间, 再计 算出锁程序调用和释放的时间差便是锁程序被占用的时间。 所述时间戳采 用板上 400MHz时钟计时, 可以保证连续计时 521天而不溢出, 由于这个 时钟频率恒定不变, 因此统计出来的时间信息更为准确, 且可以和系统时 钟校准, 提高准确性。
3、 读写 (Read/Write)为 l-bit, 标识此次访问内存是读或者写。 4、访问内存地址(Physical Address ) , 所述锁程序地址以及线程标识编 码转化的内存地址。
上述歩骤 103 中的侦听过程通过在内存接口或插槽上插卡来实现对内 存总线的侦听。
针对歩骤 102编码以及歩骤 103 的追踪信息获取过程, 上述歩骤 104 中根据所述追踪信息获得所述锁程序的使用信息, 如图 3所示, 其中所述 获得所述锁程序的使用信息包括以下歩骤:
歩骤 301、将所述追踪信息解封装获得所述内存地址以及所述锁程序的 时间信息;
歩骤 302、将所述内存地址反解码为锁程序地址以及使用所述锁程序的 线程标识, 以获得所述锁程序地址、 使用所述锁程序的线程标识以及所述 线程占用锁程序的时间分布。
所述使用信息包括锁程序的地址、 调用锁程序的线程标识以及调用和 释放锁程序的时间戳; 所述软件监测是对锁程序的使用信息进行统计处理, 从而获得各个线程占用锁程序的时间分布, 从而为系统的性能改进提供统 计数据支持。
本发明一实施例的软件监测方法在将所述地址的访问内存信息反解码 为使用所述锁程序的使用信息以根据所述使用信息进行性能分析的歩骤 104之前还包括储存所述锁程序的追踪信息的歩骤。在获得所述锁程序的追 踪信息后, 将所述追踪信息储存于如硬盘等存储设备上, 以便进行离线分 析, 从而在不占用系统的处理资源和不产生额外开销的情况下完成系统的 软件监测。
可见, 上述实施例的软件监测方法只有锁程序地址以及线程标识的记 录和编码转化地址通过软件部分实现, 而侦听、 存储以及分析方面均可以 利用旁路硬件来实现, 例如, 通过在内存接口或插槽上插卡来实现对内存 总线的侦听、 存储以及分析, 而旁路硬件无需对目标程序做任何修改, 不 占用系统的处理资源, 也不影响应用程序的运行环境, 从而通过这样软硬 结合的方式可以在不带来额外的系统开销的情况下, 实现对应系统性能的 分析。
如图 4所示, 本发明另一实施例中一种软件监测装置, 包括动态库模 块、 通信模块、 侦听模块以及数据分析模块, 其中:
所述动态库模块用于记录锁程序地址以及使用所述锁程序的线程标识, 通过动态插桩的方式或在程序运行前通过加载自定义的动态连接库的方式, 将与锁程序相关的函数进行重载, 在重载函数的过程中获取并记录锁程序 地址以及线程标识。
所述通信模块用于将所述锁程序地址以及使用所述锁程序的线程标识 进行编码转化为一内存地址进行访问内存, 当锁程序被调用时, 便触发动 态库模块记录锁程序的地址以及占用的线程标识, 再由通信模块将所述锁 程序地址以及占用锁程序的线程标识转化为内存地址, 以在所述锁程序被 调用或释放时通过所述内存地址进行访问内存。
所述侦听模块用于侦听内存总线并识别所述内存地址的访问内存信号 以获取所述锁程序的追踪信息, 首先由被监测主机或系统预留两段物理地 址空间, 以通过映射表建立所述锁程序地址以及使用所述锁程序的线程标 识编码转化的内存地址与所述物理地址空间之间的映射关系; 然后通过侦 听来识别内存总线中映射在所述物理地址空间内的访问地址, 并将所述访 问地址以及时间信息封装成追踪信息; 最后向数据分析模块发送所述追踪 信息。 所述时间信息为所述侦听模块捕获所述锁程序因被调用或释放而被 编码转化为内存地址进行访问内存时产生的信号的时间, 也就是所述锁程 序被调用或释放的时间戳。 所述侦听模块包括时钟, 以通过时钟校准来为 所述访问地址的捕获标注时间信息。
所述数据分析模块用于将所述追踪信息解码为所述锁程序的使用信息 以根据所述使用信息进行性能分析, 所述追踪信息包括所述地址信息以及 时间信息, 其中所述数据分析模块将所述追踪信息中的所述地址信息反解 码为所述锁程序地址以及调用锁程序的线程标识, 以获得所述锁程序的使 用信息, 所述使用信息包括锁程序地址、 调用锁程序的线程标识以及调用 和释放锁程序的时间戳; 所述软件监测是对锁程序的使用信息进行统计处 理, 从而获得各个线程占用锁程序的时间分布, 从而为系统的性能改进提 供统计数据支持。
本发明另一实施例的软件监测装置还包括一数据存储模块, 用于接受 并存储所述侦听模块产生的所述追踪信息。 所述数据存储模块可以是主机 或系统的硬盘等存储设备, 通过硬盘存储所述追踪信息, 可以实现离线分 析, 从而将数据的收集与分析分离, 从而在不占用系统的处理资源和不产 生额外开销的情况下完成系统的软件监测。
本发明实施例的软件监测方法、 装置以及系统只有锁程序地址以及线 程标识的记录和编码转化地址通过软件部分实现, 而侦听、 存储以及分析 方面均可以利用旁路硬件来实现, 例如, 通过在内存接口或插槽上插卡来 实现对内存总线的侦听、 存储以及分析, 此外还可以在所述卡上设置时钟 校准而有效地避免了多核环境下时钟不同歩而造成的事件顺序紊乱的问题。 所述专用旁路硬件不占用系统的 CPU等资源, 而软件部分只利用系统的少 量资源, 总体上对系统的资源占用率低, 所述旁路硬件不影响应用程序的 运行环境, 对应用程序的干扰小, 而且硬件捕获的应用程序的行为信息量 仅受硬件配置的限制, 与应用程序无关。
可见, 上述软件监测方法、 装置以及系统, 通过软硬件的结合对系统 串行部分的相关信息进行非插桩式的分析, 不对目标程序做任何修改, 也 不依赖于具体的软件或硬件平台, 在分析运行过程中不引入额外的开销。
如图 4所示, 本发明又一实施例中一种软件监测系统, 包括一软件检 测装置以及软件执行主体, 其中所述软件监测装置用于监测运行在软件执 行主体上的软件程序, 所述软件执行主体可以是被监测主机。 所述软件检测装置用于记录所述软件执行主体的锁程序地址以及线程 标识, 所述线程标识用于标识使用所述锁程序的线程; 根据所述锁程序地 址以及所述线程标识获得内存地址, 并通过所述内存地址访问内存; 侦听 内存总线以识别所述访问内存的信号并根据所述信号获取所述锁程序的追 踪信息, 所述锁程序的追踪信息包括所述内存地址以及访问时间信息; 根 据所述追踪信息获得所述锁程序的使用信息, 所述使用信息包括所述锁程 序地址、 使用所述锁程序的线程标识以及所述线程占用锁程序的时间, 所 述占用锁程序的时间根据所述访问时间信息确定。
以上对本发明实施例提供的通信系统进行了详细介绍, 本文中应用了 具体个例对本发明的原理及实施方式进行了阐述, 以上实施例的说明只是 用于帮助理解本发明的方法及其核心思想; 同时, 对于本领域的一般技术 人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处, 综上所述, 本说明书内容不应理解为对本发明的限制。

Claims

权利要求
1、 一种软件监测方法, 其特征在于, 所述方法包括:
记录锁程序地址以及线程标识, 所述线程标识用于标识使用所述锁程 序的线程;
根据所述锁程序地址以及所述线程标识获得内存地址, 并通过所述内 存地址访问内存;
侦听内存总线以识别所述访问内存的信号并根据所述信号获取所述锁 程序的追踪信息, 所述锁程序的追踪信息包括所述内存地址以及访问时间
I R 自、 .,
根据所述追踪信息获得所述锁程序的使用信息, 所述使用信息包括所 述锁程序地址、 使用所述锁程序的线程标识以及所述线程占用锁程序的时 间, 所述占用锁程序的时间根据所述访问时间信息确定。
2、 根据权利要求 1所述的方法, 其特征在于, 所述侦听内存总线以识 别所述内存地址的访问内存信号并获取所述锁程序的追踪信息的歩骤中, 通过映射表识别出内存总线中访问地址为所述锁程序地址以及使用所述锁 程序的线程标识所转化的内存地址的访问内存信号。
3、 根据权利要求 2所述的方法, 其特征在于, 所述侦听内存总线以识 别所述内存地址的访问内存信号并获取所述锁程序的追踪信息包括:
预留物理地址空间, 通过所述映射表建立所述锁程序地址以及使用所 述锁程序的线程标识编码转化的内存地址与所述物理地址空间之间的映射 关系;
侦听所述内存总线中的访问地址并判断所述访问地址是否映射在所述 物理地址空间内;
根据判断结果, 将映射在所述物理地址空间内的访问内存地址以及时 间信息封装成追踪信息;
传输所述追踪信息。
4、 根据权利要求 3项所述的方法, 其特征在于, 所述物理地址空间为 两段段物理地址, 所述锁程序以及使用所述锁程序的线程标识编码转化的 内存地址通过映射表映射为所述两段段物理地址区间内的物理地址。
5、 根据权利要求 3所述的方法, 其特征在于, 在所述根据所述追踪信 息获得所述锁程序的使用信息的歩骤之前还包括接收并存储所述追踪信息 以供离线分析。
6、 根据权利要求 1所述的方法, 其特征在于, 根据所述锁程序地址以 及所述线程标识获得内存地址包括将所述锁程序地址以及所述线程标识编 码转化或者映射为内存地址。
7、 根据权利要求 1至 6任一项所述的方法, 其特征在于, 所述追踪信 息中的时间信息包括调用和释放锁程序的时间戳。
8、 根据权利要求 7所述的方法, 其特征在于, 所述调用和释放锁程序 的时间戳是通过时钟记录侦听到所述锁程序因被调用或释放而被编码转化 为内存地址并访问内存的时间。
9、 根据权利要求 7所述的方法, 其特征在于, 所述追踪信息还包括: 序列号, 用于在分析的时候检测有没有丢失;
读写信息, 用于标识此次访问内存是读或者写。
10、 根据权利要求 9所述的方法, 其特征在于, 所述追踪信息主要由 所述锁程序以及使用所述锁程序的线程标识编码转化的内存地址、 所述时 间信息、 序列号以及读写信息封装而成。
11、 根据权利要求 1至 6任一项所述的方法, 其特征在于, 所述记录 锁程序地址以及线程标识包括通过所述锁程序被调用时重载与锁程序相关 的函数中记录所述锁程序地址以及使用所述锁程序的线程标识。
12、 根据权利要求 11所述的方法, 其特征在于, 所述与所述锁程序相 关的函数通过动态插桩的方式或者在程序运行前加载自定义的动态连接库 的方式进行重载。
13、 根据权利要求 1至 6任一项所述的方法, 其特征在于, 所述根据 所述追踪信息获得所述锁程序的使用信息包括:
根据所述追踪信息获得所述内存地址以及所述锁程序的时间信息; 将所述内存地址反解码为锁程序地址以及使用所述锁程序的线程标识, 获得所述锁程序地址、 使用所述锁程序的线程标识以及所述线程占用锁程 序的时间信息。
14、 一种软件监测装置, 其特征在于, 所述装置包括:
动态库模块, 记录锁程序地址以及线程标识, 所述线程标识用于标识 使用所述锁程序的线程;
通信模块, 根据所述锁程序地址以及所述线程标识获得内存地址, 并 通过所述内存地址访问内存;
侦听模块, 侦听内存总线以识别所述访问内存的信号并根据所述信号 获取所述锁程序的追踪信息, 所述锁程序的追踪信息包括所述内存地址以 及访问时间信息;
数据分析模块, 根据所述追踪信息获得所述锁程序的使用信息, 所述 使用信息包括所述锁程序地址、 使用所述锁程序的线程标识以及所述线程 占用锁程序的时间, 所述占用锁程序的时间根据所述访问时间信息确定。
15、 根据权利要求 14所述的装置, 其特征在于, 所述侦听模块包括一 映射表, 通过所述映射表识别出内存总线中访问地址为所述锁程序地址以 及使用所述锁程序的线程标识所转化的内存地址。
16、 根据权利要求 15所述的装置, 其特征在于, 所述侦听模块在侦听 内存总线以识别所述内存地址的访问内存信号并获取所述锁程序的追踪信 息的过程中包括先由被监测主机预留物理地址空间, 以通过所述映射表将 所述锁程序地址以及使用所述锁程序的线程标识编码转化的内存地址映射 到所述物理地址空间内; 再通过侦听来识别内存总线中映射在所述物理地 址空间内的访问地址, 并将所述访问地址以及时间信息封装成追踪信息; 最后向数据分析模块发送所述追踪信息。
17、 根据权利要求 16所述的装置, 其特征在于, 所述物理地址空间为 两段段物理地址, 所述线程的 ID以及锁程序编码转化的内存地址通过映射 表映射为所述两段段物理地址区间内的物理地址。
18、 根据权利要求 14所述的装置, 其特征在于, 还包括一数据存储模 块, 用于接受并存储所述侦听模块产生的所述追踪信息。
19、 根据权利要求 14至 18任一项所述的装置, 其特征在于, 所述追 踪信息中的时间信息包括调用和释放锁程序的时间戳。
20、 根据权利要求 19所述的装置, 其特征在于, 所述侦听模块还包括 一时钟, 以通过时钟校准记录捕获所述锁程序因被调用或释放时被编码转 化为内存地址进行访问内存而产生访问内存信号的时间, 从而获得所述锁 程序被调用或释放的时间戳。
21、 根据权利要求 14至 18任一项所述的装置, 其特征在于, 所述动 态库模块通过所述锁程序被调用时重载与锁程序相关的函数中记录所述锁 程序地址以及使用所述锁程序的线程标识。
22、 根据权利要求 20所述的装置, 其特征在于, 所述与所述锁程序相 关的函数通过动态插桩的方式或在程序运行前加载自定义的动态连接库的 方式进行重载。
23、 根据权利要求 14至 18任一项所述的装置, 其特征在于, 所述数 据分析模块根据所述追踪信息获得所述内存地址以及所述锁程序的时间信 息, 再将所述内存地址反解码为锁程序地址以及使用所述锁程序的线程标 识, 从而获得所述锁程序地址、 使用所述锁程序的线程标识以及所述线程 占用锁程序的时间信息。
24、 一种软件监测系统, 包括一软件检测装置以及软件执行主体, 所 述软件执行主体用于执行一软件程序, 其特征在于, 所述软件检测装置用 于记录所述软件程序的锁程序地址以及线程标识, 所述线程标识用于标识 使用所述锁程序的线程; 根据所述锁程序地址以及所述线程标识获得内存 地址, 并通过所述内存地址访问内存; 侦听内存总线以识别所述访问内存 的信号并根据所述信号获取所述锁程序的追踪信息, 所述锁程序的追踪信 息包括所述内存地址以及访问时间信息; 根据所述追踪信息获得所述锁程 序的使用信息, 所述使用信息包括所述锁程序地址、 使用所述锁程序的线 程标识以及所述线程占用锁程序的时间, 所述占用锁程序的时间根据所述 访问时间信息确定。
PCT/CN2011/075705 2011-06-14 2011-06-14 软件监测方法、装置以及系统 WO2012171171A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2011/075705 WO2012171171A1 (zh) 2011-06-14 2011-06-14 软件监测方法、装置以及系统
CN201180001455.XA CN102301343B (zh) 2011-06-14 2011-06-14 软件监测方法、装置以及系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/075705 WO2012171171A1 (zh) 2011-06-14 2011-06-14 软件监测方法、装置以及系统

Publications (1)

Publication Number Publication Date
WO2012171171A1 true WO2012171171A1 (zh) 2012-12-20

Family

ID=45360523

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/075705 WO2012171171A1 (zh) 2011-06-14 2011-06-14 软件监测方法、装置以及系统

Country Status (2)

Country Link
CN (1) CN102301343B (zh)
WO (1) WO2012171171A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103207809B (zh) * 2012-01-13 2017-07-07 金蝶软件(中国)有限公司 清除互斥锁的方法及系统
CN105786692B (zh) * 2014-12-24 2019-02-05 远光软件股份有限公司 一种软件运行期性能分析方法
TWI650648B (zh) * 2018-02-09 2019-02-11 慧榮科技股份有限公司 系統晶片及存取系統晶片中記憶體的方法
CN110162483B (zh) * 2018-02-12 2020-10-20 上海寒武纪信息科技有限公司 静态内存碎片整理方法、装置、计算机设备及存储介质
CN108595502B (zh) * 2018-03-19 2021-06-22 网宿科技股份有限公司 评估数据库服务性能的方法、装置及计算机可读存储介质
CN108762825B (zh) * 2018-04-20 2021-04-27 烽火通信科技股份有限公司 动态库重载的实现方法及系统
CN109040653B (zh) * 2018-06-28 2020-09-29 苏州科达科技股份有限公司 数据加解密开销确定方法、装置及电子设备
CN114064212B (zh) * 2021-11-16 2022-07-29 摩尔线程智能科技(北京)有限责任公司 Pci设备的访问地址跟踪方法、设备及计算机可读存储介质
CN117077447B (zh) * 2023-10-17 2024-02-23 西安羚控电子科技有限公司 多席位协同想定编辑方法及装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101110044A (zh) * 2007-08-28 2008-01-23 中兴通讯股份有限公司 一种内存监控管理的方法及系统
CN102033804A (zh) * 2009-09-29 2011-04-27 国际商业机器公司 辅助内存分析的方法和系统
US20110113406A1 (en) * 2009-11-10 2011-05-12 International Business Machines Corporation Symmetric multi-processor lock tracing

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101110044A (zh) * 2007-08-28 2008-01-23 中兴通讯股份有限公司 一种内存监控管理的方法及系统
CN102033804A (zh) * 2009-09-29 2011-04-27 国际商业机器公司 辅助内存分析的方法和系统
US20110113406A1 (en) * 2009-11-10 2011-05-12 International Business Machines Corporation Symmetric multi-processor lock tracing

Also Published As

Publication number Publication date
CN102301343B (zh) 2014-02-19
CN102301343A (zh) 2011-12-28

Similar Documents

Publication Publication Date Title
WO2012171171A1 (zh) 软件监测方法、装置以及系统
CN109313567B (zh) 虚拟化精确的基于事件的采样的设备和方法
US6883162B2 (en) Annotations for transaction tracing
EP2956861B1 (en) Method and system for detecting concurrency programming errors in kernel modules and device drivers
US10394714B2 (en) System and method for false sharing prediction
US20160364315A1 (en) Fast data race detection for multicore systems
CN102609254B (zh) 获取对象级访存行为的方法及装置
US9720744B2 (en) Performance monitoring of shared processing resources
US10535368B1 (en) Reader bias based locking technique enabling high read concurrency for read-mostly workloads
US9552221B1 (en) Monitoring application execution using probe and profiling modules to collect timing and dependency information
US10671548B2 (en) Memory initialization detection system
Akiyama et al. Quantitative evaluation of intel pebs overhead for online system-noise analysis
Giraldeau et al. Recovering system metrics from kernel trace
Honarmand et al. RelaxReplay: Record and replay for relaxed-consistency multiprocessors
US8135690B2 (en) Concurrency object classification
EP3274839B1 (en) Technologies for root cause identification of use-after-free memory corruption bugs
Guo et al. Minimum viable device drivers for ARM TrustZone
US9348723B2 (en) Method, system, and computer program product
KR101748441B1 (ko) 거짓 공유 검출 장치 및 방법
US9639477B2 (en) Memory corruption prevention system
CN103853551A (zh) 检测未初始化的存储器读取的方法
US20140229715A1 (en) Apparatus and method for providing eventing ip and source data address in a statistical sampling infrastructure
CN113672499A (zh) 追踪可执行程序中的目标变量的方法和系统
WO2023036076A1 (zh) 一种软件监测方法以及相关装置
US11010274B2 (en) Method and apparatus for trace data collection

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 201180001455.X

Country of ref document: CN

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11867661

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11867661

Country of ref document: EP

Kind code of ref document: A1