linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* getpagesize / libsysfs broken with 0.148
@ 2004-07-15  8:51 Hannes Reinecke
  2004-07-15  9:10 ` Harald Hoyer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Hannes Reinecke @ 2004-07-15  8:51 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1153 bytes --]

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

[-- Attachment #2: klibc-0.148-getpagesize.patch --]
[-- Type: text/x-patch, Size: 384 bytes --]

--- klibc-0.148/klibc/getpagesize.c.orig	2004-07-07 11:56:31.000000000 +0200
+++ klibc-0.148/klibc/getpagesize.c	2004-07-15 10:32:32.749143222 +0200
@@ -20,5 +20,6 @@
   if ( rv == -1 )
     return -1;
 
-  return (page_size = si.mem_unit);
+  /* sysinfo returns 1 for mem_unit in some cases, so default to 4096. */
+  return (page_size = (si.mem_unit == 1 ? 4096 : si.mem_unit));
 }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: getpagesize / libsysfs broken with 0.148
  2004-07-15  8:51 getpagesize / libsysfs broken with 0.148 Hannes Reinecke
@ 2004-07-15  9:10 ` Harald Hoyer
  2004-07-15  9:24 ` Hannes Reinecke
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Harald Hoyer @ 2004-07-15  9:10 UTC (permalink / raw)
  To: linux-hotplug

Hannes Reinecke wrote:
> Hi all,
> 
> the implementation of getpagesize() is broken in klibc.
...

Hannes, care to send more patches from the Suse udev rpm upstream?


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id\x10040&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: getpagesize / libsysfs broken with 0.148
  2004-07-15  8:51 getpagesize / libsysfs broken with 0.148 Hannes Reinecke
  2004-07-15  9:10 ` Harald Hoyer
@ 2004-07-15  9:24 ` Hannes Reinecke
  2004-07-15 14:53 ` Daniel Stekloff
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2004-07-15  9:24 UTC (permalink / raw)
  To: linux-hotplug

Harald Hoyer wrote:
> Hannes Reinecke wrote:
> 
>> Hi all,
>>
>> the implementation of getpagesize() is broken in klibc.
> 
> ...
> 
> Hannes, care to send more patches from the Suse udev rpm upstream?
> 
About to do it. Watch this space.

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


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id\x10040&opÌk
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: getpagesize / libsysfs broken with 0.148
  2004-07-15  8:51 getpagesize / libsysfs broken with 0.148 Hannes Reinecke
  2004-07-15  9:10 ` Harald Hoyer
  2004-07-15  9:24 ` Hannes Reinecke
@ 2004-07-15 14:53 ` Daniel Stekloff
  2004-07-15 15:57 ` [klibc] " H. Peter Anvin
  2004-07-15 17:44 ` H. Peter Anvin
  4 siblings, 0 replies; 6+ messages in thread
From: Daniel Stekloff @ 2004-07-15 14:53 UTC (permalink / raw)
  To: linux-hotplug

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



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id\x10040&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [klibc] getpagesize / libsysfs broken with 0.148
  2004-07-15  8:51 getpagesize / libsysfs broken with 0.148 Hannes Reinecke
                   ` (2 preceding siblings ...)
  2004-07-15 14:53 ` Daniel Stekloff
@ 2004-07-15 15:57 ` H. Peter Anvin
  2004-07-15 17:44 ` H. Peter Anvin
  4 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2004-07-15 15:57 UTC (permalink / raw)
  To: linux-hotplug

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



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id\x10040&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [klibc] getpagesize / libsysfs broken with 0.148
  2004-07-15  8:51 getpagesize / libsysfs broken with 0.148 Hannes Reinecke
                   ` (3 preceding siblings ...)
  2004-07-15 15:57 ` [klibc] " H. Peter Anvin
@ 2004-07-15 17:44 ` H. Peter Anvin
  4 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2004-07-15 17:44 UTC (permalink / raw)
  To: linux-hotplug

H. Peter Anvin wrote:
> 
> *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.
> 

OK, Arjan van der Ven suggested using the AT_PAGESZ vector entry in the 
ELF header; this provides a nice and uniform solution across all platforms.

	-hpa


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id\x10040&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-07-15 17:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-15  8:51 getpagesize / libsysfs broken with 0.148 Hannes Reinecke
2004-07-15  9:10 ` Harald Hoyer
2004-07-15  9:24 ` Hannes Reinecke
2004-07-15 14:53 ` Daniel Stekloff
2004-07-15 15:57 ` [klibc] " H. Peter Anvin
2004-07-15 17:44 ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).