dphys-swapfile sets incorrect swap size

Bug #706764 reported by Gerry Reno
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dphys-swapfile (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: dphys-swapfile

In Ubuntu 10.04 LTS Lucid.

Package: dphys-swapfile does not set the proper swap file size. It currently looks at /proc/kcore to determine the memory size and in my machine this file is 0 bytes.

Attaching patch.

Related branches

Revision history for this message
Gerry Reno (greno-verizon) wrote :
Revision history for this message
Axel Beckert (xtaran) wrote :

Hi,

this is a bug already fixed in newer versions of dphys-swapfile, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=564466. The version in Maverick is already a fixed one. Maybe that fix should be backported to Lucid...

The only difference between the above mentioned bug report in Debian from nearly a year ago and this one is that /proc/kcore has now a zero size instead of an insanely huge size. I regard the case with a zero size kcore as way less critical than the one which fills up your hard drive.

Changed in dphys-swapfile (Ubuntu):
status: New → Confirmed
tags: added: patch
Axel Beckert (xtaran)
tags: added: fixed-in-debian fixed-upstream
Revision history for this message
Gerry Reno (greno-verizon) wrote :

When I look at upstream 20061020-3:
   MEMSIZE="`head -1 /proc/meminfo | awk '{ print $2 }'`"
looks like it still might be high by a factor of 1024 since MEMSIZE is in megabytes and meminfo is in kilobytes.

That is why my patch adjusted for the difference:
   MEMSIZE=$(($(cat /proc/meminfo | awk '/^MemTotal/ { print $2 }') / 1024))

tags: removed: fixed-in-debian fixed-upstream
Revision history for this message
Axel Beckert (xtaran) wrote : Re: [Bug 706764] Re: dphys-swapfile sets incorrect swap size

Hi,

Gerry Reno wrote:
> When I look at upstream 20061020-3:
> MEMSIZE="`head -1 /proc/meminfo | awk '{ print $2 }'`"
> looks like it still might be high by a factor of 1024 since MEMSIZE is in megabytes and meminfo is in kilobytes.
>
> That is why my patch adjusted for the difference:
> MEMSIZE=$(($(cat /proc/meminfo | awk '/^MemTotal/ { print $2 }') / 1024))

Indeed. Probably got through unnoticed because of the reintroduction
of a maximum size. Thanks for spotting that.

It's though fixed in the current upstream developement snapshot:

      MEMTOTAL="`grep '^MemTotal:' /proc/meminfo | awk '{ print $2 }'`"
      # make MBytes which rounded down will be about 10 too few, so add 10
      MEMSIZE="`echo "${MEMTOTAL} 1024 / 10 + p q" | dc`"
      # compute desired swap size, as factor * RAM
      CONF_SWAPSIZE="`echo "${MEMSIZE} ${CONF_SWAPFACTOR} * p q" | dc`"
      # remove any fractional MBytes
      CONF_SWAPSIZE="`echo "${CONF_SWAPSIZE}" | cut -f 1 -d '.'`"

  Regards, Axel
--
 ,''`. | Axel Beckert <email address hidden>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
  `- | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5

Revision history for this message
Gerry Reno (greno-verizon) wrote :

Hi Alex,
  I tried to run the fix you show for development snapshot on my machine but it says this:

The program 'dc' is currently not installed. You can install it by typing:
apt-get install dc

????

Revision history for this message
Gerry Reno (greno-verizon) wrote :

My machine is just a basic Ubuntu 10.04 LTS Lucid server.

It does have the 'bc' calculator installed but not 'dc'.

'dc' being RPN is also quite obtuse to understand being stack based which might the code difficult to maintain.

'expr' can be a pain to use with all the quoting needed but I see that used quite a lot.

Revision history for this message
Axel Beckert (xtaran) wrote :

Hi Gerry,

Gerry Reno wrote:
> I tried to run the fix you show for development snapshot on my machine but it says this:
>
> The program 'dc' is currently not installed. You can install it by typing:
> apt-get install dc

Yep, upstream switched to dc for the next release. Will become an
additional dependency in the next package. A lightweight one though.

Gerry Reno wrote:
> It does have the 'bc' calculator installed but not 'dc'.

That's no problem since dc will be installed automatically via
dependencies. Just forgot to mention that when I quoted the code from
upstream.

> 'dc' being RPN is also quite obtuse to understand being stack based
> which might the code difficult to maintain.

Surely not for the upstream developer of dphys-swapfile. He collects
pocket calculators, and likes especially those with RPN. And I'm fine
with RPN and dc, too. :)

  Regards, Axel
--
 ,''`. | Axel Beckert <email address hidden>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
  `- | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5

Axel Beckert (xtaran)
Changed in dphys-swapfile (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Axel Beckert (xtaran) wrote :

I just uploaded 20061020-4 to Debian Unstable which fixes specifically the magnitude issue.

tags: added: fixed-in-debian
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dphys-swapfile - 20061020-4

---------------
dphys-swapfile (20061020-4) unstable; urgency=low

  * Fix wrong magnitude in last upload's bugfix for 564466 when
    calculating swap size. (Closes: #612877, LP: #706764) Thanks Antonio
    Galea <email address hidden> for a very unintrusive patch.
 -- Bhavani Shankar <email address hidden> Fri, 11 Feb 2011 14:40:33 +0100

Changed in dphys-swapfile (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.