Commit ba5ed39
committed
Reduce memory churn in netlink_handler
auditd allocates a new struct auditd_event each time the netlink handler
(netlink_handler) reads a record. The handler keeps a single pointer
(cur_event) to the currently processed record. When the optional
configuration worker finishes, it sends the event back via reconfig_ev
and the pipe handler frees it. Thus only one event structure is normally
active in the netlink handler. A second structure exists only temporarily
during reconfiguration (held in reconfig_ev). Once an event is processed,
distribute_event() copies it into a new event_t structure for the dispatcher
queue. The dispatcher queue (audisp/queue.c) can hold up to the configured
depth (default 2000). Each queued entry is freed after all plugins process
it. The dispatch thread later frees the record.
Only one (occasionally two) auditd_event objects exist at any given time.
Preallocating a small static instance (or a pool of two) would remove nearly
all per‑event allocations without additional complexity.1 parent 871b8a4 commit ba5ed39
2 files changed
+43
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| |||
580 | 585 | | |
581 | 586 | | |
582 | 587 | | |
583 | | - | |
| 588 | + | |
| 589 | + | |
584 | 590 | | |
585 | 591 | | |
586 | 592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
| |||
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
98 | 107 | | |
99 | 108 | | |
100 | 109 | | |
| |||
536 | 545 | | |
537 | 546 | | |
538 | 547 | | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
539 | 572 | | |
540 | 573 | | |
541 | 574 | | |
| |||
546 | 579 | | |
547 | 580 | | |
548 | 581 | | |
549 | | - | |
| 582 | + | |
| 583 | + | |
550 | 584 | | |
551 | 585 | | |
552 | 586 | | |
| |||
1079 | 1113 | | |
1080 | 1114 | | |
1081 | 1115 | | |
1082 | | - | |
| 1116 | + | |
1083 | 1117 | | |
1084 | | - | |
1085 | 1118 | | |
1086 | 1119 | | |
1087 | 1120 | | |
| |||
0 commit comments