Message ID | 1386317890.31845.26.camel@joe-AO722 (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <joe@perches.com> Received: from smtprelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by open-mesh.org (Postfix) with ESMTP id B6FDE601F09 for <b.a.t.m.a.n@lists.open-mesh.org>; Fri, 6 Dec 2013 09:18:14 +0100 (CET) Received: from filter.hostedemail.com (ff-bigip1 [10.5.19.254]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id B99AE235AE; Fri, 6 Dec 2013 08:18:13 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::::::, RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1277:1311:1313:1314:1345:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1714:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3351:3865:3867:4419:5007:7652:7903:10004:10400:10848:11026:11473:11658:11914:12043:12438:12517:12519:12555:13069:13311:13357, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: rose03_81d9ec035b507 X-Filterd-Recvd-Size: 1712 Received: from [192.168.1.157] (pool-96-251-49-11.lsanca.fios.verizon.net [96.251.49.11]) (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA; Fri, 6 Dec 2013 08:18:12 +0000 (UTC) Message-ID: <1386317890.31845.26.camel@joe-AO722> From: Joe Perches <joe@perches.com> To: Marek Lindner <mareklindner@neomailbox.ch>, Simon Wunderlich <sw@simonwunderlich.de>, Antonio Quartulli <antonio@meshcoding.com> Date: Fri, 06 Dec 2013 00:18:10 -0800 Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, "David S. Miller" <davem@davemloft.net>, linux-kernel@vger.kernel.org Subject: [B.A.T.M.A.N.] [PATCH -next] batadv: Slight optimization of batadv_compare_eth X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n@lists.open-mesh.org> List-Id: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n.lists.open-mesh.org> List-Unsubscribe: <https://lists.open-mesh.org/mm/options/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=unsubscribe> List-Archive: <http://lists.open-mesh.org/pipermail/b.a.t.m.a.n/> List-Post: <mailto:b.a.t.m.a.n@lists.open-mesh.org> List-Help: <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=help> List-Subscribe: <https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=subscribe> X-List-Received-Date: Fri, 06 Dec 2013 08:18:15 -0000 |
Commit Message
Joe Perches
Dec. 6, 2013, 8:18 a.m. UTC
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(-)
Comments
-----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-----
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.
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
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.
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 } /**