diff options
author | Arnd Bergmann <arnd@arndb.de> | 2016-03-16 12:39:17 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-03-18 15:29:58 -0400 |
commit | ef3fb2422ffe92ead0579c21a02095b329434900 (patch) | |
tree | 7ec167e9ce2e8681ec3d412ddcbbfffc64a8531f | |
parent | 14cee5b4de4b9e01438d58d1806e7eef78720405 (diff) |
scsi: fc: use get/put_unaligned64 for wwn access
A bug in the gcc-6.0 prerelease version caused at least one
driver (lpfc) to have excessive stack usage when dealing with
wwn data, on the ARM architecture.
lpfc_scsi.c: In function 'lpfc_find_next_oas_lun':
lpfc_scsi.c:117:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
I have reported this as a gcc regression in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70232
However, using a better implementation of wwn_to_u64() not only
helps with the particular gcc problem but also leads to better
object code for any version or architecture.
The kernel already provides get_unaligned_be64() and
put_unaligned_be64() helper functions that provide an
optimized implementation with the desired semantics.
The lpfc_find_next_oas_lun() function in the example that
grew from 1146 bytes to 5144 bytes when moving from gcc-5.3
to gcc-6.0 is now 804 bytes, as the optimized
get_unaligned_be64() load can be done in three instructions.
The stack usage is now down to 28 bytes from 128 bytes with
gcc-5.3 before.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | include/scsi/scsi_transport_fc.h | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index 784bc2c0929f..bf66ea6bed2b 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #define SCSI_TRANSPORT_FC_H | 28 | #define SCSI_TRANSPORT_FC_H |
29 | 29 | ||
30 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
31 | #include <asm/unaligned.h> | ||
31 | #include <scsi/scsi.h> | 32 | #include <scsi/scsi.h> |
32 | #include <scsi/scsi_netlink.h> | 33 | #include <scsi/scsi_netlink.h> |
33 | 34 | ||
@@ -797,22 +798,12 @@ fc_remote_port_chkready(struct fc_rport *rport) | |||
797 | 798 | ||
798 | static inline u64 wwn_to_u64(u8 *wwn) | 799 | static inline u64 wwn_to_u64(u8 *wwn) |
799 | { | 800 | { |
800 | return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 | | 801 | return get_unaligned_be64(wwn); |
801 | (u64)wwn[2] << 40 | (u64)wwn[3] << 32 | | ||
802 | (u64)wwn[4] << 24 | (u64)wwn[5] << 16 | | ||
803 | (u64)wwn[6] << 8 | (u64)wwn[7]; | ||
804 | } | 802 | } |
805 | 803 | ||
806 | static inline void u64_to_wwn(u64 inm, u8 *wwn) | 804 | static inline void u64_to_wwn(u64 inm, u8 *wwn) |
807 | { | 805 | { |
808 | wwn[0] = (inm >> 56) & 0xff; | 806 | put_unaligned_be64(inm, wwn); |
809 | wwn[1] = (inm >> 48) & 0xff; | ||
810 | wwn[2] = (inm >> 40) & 0xff; | ||
811 | wwn[3] = (inm >> 32) & 0xff; | ||
812 | wwn[4] = (inm >> 24) & 0xff; | ||
813 | wwn[5] = (inm >> 16) & 0xff; | ||
814 | wwn[6] = (inm >> 8) & 0xff; | ||
815 | wwn[7] = inm & 0xff; | ||
816 | } | 807 | } |
817 | 808 | ||
818 | /** | 809 | /** |