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

Re: [master] improve the memory checking so it reflects better the hungry architectures.



Ack.

--
Martin Sivák
msivak redhat com
Red Hat Czech
Anaconda team / Brno, CZ

----- "Ales Kozumplik" <akozumpl redhat com> wrote:

> 1) in isys.h differentiate betweet powerpc64 and sparc and everything
> else. powerpc is extremely hungry.
> 
> 2) decrease the limits for the remaining architectures--I have i686
> and
> x86_64 particularly in mind there
> 
> 3) change the way the total memory is guessed. the previous method
> just
> assumed kernel binary image is around 16 MB. This can be completely
> off
> for the hungry archs.
> ---
>  anaconda            |   14 +++++---------
>  isys/isys.c         |    1 +
>  isys/isys.h         |   14 ++++++++++----
>  isys/isys.py        |    1 +
>  iutil.py            |   11 +++++++++++
>  loader/loadermisc.c |    7 +++++++
>  6 files changed, 35 insertions(+), 13 deletions(-)
> 
> diff --git a/anaconda b/anaconda
> index b5532b0..45e2fc1 100755
> --- a/anaconda
> +++ b/anaconda
> @@ -349,12 +349,6 @@ def runVNC():
>                      sys.stdin.readline()
>                      iutil.execConsole()
>  
> -def within_available_memory(needed_ram):
> -    # kernel binary code estimate that is
> -    # not reported in MemTotal by /proc/meminfo:
> -    epsilon = 15360 # 15 MB
> -    return needed_ram < (iutil.memInstalled() + epsilon)
> -
>  def check_memory(anaconda, opts, display_mode=None):
>  
>      if not display_mode:
> @@ -366,8 +360,10 @@ def check_memory(anaconda, opts,
> display_mode=None):
>          extra_ram += isys.URL_INSTALL_EXTRA_RAM
>          reason = " using this install method"
>  
> +    total_ram = iutil.total_memory()
> +
>      needed_ram = isys.MIN_RAM + extra_ram
> -    if not within_available_memory(needed_ram):
> +    if needed_ram > total_ram:
>          from snack import SnackScreen, ButtonChoiceWindow
>          screen = SnackScreen()
>          ButtonChoiceWindow(screen, _('Fatal Error'),
> @@ -382,9 +378,9 @@ def check_memory(anaconda, opts,
> display_mode=None):
>  
>      # override display mode if machine cannot nicely run X
>      if display_mode not in ('t', 'c') and not flags.usevnc:
> -        needed_ram = isys.MIN_GUI_RAM + extra_ram
> +        needed_ram += isys.GUI_INSTALL_EXTRA_RAM
>  
> -        if not within_available_memory(needed_ram):
> +        if needed_ram > total_ram:
>              complain = _("You do not have enough RAM to use the
> graphical "
>                           "installer.")
>              if flags.livecdInstall:
> diff --git a/isys/isys.c b/isys/isys.c
> index 409170b..ca3fb0d 100644
> --- a/isys/isys.c
> +++ b/isys/isys.c
> @@ -313,6 +313,7 @@ void init_isys(void) {
>  
>      PyDict_SetItemString(d, "MIN_RAM", PyInt_FromLong(MIN_RAM));
>      PyDict_SetItemString(d, "MIN_GUI_RAM",
> PyInt_FromLong(MIN_GUI_RAM));
> +    PyDict_SetItemString(d, "GUI_INSTALL_EXTRA_RAM",
> PyInt_FromLong(GUI_INSTALL_EXTRA_RAM));
>      PyDict_SetItemString(d, "URL_INSTALL_EXTRA_RAM",
> PyInt_FromLong(URL_INSTALL_EXTRA_RAM));
>      PyDict_SetItemString(d, "EARLY_SWAP_RAM",
> PyInt_FromLong(EARLY_SWAP_RAM));
>  }
> diff --git a/isys/isys.h b/isys/isys.h
> index e3cb1fc..659e3d6 100644
> --- a/isys/isys.h
> +++ b/isys/isys.h
> @@ -20,10 +20,16 @@
>  #ifndef H_ISYS
>  #define H_ISYS
>  
> -#define MIN_RAM			262144 // 256 MB
> -#define MIN_GUI_RAM		524288 // 512 MB
> -#define URL_INSTALL_EXTRA_RAM   131072 // 128 MB
> -#define EARLY_SWAP_RAM		524288
> +#if defined(__powerpc64__) || defined(__sparc__)
> +  #define MIN_RAM                 1024*1024 // 1 GB
> +  #define GUI_INSTALL_EXTRA_RAM   512*1024  // 512 MB
> +#else
> +  #define MIN_RAM                 256 * 1024 // 256 MB
> +  #define GUI_INSTALL_EXTRA_RAM   128 * 1024 // 128 MB
> +#endif
> +#define URL_INSTALL_EXTRA_RAM   128 * 1024 // 128 MB
> +#define MIN_GUI_RAM             MIN_RAM + GUI_INSTALL_EXTRA_RAM
> +#define EARLY_SWAP_RAM          512 * 1024 // 512 MB
>  
>  #define OUTPUT_TERMINAL "/dev/tty5"
>  
> diff --git a/isys/isys.py b/isys/isys.py
> index 62010ff..cddb916 100755
> --- a/isys/isys.py
> +++ b/isys/isys.py
> @@ -62,6 +62,7 @@ mountCount = {}
>  
>  MIN_RAM = _isys.MIN_RAM
>  MIN_GUI_RAM = _isys.MIN_GUI_RAM
> +GUI_INSTALL_EXTRA_RAM = _isys.GUI_INSTALL_EXTRA_RAM
>  URL_INSTALL_EXTRA_RAM = _isys.URL_INSTALL_EXTRA_RAM
>  EARLY_SWAP_RAM = _isys.EARLY_SWAP_RAM
>  
> diff --git a/iutil.py b/iutil.py
> index b2dabd1..fc22c76 100644
> --- a/iutil.py
> +++ b/iutil.py
> @@ -453,6 +453,17 @@ def swapSuggestion(quiet=0):
>  
>      return (minswap, maxswap)
>  
> +def total_memory():
> +    """
> +    Calculate how much memory this machine has in kB. Because
> /proc/meminfo only
> +    gives us the MemTotal (total physical RAM minus the kernel binary
> code), we
> +    need to round this up. Assuming every machine has the total RAM
> MB number
> +    divisible by 128
> +    """
> +    reported_mb = memInstalled() / 1024
> +    mem = ((reported_mb / 128) + 1) * 128
> +    return mem * 1024
> +
>  ## Create a directory path.  Don't fail if the directory already
> exists.
>  # @param dir The directory path to create.
>  def mkdirChain(dir):
> diff --git a/loader/loadermisc.c b/loader/loadermisc.c
> index 64e80a2..2e667f5 100644
> --- a/loader/loadermisc.c
> +++ b/loader/loadermisc.c
> @@ -144,6 +144,13 @@ int totalMemory(void) {
>          }
>      }
>  
> +    /*Because /proc/meminfo only gives us the MemTotal (total
> physical RAM minus
> +    the kernel binary code), we need to round this up. Assuming every
> machine
> +    has the total RAM MB number divisible by 128. */
> +    total /= 1024;
> +    total = (total / 128 + 1) * 128;
> +    total *= 1024;
> +
>      logMessage(INFO, "%d kB are available", total);
>  
>      return total;
> -- 
> 1.6.6
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list redhat com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list


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