netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
       [not found] <cover.1438331416.git.viresh.kumar@linaro.org>
@ 2015-07-31  8:38 ` Viresh Kumar
  2015-07-31 15:04   ` Murali Karicheri
       [not found] ` <cover.1438331416.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2015-07-31  8:38 UTC (permalink / raw)
  To: akpm
  Cc: linaro-kernel, linux-kernel, Viresh Kumar, Murali Karicheri,
	open list:TI NETCP ETHERNET DRIVER, Wingman Kwok

IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
is no need to do that again from its callers. Drop it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/net/ethernet/ti/netcp_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index ec8ed30196f3..f685a19a3703 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -1016,7 +1016,7 @@ netcp_tx_map_skb(struct sk_buff *skb, struct netcp_intf *netcp)
 	}
 
 	desc = knav_pool_desc_get(netcp->tx_pool);
-	if (unlikely(IS_ERR_OR_NULL(desc))) {
+	if (IS_ERR_OR_NULL(desc)) {
 		dev_err(netcp->ndev_dev, "out of TX desc\n");
 		dma_unmap_single(dev, dma_addr, pkt_len, DMA_TO_DEVICE);
 		return NULL;
@@ -1049,7 +1049,7 @@ netcp_tx_map_skb(struct sk_buff *skb, struct netcp_intf *netcp)
 		}
 
 		ndesc = knav_pool_desc_get(netcp->tx_pool);
-		if (unlikely(IS_ERR_OR_NULL(ndesc))) {
+		if (IS_ERR_OR_NULL(ndesc)) {
 			dev_err(netcp->ndev_dev, "out of TX desc for frags\n");
 			dma_unmap_page(dev, dma_addr, buf_len, DMA_TO_DEVICE);
 			goto free_descs;
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 15/15] net: Drop unlikely before IS_ERR(_OR_NULL)
       [not found] ` <cover.1438331416.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-07-31  8:38   ` Viresh Kumar
  0 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2015-07-31  8:38 UTC (permalink / raw)
  To: akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b
  Cc: open list:OPENVSWITCH, linaro-kernel-cunTk1MwBs8s++Sfvej+rw,
	Neil Horman, Viresh Kumar, Vlad Yasevich,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, open list:SCTP PROTOCOL,
	open list:OPENVSWITCH, David S. Miller

IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
is no need to do that again from its callers. Drop it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 net/openvswitch/datapath.c | 2 +-
 net/sctp/socket.c          | 2 +-
 net/socket.c               | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index ff8c4a4c1609..01d69680ba5d 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1143,7 +1143,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
 						info, OVS_FLOW_CMD_NEW, false,
 						ufid_flags);
 
-		if (unlikely(IS_ERR(reply))) {
+		if (IS_ERR(reply)) {
 			error = PTR_ERR(reply);
 			goto err_unlock_ovs;
 		}
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1425ec2bbd5a..c1569432235e 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4481,7 +4481,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval
 	}
 
 	newfile = sock_alloc_file(newsock, 0, NULL);
-	if (unlikely(IS_ERR(newfile))) {
+	if (IS_ERR(newfile)) {
 		put_unused_fd(retval);
 		sock_release(newsock);
 		return PTR_ERR(newfile);
diff --git a/net/socket.c b/net/socket.c
index 9963a0b53a64..dd2c247c99e3 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -373,7 +373,7 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname)
 
 	file = alloc_file(&path, FMODE_READ | FMODE_WRITE,
 		  &socket_file_ops);
-	if (unlikely(IS_ERR(file))) {
+	if (IS_ERR(file)) {
 		/* drop dentry, keep inode */
 		ihold(d_inode(path.dentry));
 		path_put(&path);
@@ -1303,7 +1303,7 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,
 	}
 
 	newfile1 = sock_alloc_file(sock1, flags, NULL);
-	if (unlikely(IS_ERR(newfile1))) {
+	if (IS_ERR(newfile1)) {
 		err = PTR_ERR(newfile1);
 		goto out_put_unused_both;
 	}
@@ -1467,7 +1467,7 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
 		goto out_put;
 	}
 	newfile = sock_alloc_file(newsock, flags, sock->sk->sk_prot_creator->name);
-	if (unlikely(IS_ERR(newfile))) {
+	if (IS_ERR(newfile)) {
 		err = PTR_ERR(newfile);
 		put_unused_fd(newfd);
 		sock_release(newsock);
-- 
2.4.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
  2015-07-31  8:38 ` [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL) Viresh Kumar
@ 2015-07-31 15:04   ` Murali Karicheri
  2015-07-31 15:39     ` David Laight
  2015-07-31 16:20     ` Viresh Kumar
  0 siblings, 2 replies; 6+ messages in thread
From: Murali Karicheri @ 2015-07-31 15:04 UTC (permalink / raw)
  To: Viresh Kumar, akpm
  Cc: linaro-kernel, linux-kernel, TI NETCP ETHERNET DRIVER,
	Wingman Kwok

On 07/31/2015 04:38 AM, Viresh Kumar wrote:
> IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
> is no need to do that again from its callers. Drop it.
>

IS_ERR_OR_NULL() is defined as

static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
{
         return !ptr || IS_ERR_VALUE((unsigned long)ptr);
}

So the unlikely() applies only to second part. Wouldn't that be a 
problem for optimization?

Murali

> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>   drivers/net/ethernet/ti/netcp_core.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
> index ec8ed30196f3..f685a19a3703 100644
> --- a/drivers/net/ethernet/ti/netcp_core.c
> +++ b/drivers/net/ethernet/ti/netcp_core.c
> @@ -1016,7 +1016,7 @@ netcp_tx_map_skb(struct sk_buff *skb, struct netcp_intf *netcp)
>   	}
>
>   	desc = knav_pool_desc_get(netcp->tx_pool);
> -	if (unlikely(IS_ERR_OR_NULL(desc))) {
> +	if (IS_ERR_OR_NULL(desc)) {
>   		dev_err(netcp->ndev_dev, "out of TX desc\n");
>   		dma_unmap_single(dev, dma_addr, pkt_len, DMA_TO_DEVICE);
>   		return NULL;
> @@ -1049,7 +1049,7 @@ netcp_tx_map_skb(struct sk_buff *skb, struct netcp_intf *netcp)
>   		}
>
>   		ndesc = knav_pool_desc_get(netcp->tx_pool);
> -		if (unlikely(IS_ERR_OR_NULL(ndesc))) {
> +		if (IS_ERR_OR_NULL(ndesc)) {
>   			dev_err(netcp->ndev_dev, "out of TX desc for frags\n");
>   			dma_unmap_page(dev, dma_addr, buf_len, DMA_TO_DEVICE);
>   			goto free_descs;
>


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
  2015-07-31 15:04   ` Murali Karicheri
@ 2015-07-31 15:39     ` David Laight
  2015-07-31 16:20     ` Viresh Kumar
  1 sibling, 0 replies; 6+ messages in thread
From: David Laight @ 2015-07-31 15:39 UTC (permalink / raw)
  To: 'Murali Karicheri', Viresh Kumar,
	akpm@linux-foundation.org
  Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org,
	TI NETCP ETHERNET DRIVER, Wingman Kwok

From: Murali Karicheri
> Sent: 31 July 2015 16:04
> On 07/31/2015 04:38 AM, Viresh Kumar wrote:
> > IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
> > is no need to do that again from its callers. Drop it.
> >
> 
> IS_ERR_OR_NULL() is defined as
> 
> static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
> {
>          return !ptr || IS_ERR_VALUE((unsigned long)ptr);
> }
> 
> So the unlikely() applies only to second part. Wouldn't that be a
> problem for optimization?

Ugg...

The unlikely() in IS_ERR_VALUE() is likely to stop the compiler
doing a single 'window' comparison for the range [-MAX_ERROR .. 0].
So you are likely to end up with 2 comparisons.
I suspect that:

	return IS_ERR_VALUE((unsigned long)ptr - 1);

would be a much better test.
(Ignoring the off-by-one for the highest error.)

	David

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
  2015-07-31 15:04   ` Murali Karicheri
  2015-07-31 15:39     ` David Laight
@ 2015-07-31 16:20     ` Viresh Kumar
  2015-08-03 15:52       ` Murali Karicheri
  1 sibling, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2015-07-31 16:20 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: akpm, linaro-kernel, linux-kernel, TI NETCP ETHERNET DRIVER,
	Wingman Kwok

On 31-07-15, 11:04, Murali Karicheri wrote:
> On 07/31/2015 04:38 AM, Viresh Kumar wrote:
> >IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
> >is no need to do that again from its callers. Drop it.
> >
> 
> IS_ERR_OR_NULL() is defined as
> 
> static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
> {
>         return !ptr || IS_ERR_VALUE((unsigned long)ptr);
> }
> 
> So the unlikely() applies only to second part. Wouldn't that be a
> problem for optimization?

This is what the first patch of the series does:

http://permalink.gmane.org/gmane.linux.kernel/2009151

-- 
viresh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
  2015-07-31 16:20     ` Viresh Kumar
@ 2015-08-03 15:52       ` Murali Karicheri
  0 siblings, 0 replies; 6+ messages in thread
From: Murali Karicheri @ 2015-08-03 15:52 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: akpm, linaro-kernel, linux-kernel, TI NETCP ETHERNET DRIVER,
	Wingman Kwok

On 07/31/2015 12:20 PM, Viresh Kumar wrote:
> On 31-07-15, 11:04, Murali Karicheri wrote:
>> On 07/31/2015 04:38 AM, Viresh Kumar wrote:
>>> IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
>>> is no need to do that again from its callers. Drop it.
>>>
>>
>> IS_ERR_OR_NULL() is defined as
>>
>> static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
>> {
>>          return !ptr || IS_ERR_VALUE((unsigned long)ptr);
>> }
>>
>> So the unlikely() applies only to second part. Wouldn't that be a
>> problem for optimization?
>
> This is what the first patch of the series does:
>
> http://permalink.gmane.org/gmane.linux.kernel/2009151
>
Assuming the above change is merged, this patch looks good.

Acked-by: Murali Karicheri <m-karicheri2@ti.com>

-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-03 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1438331416.git.viresh.kumar@linaro.org>
2015-07-31  8:38 ` [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL) Viresh Kumar
2015-07-31 15:04   ` Murali Karicheri
2015-07-31 15:39     ` David Laight
2015-07-31 16:20     ` Viresh Kumar
2015-08-03 15:52       ` Murali Karicheri
     [not found] ` <cover.1438331416.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-07-31  8:38   ` [PATCH 15/15] " Viresh Kumar

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).