Daniel Stekloff
2004-Jul-15 07:55 UTC
[klibc] Re: getpagesize / libsysfs broken with 0.148
On Thu, 2004-07-15 at 01:51, Hannes Reinecke wrote:> Hi all, > > the implementation of getpagesize() is broken in klibc. > > klibc uses sysinfo.mem_unit, which linux interpretes as the memory unit > all other memory values returned are to be multiplied with. > So it's perfectly ok for the linux sysinfo() to return a mem_unit of > '1', which is does if the memory available for this machine fits into > the counter. > For the unbelievers, have a look in kernel/timer.c:sys_sysinfo(). > > As a quick hack I've added a check for mem_unit==1 and reset the > page_size to 4096 on those cases. > > Naturally, this is not the right fix. The right fix would be to get the > values from the kernel headers and/or some magic juju for those machines > with variable pagesize. > > It probably would not have been noticed, but as libsysfs insists on > doing all reads from sysfs attributes with a length of pagesize, the > failures were ... interesting.Libsysfs reads with length of pagesize because that was a sysfs limitation. Has sysfs changed? There use to be an ifdef klibc around the getpagesize() call but that seems to have been removed at some point. Thanks, Dan> So in short, udev does _not_ work with klibc until that (or an > equivalent) patch is applied. > > Cheers, > > Hannes
Hi all, the implementation of getpagesize() is broken in klibc. klibc uses sysinfo.mem_unit, which linux interpretes as the memory unit all other memory values returned are to be multiplied with. So it's perfectly ok for the linux sysinfo() to return a mem_unit of '1', which is does if the memory available for this machine fits into the counter. For the unbelievers, have a look in kernel/timer.c:sys_sysinfo(). As a quick hack I've added a check for mem_unit==1 and reset the page_size to 4096 on those cases. Naturally, this is not the right fix. The right fix would be to get the values from the kernel headers and/or some magic juju for those machines with variable pagesize. It probably would not have been noticed, but as libsysfs insists on doing all reads from sysfs attributes with a length of pagesize, the failures were ... interesting. So in short, udev does _not_ work with klibc until that (or an equivalent) patch is applied. Cheers, Hannes -- Dr. Hannes Reinecke hare@suse.de SuSE Linux AG S390 & zSeries Maxfeldstra?e 5 +49 911 74053 688 90409 N?rnberg http://www.suse.de -------------- next part -------------- A non-text attachment was scrubbed... Name: klibc-0.148-getpagesize.patch Type: text/x-patch Size: 384 bytes Desc: not available Url : http://www.zytor.com/pipermail/klibc/attachments/20040715/fa176139/klibc-0.148-getpagesize-0001.bin
Hannes Reinecke wrote: >> Hi all, > > the implementation of getpagesize() is broken in klibc. > > klibc uses sysinfo.mem_unit, which linux interpretes as the memory unit > all other memory values returned are to be multiplied with. > So it's perfectly ok for the linux sysinfo() to return a mem_unit of > '1', which is does if the memory available for this machine fits into > the counter. > For the unbelievers, have a look in kernel/timer.c:sys_sysinfo(). > > As a quick hack I've added a check for mem_unit==1 and reset the > page_size to 4096 on those cases. >*SIGH* So much for the claim that there actually existed a sane way to get the page size across platforms. This is particularly nasty because of the definition of mmap2(). The kernel headers don't work very well since page size is a kernel-compile-time option on some platforms, e.g. MIPS, and dynamic on some platforms. -hpa