All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: linux-hotplug@vger.kernel.org
Subject: getpagesize / libsysfs broken with 0.148
Date: Thu, 15 Jul 2004 08:51:11 +0000	[thread overview]
Message-ID: <40F6457F.8050200@suse.de> (raw)

[-- 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));
 }

             reply	other threads:[~2004-07-15  8:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-15  8:51 Hannes Reinecke [this message]
2004-07-15  9:10 ` getpagesize / libsysfs broken with 0.148 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40F6457F.8050200@suse.de \
    --to=hare@suse.de \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.