Here is a patch for the smem man page. It includes the following:
* A new section on embedded usage briefly describing smemcap
NOTE: Someone please doublecheck it,
since I am not an embedded developer.
* Mentions that kernel image for -K option must be uncompressed.
* A new copyright section.
* A new resources section.
* Replaces notes with a requirements section.
* Adds a couple of commands to the see also list.
* Fixes a couple typos.
- totalmem should return kB when provided manually
- firmware size never goes below zero
- add comments
- calculate kernel portion of cached by subtracting mapped rather than
anonymous
- get rid of sum() bits for silly column totals
Jeff Schroeder wrote:
> Awesome tool! I learned about this from the LWN article and
> immediately (stupidly) tried it out on a centos 5 host. Here is a
> patch to add a kernel version check.
This is a nice fix, but the version check should be done against
the proc data being used (which is not necessarily that of the
local kernel). This required moving kernel_version_check to
after where the src data is read.
I do "smem -w -K a.txt -R 2048M" and got following error:
zhichyu@w-shpd-zcyu:~/sftw4ubuntu$ smem-0.1/smem -w -K a.txt -R 2048M
size: 'a.txt': No such file
Traceback (most recent call last):
File "smem-0.1/smem", line 607, in <module>
showsystem()
File "smem-0.1/smem", line 361, in showsystem
k = kernelsize()
File "smem-0.1/smem", line 77, in kernelsize
d = os.popen("size %s" % options.kernel).readlines()[1]
IndexError: list index out of range
The root cause is that os.popen("size a.txt") returns only one line.
If the user provides an invalid kernel image file path, I think it's
better to assume the image size is zero than raise an exception.
There are two minor bugs on physical memory size computing:
(1) fromunits() returns wrong value for "2001844kB", which consists of
more than one digits.
(2) memory()['memtotal'] is in kB. If "--realmem" is not provided at
CLI, totalmem() returns number in MB and the "firmware/hardware"
amount will be minus. totalmem() needs to always return value in kB.
Here is how to test this patch:
(1) Do "smem -w" , the "firmware/hardware" amount should not be minus.
(2) Do "smem -w -R 2001844kB" (change 2001844kB per your PC, note to
keep it in kB unit) , the "firmware/hardware" amount should not be
minus.
Here's a patch to fix these issues.
Awesome tool! I learned about this from the LWN article and
immediately (stupidly) tried it out on a centos 5 host. Here is a
patch to add a kernel version check.