avoid unaligned access to data
PATCH 1/1 avoid unaligned access to data
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.
udevdb.c +17 -0
@@ -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); }
Signature · 14 lines
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_id56&alloc_id438&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Olaf Hering
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?
Signature · 14 lines
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_id70&alloc_id638&op�k _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 10 lines · Olaf Hering
Quoted 6 lines · Olaf Hering
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_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 11 lines · Olaf Hering
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.cudev-018.align/udevdb.c
udevdb.c line 47
Quoted 4 lines
udevdb.c +1
-0@@ -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_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 10 lines · Greg KH
Quoted 9 lines · Olaf Hering
Quoted 6 lines · Olaf Hering
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.
Quoted 8 lines
Quoted 1 line
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
Signature · 14 lines
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_id70&alloc_id638&op�k _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 15 lines · Greg KH
Quoted 14 lines · Olaf Hering
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.cudev-018.align/udevdb.cudevdb.c +0
-0@@ -44,6 +44,8 @@static TDB_CONTEXT *udevdb;
Quoted 4 lines
udevdb.c line 47
Quoted 1 line
udevdb.c +1
-0+#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.
Signature · 14 lines
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_id70&alloc_id638&op�k _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 16 lines · Olaf Hering
Quoted 14 lines · Greg KH
Quoted 10 lines · Olaf Hering
Quoted 6 lines · Olaf Hering
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 :(
Quoted 8 lines
Quoted 4 lines
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_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 1 line · Greg KH
Seems like a pretty stupid architecture to be complaining of this :)
just look at the vendors name..
it results in a warning in dmesg.
Signature · 14 lines
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_id70&alloc_id638&op�k _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 10 lines · Greg KH
Quoted 3 lines · Olaf Hering
it complains about unaligned memory access.
udevinfo(4922): unaligned access to
0x6000000000015747, ip=0x4000000000001dd0So 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_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel