Simple Linux Utility for Resource Management

# SLURM Process Tracking Plugin API

## Overview

This document describes SLURM process tracking plugins and the API that defines them. It is intended as a resource to programmers wishing to write their own SLURM process tracking plugins. This is version 0 of the API.

SLURM process tracking plugins are SLURM plugins that implement the SLURM process tracking API described herein. They must conform to the SLURM Plugin API with the following specifications:

const char plugin_type[]
The major type must be "proctrack." The minor type can be any recognizable abbreviation for the type of proctrack. We recommend, for example:

- aix—Perform process tracking on an AIX platform. NOTE: This requires a kernel extension that records ever process creation and termination.
- cgroup—Use Linux cgroups for process tracking.
- linuxproc—Perform process tracking based upon a scan of the Linux process table and use the parent process ID to determine what processes are members of a SLURM job. NOTE: This mechanism is not entirely reliable for process tracking.
- lua—Use site-defined Lua script for process tracking. Sample Lua scripts can be found with the SLURM distribution in the directory contribs/lua. The default installation location of the Lua scripts is the same location as the SLURM configuration file, slurm.conf.
- pgid—Use process group ID to determine what processes are members of a SLURM job. NOTE: This mechanism is not entirely reliable for process tracking.
- rms—Use a Quadrics RMS kernel patch to establish what processes are members of a SLURM job. NOTE: This requires a kernel patch that records every process creation and termination.
- sgj_job—Use SGI's Process Aggregates (PAGG) kernel module. NOTE: This kernel module records every process creation and termination.

The plugin_name and plugin_version symbols required by the SLURM Plugin API require no specialization for process tracking. Note carefully, however, the versioning discussion below.

The programmer is urged to study src/plugins/proctrack/pgid/proctrack_pgid.c for an example implementation of a SLURM proctrack plugin.

## Data Objects

The implementation must support a container id of type uint64_t. This container ID is maintained by the plugin directly in the slurmd job structure using the field named cont_id.

The implementation must maintain (though not necessarily directly export) an enumerated errno to allow SLURM to discover as practically as possible the reason for any failed API call. These values must not be used as return values in integer-valued functions in the API. The proper error return value from integer-valued functions is SLURM_ERROR. The implementation should endeavor to provide useful and pertinent information by whatever means is practical. Successful API calls are not required to reset errno to a known value.

## API Functions

The following functions must appear. Functions which are not implemented should be stubbed.

int slurm_container_plugin_create (slurmd_job_t *job);

Description: Create a container. The container should be valid slurm_container_plugin_destroy() is called. This function must put the container ID directory in the job structure's variable cont_id.

Argument: job (input/output) Pointer to a slurmd job structure.

Returns: SLURM_SUCCESS if successful. On failure, the plugin should return SLURM_ERROR and set the errno to an appropriate value to indicate the reason for failure.

int slurm_container_plugin_add (slurmd_job_t *job, pid_t pid);

Description: Add a specific process ID to a given job's container.

Arguments:
job (input) Pointer to a slurmd job structure.
pid (input) The ID of the process to add to this job's container.

Returns: SLURM_SUCCESS if successful. On failure, the plugin should return SLURM_ERROR and set the errno to an appropriate value to indicate the reason for failure.

int slurm_container_plugin_signal (uint64_t id, int signal);

Description: Signal all processes in a given job's container.

Arguments:
id (input) Job container's ID.
signal (input) Signal to be sent to processes. Note that a signal of zero just tests for the existence of processes in a given job container.

Returns: SLURM_SUCCESS if the signal was sent. If the signal can not be sent, the function should return SLURM_ERROR and set its errno to an appropriate value to indicate the reason for failure.

int slurm_container_plugin_destroy (uint64_t id);

Description: Destroy or otherwise invalidate a job container. This does not imply the container is empty, just that it is no longer needed.

Arguments: id (input) Job container's ID.

Returns: SLURM_SUCCESS if successful. On failure, the plugin should return SLURM_ERROR and set the errno to an appropriate value to indicate the reason for failure.

uint64_t slurm_container_plugin_find (pid_t pid);

Description: Given a process ID, return its job container ID.

Arguments: pid (input) A process ID.

Returns: The job container ID with this process or zero if none is found.

uint32_t slurm_container_plugin_get_pids (uint64_t cont_id, pid_t **pids, int *npids);

Description: Given a process container ID, fill in all the process IDs in the container.

Arguments: cont_id (input) A container ID.
pids (output) Array of process IDs in the container.
npids (output) Count of process IDs in the container.

Returns: SLURM_SUCCESS if successful, SLURM_ERROR else.

## Versioning

This document describes version 91 of the SLURM Process Tracking API. Future releases of SLURM may revise this API. A process tracking plugin conveys its ability to implement a particular API version using the mechanism outlined for SLURM plugins.

Last modified 29 April 2011