* [PATCH] avoid unaligned access to data
@ 2004-02-29 20:45 Olaf Hering
2004-03-05 22:21 ` Olaf Hering
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Olaf Hering @ 2004-02-29 20:45 UTC (permalink / raw)
To: linux-hotplug
the data access in udevinfo is usually unaligned, due to the fact that
the struct is at offset strlen(sysfspath). That makes an ia64 kernel
rather unhappy. Unless I miss something, this change makes it happy by
making an incompatible change to the database.
diff -p -purN udev-018/udevdb.c udev-018.align/udevdb.c
--- udev-018/udevdb.c 2004-02-19 19:38:36.000000000 +0100
+++ udev-018.align/udevdb.c 2004-02-22 13:05:15.000000000 +0100
@@ -44,6 +44,8 @@
static TDB_CONTEXT *udevdb;
+#define my_key_align (__alignof__(char *))
+
int udevdb_add_dev(const char *path, const struct udevice *dev)
{
TDB_DATA key, data;
@@ -57,6 +59,11 @@ int udevdb_add_dev(const char *path, con
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
+ if (key.dsize & (my_key_align - 1))
+ key.dsize = (key.dsize & ~(my_key_align - 1)) + my_key_align;
+ if (key.dsize > SYSFS_PATH_MAX)
+ key.dsize = SYSFS_PATH_MAX;
+
data.dptr = (void *)dev;
data.dsize = UDEVICE_LEN;
@@ -73,6 +80,11 @@ int udevdb_get_dev(const char *path, str
key.dptr = (void *)path;
key.dsize = strlen(path) + 1;
+ if (key.dsize & (my_key_align - 1))
+ key.dsize = (key.dsize & ~(my_key_align - 1)) + my_key_align;
+ if (key.dsize > SYSFS_PATH_MAX)
+ key.dsize = SYSFS_PATH_MAX;
+
data = tdb_fetch(udevdb, key);
if (data.dptr = NULL || data.dsize = 0)
return -ENODEV;
@@ -96,6 +108,11 @@ int udevdb_delete_dev(const char *path)
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
+ if (key.dsize & (my_key_align - 1))
+ key.dsize = (key.dsize & ~(my_key_align - 1)) + my_key_align;
+ if (key.dsize > SYSFS_PATH_MAX)
+ key.dsize = SYSFS_PATH_MAX;
+
return tdb_delete(udevdb, key);
}
--
USB is for mice, FireWire is for men!
sUse lINUX ag, n√úRNBERG
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
@ 2004-03-05 22:21 ` Olaf Hering
2004-03-12 23:40 ` Greg KH
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Olaf Hering @ 2004-03-05 22:21 UTC (permalink / raw)
To: linux-hotplug
On Sun, Feb 29, Olaf Hering wrote:
>
> the data access in udevinfo is usually unaligned, due to the fact that
> the struct is at offset strlen(sysfspath). That makes an ia64 kernel
> rather unhappy. Unless I miss something, this change makes it happy by
> making an incompatible change to the database.
>
What is the plan here, Greg?
--
USB is for mice, FireWire is for men!
sUse lINUX ag, n√úRNBERG
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
2004-03-05 22:21 ` Olaf Hering
@ 2004-03-12 23:40 ` Greg KH
2004-03-12 23:41 ` Greg KH
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2004-03-12 23:40 UTC (permalink / raw)
To: linux-hotplug
On Fri, Mar 05, 2004 at 11:21:36PM +0100, Olaf Hering wrote:
> On Sun, Feb 29, Olaf Hering wrote:
>
> >
> > the data access in udevinfo is usually unaligned, due to the fact that
> > the struct is at offset strlen(sysfspath). That makes an ia64 kernel
> > rather unhappy. Unless I miss something, this change makes it happy by
> > making an incompatible change to the database.
> >
>
> What is the plan here, Greg?
Greg didn't see this patch :(
Next time please cc patches to me so I make sure I don't miss them. I
tend to get a _lot_ of email...
Anyway, what is the error that happens on a ia64 box?
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
2004-03-05 22:21 ` Olaf Hering
2004-03-12 23:40 ` Greg KH
@ 2004-03-12 23:41 ` Greg KH
2004-03-12 23:59 ` Olaf Hering
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2004-03-12 23:41 UTC (permalink / raw)
To: linux-hotplug
On Sun, Feb 29, 2004 at 09:45:31PM +0100, Olaf Hering wrote:
>
> the data access in udevinfo is usually unaligned, due to the fact that
> the struct is at offset strlen(sysfspath). That makes an ia64 kernel
> rather unhappy. Unless I miss something, this change makes it happy by
> making an incompatible change to the database.
>
>
> diff -p -purN udev-018/udevdb.c udev-018.align/udevdb.c
> --- udev-018/udevdb.c 2004-02-19 19:38:36.000000000 +0100
> +++ udev-018.align/udevdb.c 2004-02-22 13:05:15.000000000 +0100
> @@ -44,6 +44,8 @@
> static TDB_CONTEXT *udevdb;
>
>
> +#define my_key_align (__alignof__(char *))
Hm, can't we just pad out our data structures to provide the proper
alignment? If it's really necessary...
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
` (2 preceding siblings ...)
2004-03-12 23:41 ` Greg KH
@ 2004-03-12 23:59 ` Olaf Hering
2004-03-13 0:03 ` Olaf Hering
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Olaf Hering @ 2004-03-12 23:59 UTC (permalink / raw)
To: linux-hotplug
On Fri, Mar 12, Greg KH wrote:
> On Fri, Mar 05, 2004 at 11:21:36PM +0100, Olaf Hering wrote:
> > On Sun, Feb 29, Olaf Hering wrote:
> >
> > >
> > > the data access in udevinfo is usually unaligned, due to the fact that
> > > the struct is at offset strlen(sysfspath). That makes an ia64 kernel
> > > rather unhappy. Unless I miss something, this change makes it happy by
> > > making an incompatible change to the database.
> > >
> >
> > What is the plan here, Greg?
>
> Greg didn't see this patch :(
>
> Next time please cc patches to me so I make sure I don't miss them. I
> tend to get a _lot_ of email...
>
> Anyway, what is the error that happens on a ia64 box?
it complains about unaligned memory access.
udevinfo(4922): unaligned access to 0x6000000000015747, ip=0x4000000000001dd0
--
USB is for mice, FireWire is for men!
sUse lINUX ag, n√úRNBERG
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
` (3 preceding siblings ...)
2004-03-12 23:59 ` Olaf Hering
@ 2004-03-13 0:03 ` Olaf Hering
2004-03-13 0:11 ` Greg KH
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Olaf Hering @ 2004-03-13 0:03 UTC (permalink / raw)
To: linux-hotplug
On Fri, Mar 12, Greg KH wrote:
> On Sun, Feb 29, 2004 at 09:45:31PM +0100, Olaf Hering wrote:
> >
> > the data access in udevinfo is usually unaligned, due to the fact that
> > the struct is at offset strlen(sysfspath). That makes an ia64 kernel
> > rather unhappy. Unless I miss something, this change makes it happy by
> > making an incompatible change to the database.
> >
> >
> > diff -p -purN udev-018/udevdb.c udev-018.align/udevdb.c
> > --- udev-018/udevdb.c 2004-02-19 19:38:36.000000000 +0100
> > +++ udev-018.align/udevdb.c 2004-02-22 13:05:15.000000000 +0100
> > @@ -44,6 +44,8 @@
> > static TDB_CONTEXT *udevdb;
> >
> >
> > +#define my_key_align (__alignof__(char *))
>
> Hm, can't we just pad out our data structures to provide the proper
> alignment? If it's really necessary...
its not the alignment of struct members, but the alignment of the
struct itself. we could copy the struct from the database to an aligned
area on the stack or malloc buffer. but thats not faster than the
unaligned access.
--
USB is for mice, FireWire is for men!
sUse lINUX ag, n√úRNBERG
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
` (4 preceding siblings ...)
2004-03-13 0:03 ` Olaf Hering
@ 2004-03-13 0:11 ` Greg KH
2004-03-13 9:58 ` Olaf Hering
2004-03-13 16:57 ` Johannes Erdfelt
7 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2004-03-13 0:11 UTC (permalink / raw)
To: linux-hotplug
On Sat, Mar 13, 2004 at 12:59:39AM +0100, Olaf Hering wrote:
> On Fri, Mar 12, Greg KH wrote:
>
> > On Fri, Mar 05, 2004 at 11:21:36PM +0100, Olaf Hering wrote:
> > > On Sun, Feb 29, Olaf Hering wrote:
> > >
> > > >
> > > > the data access in udevinfo is usually unaligned, due to the fact that
> > > > the struct is at offset strlen(sysfspath). That makes an ia64 kernel
> > > > rather unhappy. Unless I miss something, this change makes it happy by
> > > > making an incompatible change to the database.
> > > >
> > >
> > > What is the plan here, Greg?
> >
> > Greg didn't see this patch :(
> >
> > Next time please cc patches to me so I make sure I don't miss them. I
> > tend to get a _lot_ of email...
> >
> > Anyway, what is the error that happens on a ia64 box?
>
> it complains about unaligned memory access.
>
> udevinfo(4922): unaligned access to 0x6000000000015747, ip=0x4000000000001dd0
So all userspace programs have to be modified to prevent this from
happening?
Does it cause a segfault, or just a warning in the syslog?
Seems like a pretty stupid architecture to be complaining of this :)
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
` (5 preceding siblings ...)
2004-03-13 0:11 ` Greg KH
@ 2004-03-13 9:58 ` Olaf Hering
2004-03-13 16:57 ` Johannes Erdfelt
7 siblings, 0 replies; 9+ messages in thread
From: Olaf Hering @ 2004-03-13 9:58 UTC (permalink / raw)
To: linux-hotplug
On Fri, Mar 12, Greg KH wrote:
> Seems like a pretty stupid architecture to be complaining of this :)
just look at the vendors name..
it results in a warning in dmesg.
--
USB is for mice, FireWire is for men!
sUse lINUX ag, n√úRNBERG
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
* Re: [PATCH] avoid unaligned access to data
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
` (6 preceding siblings ...)
2004-03-13 9:58 ` Olaf Hering
@ 2004-03-13 16:57 ` Johannes Erdfelt
7 siblings, 0 replies; 9+ messages in thread
From: Johannes Erdfelt @ 2004-03-13 16:57 UTC (permalink / raw)
To: linux-hotplug
On Fri, Mar 12, 2004, Greg KH <greg@kroah.com> wrote:
> On Sat, Mar 13, 2004 at 12:59:39AM +0100, Olaf Hering wrote:
> > it complains about unaligned memory access.
> >
> > udevinfo(4922): unaligned access to 0x6000000000015747, ip=0x4000000000001dd0
> So all userspace programs have to be modified to prevent this from
> happening?
>
> Does it cause a segfault, or just a warning in the syslog?
>
> Seems like a pretty stupid architecture to be complaining of this :)
Most architectures don't allow unaligned accesses. x86 is one of the few
that does allow it.
Linux ia64 will perform unaligned accesses in software for userspace
programs when the trap occurs, but will also print a warning.
JE
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&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] 9+ messages in thread
end of thread, other threads:[~2004-03-13 16:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-29 20:45 [PATCH] avoid unaligned access to data Olaf Hering
2004-03-05 22:21 ` Olaf Hering
2004-03-12 23:40 ` Greg KH
2004-03-12 23:41 ` Greg KH
2004-03-12 23:59 ` Olaf Hering
2004-03-13 0:03 ` Olaf Hering
2004-03-13 0:11 ` Greg KH
2004-03-13 9:58 ` Olaf Hering
2004-03-13 16:57 ` Johannes Erdfelt
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).