Message ID | 1386317890.31845.26.camel@joe-AO722 |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 06/12/13 09:18, Joe Perches wrote: > Use CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS to check if this > function can be optimized by using the generic ether_addr_equal. > > Remove the unnecessary ?: after the unoptimized memcmp. > > Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Antonio Quartulli <antonio@meshcoding.com> - -- Antonio Quartulli -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBCAAGBQJSoaKXAAoJEEKTMo6mOh1VMjoP/3GqGy0TQG1yXRzbrzAbbklJ 8Oa6DHQd2pSN/cJkR501JYwSUnCGh3m7eh7qc1HZYrEIgxIrJDLHWSqBL3FPtgap gQ92BBQG/pd38ZmmWSeZob44bEMEGAn00B1kgFx+Xb4YW4bP2rDAlvPxjjaqjT3U tBNbNYxUTBY2JMftI7WwEOwMWgLPVoHR1PhAbBTpbXMXCRrGp/vXN1xXam1xIDNx kahFmHA1Dc91dwr8ev4bcUjfGO2tXkQOEoqKRkwc1SEzuKTjgJNDxdbFNqG6vMAm k/aXhMvf3DOUkaCeslRQIkwefbKmzN69c1x2ND7S8mLEMIKyBuhKUFcf6PebD9SK Dc+KdwIx0lsaS2vGqOt6mUSie1KfY8QNAc74eF6XjDhKyJynYXe6S3L40uT4eLXR 8fwGClJmyYVIiYD65NOtiIx6C2uHFchjDpXjlz0X8N9oQ2Azr4e2RMTGkkoihvOh 94r1dmAaBrnRiAu6AkImhgN+lWgLglHWD5trmmRCxNEJf0iW+x9ZaR4yAQFDUP3k mrk5AN8JuRZkOeY5QK4AIZ0bFUh8tKW6JaNb8VHQGsLqjhAB/HPS6VljyRgMalyQ c/kLlEOIIZ9dsjMwKMgyoJ9bMtTYUTxrriKz12mQbx8mWvm4CMFEQglljQiuTyvh J+UsjAHs/ffW59JIGCfB =8xL7 -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Joe Perches <joe@perches.com> Date: Fri, 06 Dec 2013 00:18:10 -0800 > @@ -266,7 +266,11 @@ static inline void batadv_dbg(int type __always_unused, > */ > static inline int batadv_compare_eth(const void *data1, const void *data2) > { > - return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); > +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) > + return ether_addr_equal(data1, data2); > +#else > + return memcmp(data1, data2, ETH_ALEN) == 0; > +#endif > } Let's not crap up implementations with these ifdefs. What's the specific situation here? Is it that 'data1' and/or 'data2' my not be u16 aligned? If so, make a function for that in linux/etherdevice.h and invoke it in such places. You can name it something like "ether_addr_equal_unaligned()" or similar. Thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 2013-12-06 at 15:39 -0500, David Miller wrote: > From: Joe Perches <joe@perches.com> > Date: Fri, 06 Dec 2013 00:18:10 -0800 > > > @@ -266,7 +266,11 @@ static inline void batadv_dbg(int type __always_unused, > > */ > > static inline int batadv_compare_eth(const void *data1, const void *data2) > > { > > - return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); > > +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) > > + return ether_addr_equal(data1, data2); > > +#else > > + return memcmp(data1, data2, ETH_ALEN) == 0; > > +#endif > > } > > Let's not crap up implementations with these ifdefs. > > What's the specific situation here? Is it that 'data1' and/or > 'data2' my not be u16 aligned? Yes. > If so, make a function for that in linux/etherdevice.h and invoke it > in such places. You can name it something like > "ether_addr_equal_unaligned()" or similar. I'll resubmit if/after you apply the ether_addr_equal/compare_ether_addr removal. cheers, Joe -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Joe Perches <joe@perches.com> Date: Fri, 06 Dec 2013 13:17:01 -0800 > On Fri, 2013-12-06 at 15:39 -0500, David Miller wrote: >> If so, make a function for that in linux/etherdevice.h and invoke it >> in such places. You can name it something like >> "ether_addr_equal_unaligned()" or similar. > > I'll resubmit if/after you apply the > ether_addr_equal/compare_ether_addr removal. Done. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index f94f287b..74a7a3f 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -266,7 +266,11 @@ static inline void batadv_dbg(int type __always_unused, */ static inline int batadv_compare_eth(const void *data1, const void *data2) { - return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + return ether_addr_equal(data1, data2); +#else + return memcmp(data1, data2, ETH_ALEN) == 0; +#endif } /**
Use CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS to check if this function can be optimized by using the generic ether_addr_equal. Remove the unnecessary ?: after the unoptimized memcmp. Signed-off-by: Joe Perches <joe@perches.com> --- net/batman-adv/main.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html