This script includes steps for disabling THP and separately disabling THP defrag. In fact, when THP is disabled, separately disabling THP defrag is not necessary. While the extra step in not harmful, it is inconsistent with this article from RH, leading to potential confusion:
NOTE: Some third party application install scripts check value of above files and complain even if THP is disabled at boot time using transparent_hugepage=never, this is due to the fact when THP is disabled at boot time, the value of /sys/kernel/mm/redhat_transparent_hugepage/defrag will not be changed, however this is expected and system will never go in THP defragmentation code path when it is disabled at boot and THP defrag need not to be disabled separately.
The extra step of disabling THP defrag should either be removed or qualified as not necessary.
Note that leaving out the separate step of disabling defrag would also be consistent with `mongod`, whose startup warnings check for defrag only if it detects that THP is enabled. See https://github.com/mongodb/mongo/blob/1041dd848e25e879260d1015d8da4f72ee7993fe/src/mongo/db/startup_warnings_mongod.cpp#L261
- Make change and backport as necessary
- Evaluate 9 other THP tickets and include fixes as appropriate. Note that some tickets request competing adjustments: determine which settings are required in modern deployments.
- The following DOCS tickets are related to this ticket [and have been actioned upon]:
DOCS-9197- Replace shell redirection with tee to work on Amazon Linux [fixed, this ticket] DOCS-9772- MDB 3.0 init script does not address khugepage/defrag [won't fix, superseded by this ticket] DOCS-9949- tuned profile config doesn't disable defrag [won't fix, superseded by this ticket] DOCS-10088- Expand THP instructions to other, non-RHEL/CentOS distros [fixed, this ticket] DOCS-10693- Add /etc/default custom settings to handle THP on Debian/Ubuntu systems [won't fix] DOCS-11334- Update tuned to remove defrag setting also [won't fix, superseded by this ticket] DOCS-12501- Add step to THP doc to start disable-transparent-hugepages service before reboot [fixed, this ticket] DOCS-12836- THP disable instructions should use systemd not init.d [deferred to be included in DOCS-13042] DOCS-12903- Clarify rationale for disabling THP in both init.d and tuned [fixed, this ticket]