[PATCH] Change swap suggestions to the chart proposed in the discussion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There was quite a long discussion [1] about swap size suggestions and
this algorithm is the result. Moreover we should use 'swap --hibernation'
instead of 'swap --same-as-ram'.

[1] https://home.corp.redhat.com/wiki/swap-size-recommendations

Resolves: rhbz#744129
Resolves: rhbz#815557
---
 installclass.py |    2 +-
 iutil.py        |   43 +++++++++++++++++++------------------------
 kickstart.py    |    4 ++--
 3 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/installclass.py b/installclass.py
index 9514097..a417762 100644
--- a/installclass.py
+++ b/installclass.py
@@ -191,7 +191,7 @@ class BaseInstallClass(object):
         if bootreq:
             autorequests.extend(bootreq)
 
-        (minswap, maxswap) = iutil.swapSameAsRam()
+        (minswap, maxswap) = iutil.swapSuggestion()
         autorequests.append(PartSpec(fstype="swap", size=minswap, maxSize=maxswap,
                                      grow=True, asVol=True))
 
diff --git a/iutil.py b/iutil.py
index f7254e2..d14117c 100644
--- a/iutil.py
+++ b/iutil.py
@@ -452,47 +452,42 @@ def swapSuggestion(quiet=0):
     mem = ((mem/16)+1)*16
     if not quiet:
 	log.info("Detected %sM of memory", mem)
-	
-    #table suggested in rhbz#744129
-    if mem <= 4096:
-        minswap = 2048
-        maxswap = 2048
 
-    elif 4096 < mem <= 16384:
-        minswap = 4096
-        maxswap = 4096
+    #chart suggested in the discussion with other teams
+    #see: https://home.corp.redhat.com/wiki/swap-size-recommendations
+    if mem < 2048:
+        minswap = 2 * mem
+        maxswap = 2 * mem
 
-    elif 16384 < mem <= 65536:
-        minswap = 8192
-        maxswap = 8192
+    elif 2048 <= mem < 8192:
+        minswap = mem
+        maxswap = mem
 
-    elif 65536 < mem <= 262144:
-        minswap = 16384
-        maxswap = 16384
+    elif 8192 <= mem < 65536:
+        minswap = mem / 2
+        maxswap = mem / 2
 
     else:
-        minswap = 32768
-        maxswap = 32768
+        minswap = 4096
+        maxswap = 4096
 
     if not quiet:
 	log.info("Swap attempt of %sM to %sM", minswap, maxswap)
 
     return (minswap, maxswap)
 
-def swapSameAsRam(quiet=0):
+def swapHibernation(quiet=0):
     mem = memInstalled() / 1024
     mem = ((mem / 16) + 1) * 16
     if not quiet:
         log.info("Detected %sM of memory", mem)
 
-    #see #rhbz587152
-    if mem <= SWAP_SIZE_LIMIT:
-        log.info("Swap attempt of %sM to %sM", mem, mem)
-        return (mem, mem)
+    if mem <= 65536:
+        swap = mem + swapSuggestion
     else:
-        log.warning("Cannot create swap of size %sM, using upper bound %sM",
-                    mem, SWAP_SIZE_LIMIT)
-        return (SWAP_SIZE_LIMIT, SWAP_SIZE_LIMIT)
+        swap = 0
+
+    return (swap, swap)
 
 ## Create a directory path.  Don't fail if the directory already exists.
 # @param dir The directory path to create.
diff --git a/kickstart.py b/kickstart.py
index c28f030..03ab235 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -743,8 +743,8 @@ class PartitionData(commands.partition.RHEL6_PartData):
                 (self.size, self.maxSizeMB) = iutil.swapSuggestion()
                 self.grow = True
 
-            if self.sameAsRam:
-                (self.size, self.maxSizeMB) = iutil.swapSameAsRam()
+            if self.hibernation:
+                (self.size, self.maxSizeMB) = iutil.swapHibernation()
                 self.grow = False
         # if people want to specify no mountpoint for some reason, let them
         # this is really needed for pSeries boot partitions :(
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux