-
Notifications
You must be signed in to change notification settings - Fork 7
RDKB-64189: Enable ZRAM to optimize and reduce RDKB memory usage #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
260aa6e
Update ZRAM init script for current RDK-B requirements
manedurphy 4b612b4
Create separate ZRAM init script for Broadband devices
manedurphy b022cf5
Add empty checks for MEMSWAP configuration returns from the data model
manedurphy 6baebea
Use system default when queries for RFC fail
manedurphy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #################################################################################### | ||
| # If not stated otherwise in this file or this component's Licenses.txt file the | ||
| # following copyright and licenses apply: | ||
| # | ||
| # Copyright 2018 RDK Management | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ################################################################################## | ||
| . /etc/include.properties | ||
| . /etc/device.properties | ||
|
|
||
| ZRAM_LOGFILE="${LOG_PATH}/zram.log" | ||
|
|
||
| echo_t() { | ||
| echo "$(date +"%y%m%d-%T.%6N") $1" >>$ZRAM_LOGFILE | ||
| } | ||
|
|
||
| # Wait for the DM system to come up | ||
| dmIsUp=1 | ||
| while [ "x$dmIsUp" != "x0" ]; do | ||
| dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MEMSWAP.Enable | grep value | ||
| dmIsUp=$? | ||
| sleep 10 | ||
| done | ||
|
|
||
|
manedurphy marked this conversation as resolved.
|
||
| # Check if MEMSWAP is enabled by RFC, exit if not enabled | ||
| MEMSWAP_RFC_ENABLE=$(dmcli eRT retv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MEMSWAP.Enable) | ||
|
manedurphy marked this conversation as resolved.
|
||
| if [ "x$MEMSWAP_RFC_ENABLE" != "xtrue" ]; then | ||
| echo_t "MEMSWAP is disabled" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Load ZRAM module with one block device for SWAP | ||
| if modinfo zram | grep -q ' zram_num_devices:' 2>/dev/null; then | ||
| MODPROBE_ARGS="zram_num_devices=1" | ||
| elif modinfo zram | grep -q ' num_devices:' 2>/dev/null; then | ||
|
manedurphy marked this conversation as resolved.
|
||
| MODPROBE_ARGS="num_devices=1" | ||
| else | ||
| exit 1 | ||
| fi | ||
| modprobe zram "$MODPROBE_ARGS" | ||
|
manedurphy marked this conversation as resolved.
|
||
|
|
||
| # Wait for the module to load | ||
| sleep 3 | ||
|
|
||
| # Configure the disk size | ||
| MEMSWAP_DISK_SIZE=$(dmcli eRT retv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MEMSWAP.DiskSize) | ||
| if [ -z "$MEMSWAP_DISK_SIZE" ]; then | ||
| echo_t "MEMSWAP disk size not retrieved from RFC, setting to default of 300MB" | ||
|
manedurphy marked this conversation as resolved.
|
||
| MEMSWAP_DISK_SIZE=300 | ||
| fi | ||
| echo "${MEMSWAP_DISK_SIZE}M" >/sys/block/zram0/disksize | ||
| echo_t "MEMSWAP disk size set to ${MEMSWAP_DISK_SIZE}M" | ||
|
|
||
| # Configure the system swappiness | ||
| MEMSWAP_TUNABLES_SWAPPINESS=$(dmcli eRT retv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MEMSWAP.Tunables.Swappiness) | ||
|
manedurphy marked this conversation as resolved.
|
||
| if [ -z "$MEMSWAP_TUNABLES_SWAPPINESS" ]; then | ||
| echo_t "MEMSWAP swappiness not retrieved from RFC, keeping system default" | ||
| else | ||
| sysctl -w vm.swappiness="$MEMSWAP_TUNABLES_SWAPPINESS" | ||
| echo_t "System swappiness set to ${MEMSWAP_TUNABLES_SWAPPINESS}" | ||
|
manedurphy marked this conversation as resolved.
|
||
| fi | ||
|
|
||
| # Configure the system watermark scale factor | ||
| MEMSWAP_TUNABLES_WATERMARK_SCALE_FACTOR=$(dmcli eRT retv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MEMSWAP.Tunables.WatermarkScaleFactor) | ||
| if [ -z "$MEMSWAP_TUNABLES_WATERMARK_SCALE_FACTOR" ]; then | ||
| echo_t "MEMSWAP watermark scale factor not retrieved from RFC, keeping system default" | ||
| else | ||
| sysctl -w vm.watermark_scale_factor="$MEMSWAP_TUNABLES_WATERMARK_SCALE_FACTOR" | ||
| echo_t "System watermark scale factor set to ${MEMSWAP_TUNABLES_WATERMARK_SCALE_FACTOR}" | ||
|
manedurphy marked this conversation as resolved.
|
||
| fi | ||
|
|
||
| # Configure the system page cluster for SWAP | ||
| MEMSWAP_TUNABLES_PAGE_CLUSTER=$(dmcli eRT retv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MEMSWAP.Tunables.PageCluster) | ||
| if [ -z "$MEMSWAP_TUNABLES_PAGE_CLUSTER" ]; then | ||
| echo_t "MEMSWAP page cluster not retrieved from RFC, keeping system default" | ||
| else | ||
| sysctl -w vm.page-cluster="$MEMSWAP_TUNABLES_PAGE_CLUSTER" | ||
| echo_t "System page cluster for SWAP set to ${MEMSWAP_TUNABLES_PAGE_CLUSTER}" | ||
|
manedurphy marked this conversation as resolved.
|
||
| fi | ||
|
|
||
| # Enable the ZRAM SWAP device | ||
| mkswap /dev/zram0 | ||
| swapon -p 5 /dev/zram0 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.