Darryl L. Pierce
2009-Jan-14 16:47 UTC
[Ovirt-devel] [PATCH node] Changed how max swap size is calculated.
If ovirt_overcommit is present, then it is used as the factor, multiplied by memory on the server, to calculate maximum swap size. So if it is set to 5 then max swap size is 5 x memory. If overt_overcommit is not present, then the default value used is 1.5. The value calculated is then incremented by the values listed at <http://kbase.redhat.com/faq/docs/DOC-15252>. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-storage | 30 +++++++++++++++++++++++++++--- scripts/ovirt-early | 13 ++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index b3d87ae..1eb06f1 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -80,7 +80,7 @@ get_dev_name() done # if we didn't find any devices using HAL, so check for virtual devices - if [ -z $devices ]; then devices=$(ls -l /dev/[shv]d?); fi + if [ -z "$devices" ]; then devices=$(ls -l /dev/[shv]d?); fi # If there's only one device, use it. case $devices in @@ -285,13 +285,37 @@ do_confirm() done } +if [ -z "$OVIRT_OVERCOMMIT" ]; then OVIRT_OVERCOMMIT="1.5"; fi MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal:/ { print $2 }') case $MEM_SIZE in ''|*[^0-9]*) die failed to get system memory size;; esac - -MEM_SIZE=$(echo "scale=0; m=($MEM_SIZE / 1024 * 2); if (m < 2048) { m } else { 2048 }" | bc -l) +MEM_SIZE=$(echo "scale=0; $MEM_SIZE / 1024;" | bc -l) +# we multiply the overcommit coefficient by 10 then divide the +# product by 10 to avoid decimals in the result +MAX_SWAP_SIZE=$(echo "scale=0; (${MEM_SIZE} * (${OVIRT_OVERCOMMIT} * 10))/10;" | bc -l) SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$MEM_SIZE} +if [ $SWAP_SIZE -gt $MAX_SWAP_SIZE ]; then + SWAP_SIZE=$MAX_SWAP_SIZE +fi + +# if the swap size is 0, then set the size using minimum values +# from http://kbase.redhat.com/faq/docs/DOC-15252 +if [ $SWAP_SIZE -eq 0 ]; then + # convert mem size to GB + mgb=$(echo "scale=0; $MEM_SIZE/1024;" | bc -l) + if [ $mgb -le 4 ]; then + SWAP_SIZE=2 + elif [ $mgb -le 16 ]; then + SWAP_SIZE=4 + elif [ $mgb -le 64 ]; then + SWAP_SIZE=8 + else + SWAP_SIZE=16 + fi + + SWAP_SIZE=$(echo "scale=0; ${SWAP_SIZE} * 1024;" | bc -l) +fi BOOT_SIZE=${OVIRT_VOL_BOOT_SIZE:-$default_boot_size} ROOT_SIZE=${OVIRT_VOL_ROOT_SIZE:-$default_root_size} diff --git a/scripts/ovirt-early b/scripts/ovirt-early index 153c0c7..262acb6 100755 --- a/scripts/ovirt-early +++ b/scripts/ovirt-early @@ -117,6 +117,7 @@ start() { # BOOTIF=link|eth*|<MAC> (appended by pxelinux) # ovirt_init=usb|scsi[:serial#] # ovirt_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB + # ovirt_overcommit # ovirt_local_boot # ovirt_standalone # pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask> @@ -156,6 +157,10 @@ start() { # install/update oVirt Node image on the local installation target disk local_boot=0 + # ovirt_overcommit + # set the swap size coefficient + overcommit=1.5 + # ovirt_standalone # force oVirt Node standalone mode standalone=0 @@ -245,6 +250,12 @@ start() { standalone=1 bootparams="$bootparams $i" ;; + + ovirt_overcommit*) + i=${i#ovirt_overcommit=} + eval $(printf $i|awk -F: '{print "overcommit="$1;}') + ;; + ip=*) i=${i#ip=} eval $(printf $i|awk -F: '{print "ip_address="$1; print "ip_gateway="$3; print "ip_netmask="$4}') @@ -278,7 +289,7 @@ start() { ip_gateway=$gateway fi # save boot parameters as defaults for ovirt-config-* - params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" + params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" mount_config if [ -e $OVIRT_DEFAULTS ]; then echo "update ovirt defaults" -- 1.6.0.6
Darryl L. Pierce
2009-Jan-14 19:08 UTC
[Ovirt-devel] [PATCH node] Changed how max swap size is calculated.
NOTE: this patch fixes where the additional memory wasn't being added when overcommit was NOT set to 0. If ovirt_overcommit is present, then it is used as the factor, multiplied by memory on the server, to calculate maximum swap size. So if it is set to 5 then max swap size is 5 x memory. If overt_overcommit is not present, then the default value used is 1.5. The value calculated is then incremented by the values listed at <http://kbase.redhat.com/faq/docs/DOC-15252>. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-storage | 27 ++++++++++++++++++++++++--- scripts/ovirt-early | 13 ++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index b3d87ae..4d50fdc 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -80,7 +80,7 @@ get_dev_name() done # if we didn't find any devices using HAL, so check for virtual devices - if [ -z $devices ]; then devices=$(ls -l /dev/[shv]d?); fi + if [ -z "$devices" ]; then devices=$(ls -l /dev/[shv]d?); fi # If there's only one device, use it. case $devices in @@ -285,13 +285,34 @@ do_confirm() done } +if [ -z "$OVIRT_OVERCOMMIT" ]; then OVIRT_OVERCOMMIT="1.5"; fi MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal:/ { print $2 }') case $MEM_SIZE in ''|*[^0-9]*) die failed to get system memory size;; esac - -MEM_SIZE=$(echo "scale=0; m=($MEM_SIZE / 1024 * 2); if (m < 2048) { m } else { 2048 }" | bc -l) +MEM_SIZE=$(echo "scale=0; $MEM_SIZE / 1024;" | bc -l) +# we multiply the overcommit coefficient by 10 then divide the +# product by 10 to avoid decimals in the result +MAX_SWAP_SIZE=$(echo "scale=0; (${MEM_SIZE} * (${OVIRT_OVERCOMMIT} * 10))/10;" | bc -l) SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$MEM_SIZE} +if [ $SWAP_SIZE -gt $MAX_SWAP_SIZE ]; then + SWAP_SIZE=$MAX_SWAP_SIZE +fi + +# add to the swap the amounts from http://kbase.redhat.com/faq/docs/DOC-15252 +# convert mem size to GB +mgb=$(echo "scale=0; $MEM_SIZE/1024;" | bc -l) +if [ $mgb -le 4 ]; then + SWAP_SIZE=2 +elif [ $mgb -le 16 ]; then + SWAP_SIZE=4 +elif [ $mgb -le 64 ]; then + SWAP_SIZE=8 +else + SWAP_SIZE=16 +fi + +SWAP_SIZE=$(echo "scale=0; ${SWAP_SIZE} * 1024;" | bc -l) BOOT_SIZE=${OVIRT_VOL_BOOT_SIZE:-$default_boot_size} ROOT_SIZE=${OVIRT_VOL_ROOT_SIZE:-$default_root_size} diff --git a/scripts/ovirt-early b/scripts/ovirt-early index 153c0c7..262acb6 100755 --- a/scripts/ovirt-early +++ b/scripts/ovirt-early @@ -117,6 +117,7 @@ start() { # BOOTIF=link|eth*|<MAC> (appended by pxelinux) # ovirt_init=usb|scsi[:serial#] # ovirt_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB + # ovirt_overcommit # ovirt_local_boot # ovirt_standalone # pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask> @@ -156,6 +157,10 @@ start() { # install/update oVirt Node image on the local installation target disk local_boot=0 + # ovirt_overcommit + # set the swap size coefficient + overcommit=1.5 + # ovirt_standalone # force oVirt Node standalone mode standalone=0 @@ -245,6 +250,12 @@ start() { standalone=1 bootparams="$bootparams $i" ;; + + ovirt_overcommit*) + i=${i#ovirt_overcommit=} + eval $(printf $i|awk -F: '{print "overcommit="$1;}') + ;; + ip=*) i=${i#ip=} eval $(printf $i|awk -F: '{print "ip_address="$1; print "ip_gateway="$3; print "ip_netmask="$4}') @@ -278,7 +289,7 @@ start() { ip_gateway=$gateway fi # save boot parameters as defaults for ovirt-config-* - params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" + params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" mount_config if [ -e $OVIRT_DEFAULTS ]; then echo "update ovirt defaults" -- 1.6.0.6
Darryl L. Pierce
2009-Jan-14 21:37 UTC
[Ovirt-devel] [PATCH node] Changed how max swap size is calculated.
Swap partition size is based on a calculated value added to a base value defined in <http://kbase.redhat.com/faq/docs/DOC-15252>. The calculated value is an overcommit value multiplied by the amount of memory on the device. If no overcommit value is specified then the default is 0.5. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-storage | 30 +++++++++++++++++++++++++----- scripts/ovirt-early | 13 ++++++++++++- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index b3d87ae..7448452 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -80,7 +80,7 @@ get_dev_name() done # if we didn't find any devices using HAL, so check for virtual devices - if [ -z $devices ]; then devices=$(ls -l /dev/[shv]d?); fi + if [ -z "$devices" ]; then devices=$(ls -l /dev/[shv]d?); fi # If there's only one device, use it. case $devices in @@ -285,14 +285,34 @@ do_confirm() done } +if [ -z "$OVIRT_OVERCOMMIT" ]; then OVIRT_OVERCOMMIT="1.5"; fi MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal:/ { print $2 }') case $MEM_SIZE in ''|*[^0-9]*) die failed to get system memory size;; esac +MEM_SIZE=$(echo "scale=0; $MEM_SIZE / 1024;" | bc -l) +# we multiply the overcommit coefficient by 10 then divide the +# product by 10 to avoid decimals in the result +OVERCOMMIT_SWAP_SIZE=$(echo "scale=0; (${MEM_SIZE} * (${OVIRT_OVERCOMMIT} * 10))/10;" | bc -l) + +# add to the swap the amounts from http://kbase.redhat.com/faq/docs/DOC-15252 +mgb=$(echo "scale=0; $MEM_SIZE/1024;" | bc -l) +if [ $mgb -le 4 ]; then + BASE_SWAP_SIZE=2 +elif [ $mgb -le 16 ]; then + BASE_SWAP_SIZE=4 +elif [ $mgb -le 64 ]; then + BASE_SWAP_SIZE=8 +else + BASE_SWAP_SIZE=16 +fi -MEM_SIZE=$(echo "scale=0; m=($MEM_SIZE / 1024 * 2); if (m < 2048) { m } else { 2048 }" | bc -l) -SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$MEM_SIZE} +MAX_SWAP_SIZE=$(echo "scale=0; (${BASE_SWAP_SIZE} + ${OVERCOMMIT_SWAP_SIZE}) * 1024;" | bc -l) +SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$MAX_SWAP_SIZE} +if [ $SWAP_SIZE -gt $MAX_SWAP_SIZE ]; then + SWAP_SIZE=$MAX_SWAP_SIZE +fi BOOT_SIZE=${OVIRT_VOL_BOOT_SIZE:-$default_boot_size} ROOT_SIZE=${OVIRT_VOL_ROOT_SIZE:-$default_root_size} CONFIG_SIZE=${OVIRT_VOL_CONFIG_SIZE:-$default_config_size} diff --git a/scripts/ovirt-early b/scripts/ovirt-early index 153c0c7..95cf609 100755 --- a/scripts/ovirt-early +++ b/scripts/ovirt-early @@ -117,6 +117,7 @@ start() { # BOOTIF=link|eth*|<MAC> (appended by pxelinux) # ovirt_init=usb|scsi[:serial#] # ovirt_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB + # ovirt_overcommit # ovirt_local_boot # ovirt_standalone # pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask> @@ -156,6 +157,10 @@ start() { # install/update oVirt Node image on the local installation target disk local_boot=0 + # ovirt_overcommit + # set the swap size coefficient + overcommit=0.5 + # ovirt_standalone # force oVirt Node standalone mode standalone=0 @@ -245,6 +250,12 @@ start() { standalone=1 bootparams="$bootparams $i" ;; + + ovirt_overcommit*) + i=${i#ovirt_overcommit=} + eval $(printf $i|awk -F: '{print "overcommit="$1;}') + ;; + ip=*) i=${i#ip=} eval $(printf $i|awk -F: '{print "ip_address="$1; print "ip_gateway="$3; print "ip_netmask="$4}') @@ -278,7 +289,7 @@ start() { ip_gateway=$gateway fi # save boot parameters as defaults for ovirt-config-* - params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" + params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" mount_config if [ -e $OVIRT_DEFAULTS ]; then echo "update ovirt defaults" -- 1.6.0.6
Darryl L. Pierce
2009-Jan-14 21:56 UTC
[Ovirt-devel] [PATCH node] Changed how max swap size is calculated.
NOTE: this version removes the upper limit on swap size and only uses the calculated value if no size was specified. Swap partition size is based on a calculated value added to a base value defined in <http://kbase.redhat.com/faq/docs/DOC-15252>. The calculated value is an overcommit value multiplied by the amount of memory on the device. If no overcommit value is specified then the default is 0.5. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-storage | 24 ++++++++++++++++++++---- scripts/ovirt-early | 13 ++++++++++++- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index c7538a5..8e7cc14 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -289,10 +289,26 @@ MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal:/ { print $2 }') case $MEM_SIZE in ''|*[^0-9]*) die failed to get system memory size;; esac +MEM_SIZE=$(echo "scale=0; $MEM_SIZE / 1024;" | bc -l) +# we multiply the overcommit coefficient by 10 then divide the +# product by 10 to avoid decimals in the result +OVERCOMMIT_SWAP_SIZE=$(echo "scale=0; (${MEM_SIZE} * (${OVIRT_OVERCOMMIT} * 10))/10;" | bc -l) + +# add to the swap the amounts from http://kbase.redhat.com/faq/docs/DOC-15252 +mgb=$(echo "scale=0; $MEM_SIZE/1024;" | bc -l) +if [ $mgb -le 4 ]; then + BASE_SWAP_SIZE=2 +elif [ $mgb -le 16 ]; then + BASE_SWAP_SIZE=4 +elif [ $mgb -le 64 ]; then + BASE_SWAP_SIZE=8 +else + BASE_SWAP_SIZE=16 +fi -MEM_SIZE=$(echo "scale=0; m=($MEM_SIZE / 1024 * 2); if (m < 2048) { m } else { 2048 }" | bc -l) -SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$MEM_SIZE} +CALC_SWAP_SIZE=$(echo "scale=0; (${BASE_SWAP_SIZE} + ${OVERCOMMIT_SWAP_SIZE}) * 1024;" | bc -l) +SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$CALC_SWAP_SIZE} BOOT_SIZE=${OVIRT_VOL_BOOT_SIZE:-$default_boot_size} ROOT_SIZE=${OVIRT_VOL_ROOT_SIZE:-$default_root_size} CONFIG_SIZE=${OVIRT_VOL_CONFIG_SIZE:-$default_config_size} diff --git a/scripts/ovirt-early b/scripts/ovirt-early index 153c0c7..95cf609 100755 --- a/scripts/ovirt-early +++ b/scripts/ovirt-early @@ -117,6 +117,7 @@ start() { # BOOTIF=link|eth*|<MAC> (appended by pxelinux) # ovirt_init=usb|scsi[:serial#] # ovirt_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB + # ovirt_overcommit # ovirt_local_boot # ovirt_standalone # pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask> @@ -156,6 +157,10 @@ start() { # install/update oVirt Node image on the local installation target disk local_boot=0 + # ovirt_overcommit + # set the swap size coefficient + overcommit=0.5 + # ovirt_standalone # force oVirt Node standalone mode standalone=0 @@ -245,6 +250,12 @@ start() { standalone=1 bootparams="$bootparams $i" ;; + + ovirt_overcommit*) + i=${i#ovirt_overcommit=} + eval $(printf $i|awk -F: '{print "overcommit="$1;}') + ;; + ip=*) i=${i#ip=} eval $(printf $i|awk -F: '{print "ip_address="$1; print "ip_gateway="$3; print "ip_netmask="$4}') @@ -278,7 +289,7 @@ start() { ip_gateway=$gateway fi # save boot parameters as defaults for ovirt-config-* - params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" + params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname" mount_config if [ -e $OVIRT_DEFAULTS ]; then echo "update ovirt defaults" -- 1.6.0.6