Configurable Maximum Memory Limit for OpenSync Managers

Configurable Maximum Memory Limit for OpenSync Managers

General

To periodically monitor the memory usage of each manager process started by DM, as listed in the Node_Services table was added. Other Linux processes are not within the scope of this feature. If a monitored process exceeds its specified maximum memory usage to many times, a SIGABRT signal will be sent to terminate the process, prompting it to release memory resources. Subsequently, the DM will perform the predefined action for the terminated child process, as already defined in Node_Service (other_config), with a special crash reason reported via MQTT.

Implementation Outline

When the DM process starts, it retrieves the memory limits from OVSDB, which is pre-populated with the Kconfig defaults for each manager.

In case the limit is changed in database, a database callback function will refresh the effective limit for each manager.

If max_memory is not defined, the default value specified in Kconfig (DM_DEFAULT_MAX_MEMORY) will be used. If it is set to -1 for the given process, this check will be disabled, and no action will be taken by DM for that specific process.

The physical memory usage (PSS) will be examined for each process to ensure consistency with the current statistics reported to the cloud.

The number of consecutive times the memory limit can be exceeded before action is taken can be configured per process via the max_memory_cnt field. If not specified, the default value from Kconfig (DM_DEFAULT_MAX_MEMORY_CNT) is used.
With a hardcoded polling period of 30 seconds, this results in a default 5-minute grace period before the process is aborted—unless the limit is modified or the memory usage falls below the threshold, resetting the counter to 0.

Northbound API

MQTT

  • The Crash/Reports MQTT topic will be reused to send JSON-formatted reports for managers killed by DM due to exceeding memory limitations.

  • The existing JSON crash report mechanism will be reused here with a new reason Maximum memory limit exceeded (xxxxxx kB).

  • Example JSON Report:

    { "nodeId": "ABCDEFG10E", "locationId": "67a333ad2b0163894b5956f3", "firmwareVersion": "7.0.0-32599-g38d0bb-opensync", "model": "PP123X", "pid": "<NA>", "name": "OpenSync", "reason": "Maximum memory limit exceeded (32000 kB)", "timestamp": 1738838543963, "backtrace": "0 > 0xb6bcca00: os_backtrace 0x34 /usr/opensync/lib/libopensync.so\n 1 > 0xb6bccab8: os_backtrace_dump_generic 0xa4 /usr/opensync/lib/libopensync.so\n 2 > 0xb6bccedc: os_backtrace_dump_manager_restart 0xbc /usr/opensync/lib/libopensync.so\n 3 > 0xb6c6fc34: target_device_restart_managers_helper 0x50 /usr/opensync/lib/libopensync.so\n 4 > 0x1f874: cm2_trigger_restart_managers 0x1c0 /usr/opensync/bin/cm\n 5 > 0x2bdd4: (null) 0 /usr/opensync/bin/cm\n 6 > 0x2bfe4: cm2_connection_req_stability_check 0x8c /usr/opensync/bin/cm\n 7 > 0x20058: cm2_update_state 0x768 /usr/opensync/bin/cm\n 8 > 0xb6996fb4: ev_invoke_pending 0x7c /lib/libev.so.4\n 9 > 0xb6999530: ev_run 0x730 /lib/libev.so.4\n 10 > 0x1828c: main 0x1a8 /usr/opensync/bin/cm\n 11 > 0xb61c38cc: __libc_start_main 0x110 /lib/libc.so.6\n" }

OVSDB

Even though the data (max_memory) is exposed in the ovsdb database, it does not need to be managed by the cloud. The default limits will be provided at build time in Kconfig for each manager. This does not exclude the possibility that these limits could be controlled by the cloud in the future.

Node_Services table

Support for new key/value pairs is introduced in Node_Services.other_config schema.

Name

Type

Description

Name

Type

Description

other_config

key:value

New key/value pair max_memory:

  • Maximum allowed physical memory (pss) usage for give process specified in kB

  • If this field is omitted, the default value of 10,000kB specified in Kconfig (DM_DEFAULT_MAX_MEMORY) will be used.

  • If it is set to value -1, no checks will be performed

other_config

key:value

New key/value pair max_memory_cnt:

  • Maximum number of consecutive times the memory limit can be exceeded.

  • If this field is omitted, the default value of 10 specified in Kconfig (DM_DEFAULT_MAX_MEMORY_CNT) will be used.

Example

root@opensync:~# ovsh s Node_Services -w service==fsm --------------------------------------------------------------------------------------------------- _uuid | 5ed7~0e7c | _version | 2723~d153 | enable | true | other_config | ["map",[["always_restart","true"],["max_memory","160000"],["restart_delay","-1"]]] | service | fsm | status | enabled | ---------------------------------------------------------------------------------------------------

Southbound API

N/A

Memory limits proposal

Proposed memory limits are defined based on the expectation of a safe limit, derived from measurements of memory usage on field devices (OpenSync 6.6) and from measurements on an idle device immediately after establishing a connection.

Process name

Idle memory usage after connection [kB]

Heuristic average memory usage [kB]

Memory limit (proposed) [kB]

Process name

Idle memory usage after connection [kB]

Heuristic average memory usage [kB]

Memory limit (proposed) [kB]

blem

870

2800

10000

cm

1456

5600

20000

fcm

2027

28710

100000

fm

714

624

10000

fsm

26910

32000

160000

nfm

1802

1800

10000

nm

6381

5400

20000

om

780

1800

10000

owm

31040

23400

100000

pm

2741

4000

10000

psm

2055

2300

10000

qm

1773

3000

10000

qosm

886

3000

10000

sm

1492

6000

20000

tpsm

720

N/A

10000

um

751

N/A

100000

vpnm

687

N/A

10000

wano

1194

5500

20000