Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 1e89f7e

Browse files
author
James O. D. Hunt
authored
Merge pull request #225 from Pennyzct/memory-hotplug
memory_hotplug: MEM_BOUNDARY_MB should be arch-dependent
2 parents 53215ac + e4d5c1b commit 1e89f7e

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

image-builder/image_builder.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ MAX_IMG_SIZE_MB=2048
5050

5151
FS_TYPE=${FS_TYPE:-"ext4"}
5252

53-
# In order to support memory hotplug, image must be aligned to 128M
54-
MEM_BOUNDARY=128
53+
# In order to support memory hotplug, image must be aligned to memory section(size in MB) according to different architecture.
54+
ARCH=$(arch)
55+
case "$ARCH" in
56+
aarch64) MEM_BOUNDARY_MB=1024 ;;
57+
*) MEM_BOUNDARY_MB=128 ;;
58+
esac
5559

5660
# Maximum no of attempts to create a root disk before giving up
5761
MAX_ATTEMPTS=5
@@ -139,20 +143,21 @@ OK "Agent installed"
139143
ROOTFS_SIZE=$(du -B 1MB -s "${ROOTFS}" | awk '{print $1}')
140144
BLOCK_SIZE=${BLOCK_SIZE:-4096}
141145
OLD_IMG_SIZE=0
146+
ORIG_MEM_BOUNDARY_MB=${MEM_BOUNDARY_MB}
142147

143148
align_memory()
144149
{
145-
remaining=$(($IMG_SIZE % $MEM_BOUNDARY))
150+
remaining=$(($IMG_SIZE % $MEM_BOUNDARY_MB))
146151
if [ "$remaining" != "0" ];then
147-
warning "image size '$IMG_SIZE' is not aligned to memory boundary '$MEM_BOUNDARY', aligning it"
148-
IMG_SIZE=$(($IMG_SIZE + $MEM_BOUNDARY - $remaining))
152+
warning "image size '$IMG_SIZE' is not aligned to memory boundary '$MEM_BOUNDARY_MB', aligning it"
153+
IMG_SIZE=$(($IMG_SIZE + $MEM_BOUNDARY_MB - $remaining))
149154
fi
150155
}
151156

152157
# Calculate image size based on the rootfs
153158
calculate_img_size()
154159
{
155-
IMG_SIZE=${IMG_SIZE:-$MEM_BOUNDARY}
160+
IMG_SIZE=${IMG_SIZE:-$MEM_BOUNDARY_MB}
156161
align_memory
157162
if [ -n "$ROOT_FREE_SPACE" ] && [ "$IMG_SIZE" -gt "$ROOTFS_SIZE" ]; then
158163
info "Ensure that root partition has at least ${ROOT_FREE_SPACE}MB of free space"
@@ -258,8 +263,8 @@ create_rootfs_disk()
258263
# if the available disk space is less than rootfs size, repeat the process
259264
# of disk creation by adding 5% in the inital assumed value $ROOTFS_SIZE
260265
if [ $ROOTFS_SIZE -gt $AVAIL_DISK ]; then
261-
# Increase the size but remain aligned to 128
262-
MEM_BOUNDARY=$(($MEM_BOUNDARY+128))
266+
# Increase the size but remain aligned to the original MEM_BOUNDARY_MB, which is stored in $ORIG_MEM_BOUNDARY_MB
267+
MEM_BOUNDARY_MB=$(($MEM_BOUNDARY_MB+$ORIG_MEM_BOUNDARY_MB))
263268
OLD_IMG_SIZE=${IMG_SIZE}
264269
unset IMG_SIZE
265270
unmount

0 commit comments

Comments
 (0)