[PATCHv3] 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        |   48 +++++++++++++++---------------------------------
 kickstart.py    |    7 ++-----
 3 files changed, 18 insertions(+), 39 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..c583fe2 100644
--- a/iutil.py
+++ b/iutil.py
@@ -447,52 +447,34 @@ def memInstalled():
 ## Suggest the size of the swap partition that will be created.
 # @param quiet Should size information be logged?
 # @return A tuple of the minimum and maximum swap size, in megabytes.
-def swapSuggestion(quiet=0):
+def swapSuggestion(quiet=0, hibernation=False):
     mem = memInstalled()/1024
     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:
+        swap = 2 * mem
 
-    elif 16384 < mem <= 65536:
-        minswap = 8192
-        maxswap = 8192
+    elif 2048 <= mem < 8192:
+        swap = mem
 
-    elif 65536 < mem <= 262144:
-        minswap = 16384
-        maxswap = 16384
+    elif 8192 <= mem < 65536:
+        swap = mem / 2
 
     else:
-        minswap = 32768
-        maxswap = 32768
+        swap = 4096
 
     if not quiet:
-	log.info("Swap attempt of %sM to %sM", minswap, maxswap)
+	log.info("Swap attempt of %sM", swap)
 
-    return (minswap, maxswap)
+    if hibernation and mem <= 65536:
+        swap = mem + swap
 
-def swapSameAsRam(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)
-    else:
-        log.warning("Cannot create swap of size %sM, using upper bound %sM",
-                    mem, SWAP_SIZE_LIMIT)
-        return (SWAP_SIZE_LIMIT, SWAP_SIZE_LIMIT)
+    #we have to return minimum and maximum swap size
+    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..198982a 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -739,13 +739,10 @@ class PartitionData(commands.partition.RHEL6_PartData):
         if self.mountpoint == "swap":
             type = "swap"
             self.mountpoint = ""
-            if self.recommended:
-                (self.size, self.maxSizeMB) = iutil.swapSuggestion()
+            if self.recommended or self.hibernation:
+                (self.size, self.maxSizeMB) = iutil.swapSuggestion(self.hibernation)
                 self.grow = True
 
-            if self.sameAsRam:
-                (self.size, self.maxSizeMB) = iutil.swapSameAsRam()
-                self.grow = False
         # if people want to specify no mountpoint for some reason, let them
         # this is really needed for pSeries boot partitions :(
         elif self.mountpoint == "None":
-- 
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