WARNING: This is the _old_ Lustre wiki, and it is in the process of being retired. The information found here is all likely to be out of date. Please search the new wiki for more up to date information.

Lustre Debugging for Developers

From Obsolete Lustre Wiki
Jump to navigationJump to search

Intro...

Adding Debugging to the Source Code

The debug infrastructure provides a number of macros that can be used in Lustre™ source code to aid in debugging or reporting serious errors.

To use these macros, you will need to set the DEBUG_SUBSYSTEM variable at the top of the file to do what?? as shown below:

#define DEBUG_SUBSYSTEM S_PORTALS

A list of available macros with descriptions is provided in see Section 23.2.8: Adding Debugging to the Lustre Source Code in the Lustre Operations Manual.

Ptlrpc Request History

Each service maintains a request history, which can be useful for first occurrence troubleshooting.

Is ptlrpc an acronym?

Ptlrpc history works as follows:

  1. request_in_callback() adds the new request to the service's request history.
  2. When a request buffer becomes idle add it the contents of the request buffer? to the service's request buffer history list.
  3. Cull buffers from the service's request buffer history if it has grown above "req_buffer_history_max" and remove its reqs from the service's request history.


The request history is accessed and controlled using the following /proc files under the service directory:

req_buffer_history_len Number of request buffers currently in the history
req_buffer_history_max Maximum number of request buffers to keep
req_history Request history

Note that requests in the history include "live" requests that are actually being handled. Each line in req_history looks like:

<seq>:<target NID>:<client ID>:<xid>:<length>:<phase> <svc specific>

Where:

seq Request sequence number
target NID Destination NID of the incoming request
client ID client's PID and NID
xid rq_xid
length size of the request message
phase:
  New Waiting to be handled or couldn't be unpacked
  Interpret Unpacked and being handled
  Complete Handled
svc specific Service-specific request printout. Currently the only service that does this is the OST, which prints the opcode if the message has been unpacked successfully.

LWT Tracing

A lightweight tracing facility called LWT prints fixed size requests into a buffer and is faster than LDEBUG.

The records that are dumped contain:

  • Current CPU
  • Process counter
  • Pointer to file
  • Pointer to line in the file
  • Four void * pointers

An lctl command dumps the logs to files.

This tracking facility has been used successfully to debug difficult problems.

Is this included with Lustre?

Finding memory leaks

Memory leaks can occur in code when memory has been allocated and then not freed once it is no longer required. The leak_finder.pl program provides a way to find memory leaks. To use this program, follow these steps:

1. Turn on debugging to make sure all malloc and free entries are collected by entering:

sysctl -w lnet.debug=+malloc

2. Use lctl to dump the log into a user specified log file as shown in previous section.

3. Run the leak finder on the contents of the log file by entering:

perl leak_finder.pl <ascii-logname>

The output is similar to:

malloced 8bytes at a3116744 called pathcopy
(lprocfs_status.c
lprocfs_add_vars:80)
freed 8bytes at a3116744 called pathcopy
(lprocfs_status.c
lprocfs_add_vars:80)

The leak_finder.pl tool also displays any leaks that were found found:

Leak:32bytes allocated at a23a8fc  (service.c:ptlrpc_init_svc:144,debug file line 241)