trivial: Drop unlikely before IS_ERR(_OR_NULL)
Subsystems (37)
cover trivial: Drop unlikely before IS_ERR(_OR_NULL)
Hi,
This cleans up the usage of IS_ERR(_OR_NULL)(), where the callers have added additional unlikely compiler flag to them. It also fixes the definition of IS_ERR_OR_NULL(), to use unlikely for all checks it does.
Viresh Kumar (15):
err.h: add (missing) unlikely() to IS_ERR_OR_NULL() PM / OPP: Drop unlikely before IS_ERR(_OR_NULL)
drivers: devfreq: Drop unlikely before IS_ERR(_OR_NULL)
drivers: gpu: Drop unlikely before IS_ERR(_OR_NULL)
drivers: input: Drop unlikely before IS_ERR(_OR_NULL)
drivers: md: Drop unlikely before IS_ERR(_OR_NULL)
drivers: misc: Drop unlikely before IS_ERR(_OR_NULL)
drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
drivers: rtc: Drop unlikely before IS_ERR(_OR_NULL)
drivers: staging: Drop unlikely before IS_ERR(_OR_NULL)
drivers: target: Drop unlikely before IS_ERR(_OR_NULL)
fs: Drop unlikely before IS_ERR(_OR_NULL)
blk-cgroup: Drop unlikely before IS_ERR(_OR_NULL)
mm: Drop unlikely before IS_ERR(_OR_NULL)
net: Drop unlikely before IS_ERR(_OR_NULL)
drivers/base/power/opp.c | 6 +++--- drivers/devfreq/devfreq.c | 4 ++-- drivers/gpu/drm/ttm/ttm_tt.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- drivers/input/mouse/alps.c | 2 +- drivers/md/dm-snap-persistent.c | 2 +- drivers/md/dm-verity.c | 2 +- drivers/md/persistent-data/dm-block-manager.c | 8 ++++---- drivers/misc/c2port/core.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 4 ++-- drivers/rtc/interface.c | 2 +- drivers/rtc/rtc-bfin.c | 2 +- drivers/rtc/rtc-gemini.c | 2 +- drivers/staging/android/ashmem.c | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 2 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 6 +++--- drivers/target/tcm_fc/tfc_cmd.c | 2 +- fs/cifs/readdir.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/ext4/extents.c | 6 +++--- fs/ext4/namei.c | 2 +- fs/namei.c | 4 ++-- fs/ncpfs/dir.c | 2 +- fs/nfs/objlayout/objio_osd.c | 2 +- fs/proc/proc_sysctl.c | 2 +- include/linux/blk-cgroup.h | 2 +- include/linux/err.h | 2 +- mm/huge_memory.c | 2 +- net/openvswitch/datapath.c | 2 +- net/sctp/socket.c | 2 +- net/socket.c | 6 +++--- 32 files changed, 47 insertions(+), 47 deletions(-)
Signature · 1 line
2.4.0
PATCH 1/15 err.h: add (missing) unlikely() to IS_ERR_OR_NULL()
IS_ERR_VALUE() already contains it and so we need to add this only to the !ptr check. That will allow users of IS_ERR_OR_NULL(), to not add this compiler flag.
--- include/linux/err.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/err.h +1 -1
@@ -37,7 +37,7 @@ static inline bool __must_check IS_ERR(__force const void *ptr)static inline bool __must_check IS_ERR_OR_NULL (__force const void *ptr) { -return !ptr ||IS_ERR_VALUE ((unsigned long )ptr); +return unlikely (!ptr) ||IS_ERR_VALUE ((unsigned long )ptr); }/**
Signature · 1 line
2.4.0
PATCH 2/15 PM / OPP: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/base/power/opp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/base/power/opp.c +3 -3
@@ -134,7 +134,7 @@ static struct device_opp *_find_device_opp(struct device *dev) {struct device_opp *tmp_dev_opp, *dev_opp =ERR_PTR (-ENODEV ); -if (unlikely (IS_ERR_OR_NULL (dev))) { +if (IS_ERR_OR_NULL (dev)) {pr_err ("%s: Invalid parameters\n" , __func__);return ERR_PTR (-EINVAL ); }
@@ -172,7 +172,7 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)opp_rcu_lockdep_assert (); tmp_opp =rcu_dereference (opp); -if (unlikely (IS_ERR_OR_NULL (tmp_opp)) || !tmp_opp->available) +if (IS_ERR_OR_NULL (tmp_opp) || !tmp_opp->available)pr_err ("%s: Invalid parameters\n" , __func__);else v = tmp_opp->u_volt;
@@ -204,7 +204,7 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)opp_rcu_lockdep_assert (); tmp_opp =rcu_dereference (opp); -if (unlikely (IS_ERR_OR_NULL (tmp_opp)) || !tmp_opp->available) +if (IS_ERR_OR_NULL (tmp_opp) || !tmp_opp->available)pr_err ("%s: Invalid parameters\n" , __func__);else f = tmp_opp->rate;
Signature · 1 line
2.4.0
PATCH 3/15 drivers: devfreq: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/devfreq/devfreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/devfreq/devfreq.c +2 -2
@@ -53,7 +53,7 @@ static struct devfreq *find_device_devfreq(struct device *dev) {struct devfreq *tmp_devfreq; -if (unlikely (IS_ERR_OR_NULL (dev))) { +if (IS_ERR_OR_NULL (dev)) {pr_err ("DEVFREQ: %s: Invalid parameters\n" , __func__);return ERR_PTR (-EINVAL ); }
@@ -133,7 +133,7 @@ static struct devfreq_governor *find_devfreq_governor(const char *name) {struct devfreq_governor *tmp_governor; -if (unlikely (IS_ERR_OR_NULL (name))) { +if (IS_ERR_OR_NULL (name)) {pr_err ("DEVFREQ: %s: Invalid parameters\n" , __func__);return ERR_PTR (-EINVAL ); }
Signature · 1 line
2.4.0
PATCH 4/15 drivers: gpu: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/gpu/drm/ttm/ttm_tt.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/ttm/ttm_tt.c +2 -2
@@ -340,7 +340,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) swap_storage =shmem_file_setup ("ttm swap" , ttm->num_pages <<PAGE_SHIFT ,0 ); -if (unlikely (IS_ERR (swap_storage))) { +if (IS_ERR (swap_storage)) {pr_err ("Failed allocating swap storage\n" );return PTR_ERR (swap_storage); }
@@ -354,7 +354,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)if (unlikely (from_page ==NULL ))continue ; to_page =shmem_read_mapping_page (swap_space, i); -if (unlikely (IS_ERR (to_page))) { +if (IS_ERR (to_page)) { ret =PTR_ERR (to_page); goto out_err; }
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +1 -1
@@ -159,7 +159,7 @@ static int vmw_gb_context_init(struct vmw_private *dev_priv,if (dev_priv->has_mob) { uctx->man =vmw_cmdbuf_res_man_create (dev_priv); -if (unlikely (IS_ERR (uctx->man))) { +if (IS_ERR (uctx->man)) { ret =PTR_ERR (uctx->man); uctx->man =NULL ; goto out_err;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -1
@@ -1054,7 +1054,7 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,return -EINVAL ; vmaster =vmw_master_check (dev, file_priv, flags); -if (unlikely (IS_ERR (vmaster))) { +if (IS_ERR (vmaster)) { ret =PTR_ERR (vmaster);if (ret != -ERESTARTSYS )
Signature · 1 line
2.4.0
Re: [PATCH 04/15] drivers: gpu: Drop unlikely before IS_ERR(_OR_NULL)
This patch: Reviewed-by: Sinclair Yeh <[email protected]>
Quoted 61 lines · Viresh Kumar
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 <[email protected]>--- drivers/gpu/drm/ttm/ttm_tt.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/ttm/ttm_tt.c +2
-2@@ -340,7 +340,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) swap_storage =shmem_file_setup ("ttm swap" , ttm->num_pages <<PAGE_SHIFT ,0 ); -if (unlikely (IS_ERR (swap_storage))) { +if (IS_ERR (swap_storage)) {pr_err ("Failed allocating swap storage\n" );return PTR_ERR (swap_storage); }@@ -354,7 +354,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)if (unlikely (from_page ==NULL ))continue ; to_page =shmem_read_mapping_page (swap_space, i); -if (unlikely (IS_ERR (to_page))) { +if (IS_ERR (to_page)) { ret =PTR_ERR (to_page); goto out_err; }drivers/gpu/drm/vmwgfx/vmwgfx_context.c +1
-1@@ -159,7 +159,7 @@ static int vmw_gb_context_init(struct vmw_private *dev_priv,if (dev_priv->has_mob) { uctx->man =vmw_cmdbuf_res_man_create (dev_priv); -if (unlikely (IS_ERR (uctx->man))) { +if (IS_ERR (uctx->man)) { ret =PTR_ERR (uctx->man); uctx->man =NULL ; goto out_err;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1
-1@@ -1054,7 +1054,7 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,return -EINVAL ; vmaster =vmw_master_check (dev, file_priv, flags); -if (unlikely (IS_ERR (vmaster))) { +if (IS_ERR (vmaster)) { ret =PTR_ERR (vmaster);if (ret != -ERESTARTSYS )Signature · 1 line
2.4.0
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
AppliedRe: [PATCH 04/15] drivers: gpu: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 7 lines · Sinclair Yeh
This patch: Reviewed-by: Sinclair Yeh <[email protected]>
Quoted 4 lines · Viresh Kumar
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 <[email protected]>
Applied to drm-misc, thanks.
-Daniel
Quoted 61 lines
Quoted 57 lines
--- drivers/gpu/drm/ttm/ttm_tt.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/ttm/ttm_tt.c +2
-2@@ -340,7 +340,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) swap_storage =shmem_file_setup ("ttm swap" , ttm->num_pages <<PAGE_SHIFT ,0 ); -if (unlikely (IS_ERR (swap_storage))) { +if (IS_ERR (swap_storage)) {pr_err ("Failed allocating swap storage\n" );return PTR_ERR (swap_storage); }@@ -354,7 +354,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)if (unlikely (from_page ==NULL ))continue ; to_page =shmem_read_mapping_page (swap_space, i); -if (unlikely (IS_ERR (to_page))) { +if (IS_ERR (to_page)) { ret =PTR_ERR (to_page); goto out_err; }drivers/gpu/drm/vmwgfx/vmwgfx_context.c +1
-1@@ -159,7 +159,7 @@ static int vmw_gb_context_init(struct vmw_private *dev_priv,if (dev_priv->has_mob) { uctx->man =vmw_cmdbuf_res_man_create (dev_priv); -if (unlikely (IS_ERR (uctx->man))) { +if (IS_ERR (uctx->man)) { ret =PTR_ERR (uctx->man); uctx->man =NULL ; goto out_err;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1
-1@@ -1054,7 +1054,7 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,return -EINVAL ; vmaster =vmw_master_check (dev, file_priv, flags); -if (unlikely (IS_ERR (vmaster))) { +if (IS_ERR (vmaster)) { ret =PTR_ERR (vmaster);if (ret != -ERESTARTSYS )Signature · 1 line
2.4.0_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/15 drivers: input: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/input/mouse/alps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/alps.c +1 -1
@@ -1365,7 +1365,7 @@ static void alps_report_bare_ps2_packet(struct psmouse *psmouse,/* On V2 devices the DualPoint Stick reports bare packets */ dev = priv->dev2; dev2 = psmouse->dev; - }else if (unlikely (IS_ERR_OR_NULL (priv->dev3))) { + }else if (IS_ERR_OR_NULL (priv->dev3)) {/* Register dev3 mouse if we received PS/2 packet first time */ if (!IS_ERR (priv->dev3)) psmouse_queue_work(psmouse, &priv->dev3_register_work,
Signature · 1 line
2.4.0
Dmitry Torokhov
maintainerRe: [PATCH 05/15] drivers: input: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 2 lines · Viresh Kumar
IS_ERR(_OR_NULL)already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
I'd rather keep it as it documents the expected behavior and double unlikely should work just fine.
Quoted 22 lines
Signed-off-by Viresh Kumar <[email protected]>--- drivers/input/mouse/alps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/input/mouse/alps.c +1
-1@@ -1365,7 +1365,7 @@ static void alps_report_bare_ps2_packet(struct psmouse *psmouse,/* On V2 devices the DualPoint Stick reports bare packets */ dev = priv->dev2; dev2 = psmouse->dev; - }else if (unlikely (IS_ERR_OR_NULL (priv->dev3))) { + }else if (IS_ERR_OR_NULL (priv->dev3)) {/* Register dev3 mouse if we received PS/2 packet first time */ if (!IS_ERR (priv->dev3)) psmouse_queue_work(psmouse, &priv->dev3_register_work,Signature · 1 line
2.4.0
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH 05/15] drivers: input: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 6 lines · Dmitry Torokhov
Quoted 2 lines · Viresh Kumar
IS_ERR(_OR_NULL)already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.I'd rather keep it as it documents the expected behavior and double unlikely should work just fine.
TBH, I don't really agree that it is there for documentation. The only purpose of such compiler flags is to try make code more efficient.
Anyway, I got to this series as someone asked me to fix this for one of my patches which used unlikely(IS_ERR_OR_NULL()). And so I thought about fixing all sites that are doing double unlikely (that shouldn't hurt for sure).
I will leave it to you.
Signature · 1 line
viresh
Re: [PATCH 05/15] drivers: input: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 12 lines · On Saturday 01 August 2015 13:22:51 Viresh Kumar wrote:
Quoted 6 lines · Dmitry Torokhov
Quoted 2 lines · Viresh Kumar
IS_ERR(_OR_NULL)already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.I'd rather keep it as it documents the expected behavior and double unlikely should work just fine.
TBH, I don't really agree that it is there for documentation. The only purpose of such compiler flags is to try make code more efficient.
Quoted 6 lines
Anyway, I got to this series as someone asked me to fix this for one of my patches which used unlikely(IS_ERR_OR_NULL()). And so I thought about fixing all sites that are doing double unlikely (that shouldn't hurt for sure).
I will leave it to you.
I think that unlikely() macro here make code more readable. Yes, it is also for compiler optimization, but also for me it looks like Clean Code pattern <https://de.wikipedia.org/wiki/Clean_Code> -- is not it?
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH 05/15] drivers: input: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 18 lines · Pali Rohár
Quoted 17 lines · On Saturday 01 August 2015 13:22:51 Viresh Kumar wrote:
Quoted 6 lines · Dmitry Torokhov
Quoted 2 lines · Viresh Kumar
IS_ERR(_OR_NULL)already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.I'd rather keep it as it documents the expected behavior and double unlikely should work just fine.
TBH, I don't really agree that it is there for documentation. The only purpose of such compiler flags is to try make code more efficient.
Anyway, I got to this series as someone asked me to fix this for one of my patches which used unlikely(IS_ERR_OR_NULL()). And so I thought about fixing all sites that are doing double unlikely (that shouldn't hurt for sure).
Quoted 5 lines
Quoted 1 line
I will leave it to you.
I think that
unlikely()macro here make code more readable. Yes, it is also for compiler optimization, but also for me it looks like Clean Code pattern <https://de.wikipedia.org/wiki/Clean_Code> -- is not it?
People know that errors are unlikely, no need to tell them. I'd remove it.
Pavel
Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 05/15] drivers: input: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 22 lines · On Sunday 02 August 2015 17:43:52 Pavel Machek wrote:
Quoted 21 lines · Pali Rohár
Quoted 19 lines · On Saturday 01 August 2015 13:22:51 Viresh Kumar wrote:
Quoted 7 lines · Dmitry Torokhov
Quoted 3 lines · Viresh Kumar
IS_ERR(_OR_NULL)already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.I'd rather keep it as it documents the expected behavior and double unlikely should work just fine.
TBH, I don't really agree that it is there for documentation. The only purpose of such compiler flags is to try make code more efficient.
Anyway, I got to this series as someone asked me to fix this for one of my patches which used unlikely(IS_ERR_OR_NULL()). And so I thought about fixing all sites that are doing double unlikely (that shouldn't hurt for sure).
I will leave it to you.
Quoted 8 lines
Quoted 4 lines
I think that
unlikely()macro here make code more readable. Yes, it is also for compiler optimization, but also for me it looks like Clean Code pattern <https://de.wikipedia.org/wiki/Clean_Code> -- is not it?People know that errors are unlikely, no need to tell them. I'd remove it.
Pavel
Errors and bugs are always unlikely ;-)
Signature · 2 lines
Pali Rohár [email protected]
PATCH 6/15 drivers: md: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/md/dm-snap-persistent.c | 2 +- drivers/md/dm-verity.c | 2 +- drivers/md/persistent-data/dm-block-manager.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/md/dm-snap-persistent.c +1 -1
@@ -533,7 +533,7 @@ static int read_exceptions(struct pstore *ps, chunk =area_location (ps, ps->current_area); area =dm_bufio_read (client, chunk, &bp); -if (unlikely (IS_ERR (area))) { +if (IS_ERR (area)) { r =PTR_ERR (area); goto ret_destroy_bufio; }
drivers/md/dm-verity.c +1 -1
@@ -271,7 +271,7 @@ static int verity_verify_level(struct dm_verity_io *io, sector_t block,verity_hash_at_level (v, block, level, &hash_block, &offset); data =dm_bufio_read (v->bufio, hash_block, &buf); -if (unlikely (IS_ERR (data))) +if (IS_ERR (data))return PTR_ERR (data); aux =dm_bufio_get_aux_data (buf);
drivers/md/persistent-data/dm-block-manager.c +4 -4
@@ -454,7 +454,7 @@ int dm_bm_read_lock(struct dm_block_manager *bm, dm_block_t b,int r; p =dm_bufio_read (bm->bufio, b, (struct dm_buffer **) result); -if (unlikely (IS_ERR (p))) +if (IS_ERR (p))return PTR_ERR (p); aux =dm_bufio_get_aux_data (to_buffer (*result));
@@ -490,7 +490,7 @@ int dm_bm_write_lock(struct dm_block_manager *bm,return -EPERM ; p =dm_bufio_read (bm->bufio, b, (struct dm_buffer **) result); -if (unlikely (IS_ERR (p))) +if (IS_ERR (p))return PTR_ERR (p); aux =dm_bufio_get_aux_data (to_buffer (*result));
@@ -523,7 +523,7 @@ int dm_bm_read_try_lock(struct dm_block_manager *bm,int r; p =dm_bufio_get (bm->bufio, b, (struct dm_buffer **) result); -if (unlikely (IS_ERR (p))) +if (IS_ERR (p))return PTR_ERR (p);if (unlikely (!p))return -EWOULDBLOCK ;
@@ -559,7 +559,7 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm,return -EPERM ; p =dm_bufio_new (bm->bufio, b, (struct dm_buffer **) result); -if (unlikely (IS_ERR (p))) +if (IS_ERR (p))return PTR_ERR (p);memset (p,0 ,dm_bm_block_size (bm));
Signature · 1 line
2.4.0
PATCH 7/15 drivers: misc: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/misc/c2port/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/c2port/core.c +1 -1
@@ -926,7 +926,7 @@ struct c2port_device *c2port_device_register(char *name, c2dev->dev =device_create (c2port_class,NULL ,0 , c2dev,"c2port%d" , c2dev->id); -if (unlikely (IS_ERR (c2dev->dev))) { +if (IS_ERR (c2dev->dev)) { ret =PTR_ERR (c2dev->dev); goto error_device_create; }
Signature · 1 line
2.4.0
PATCH 8/15 drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/net/ethernet/ti/netcp_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/netcp_core.c +2 -2
@@ -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;
Signature · 1 line
2.4.0
Re: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 3 lines · Viresh Kumar
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
Quoted 28 lines
Signed-off-by Viresh Kumar <[email protected]>--- drivers/net/ethernet/ti/netcp_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/ti/netcp_core.c +2
-2@@ -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;
Signature · 2 lines
Murali Karicheri Linux Kernel, Keystone
RE: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
From: Murali Karicheri
Quoted 8 lines
Sent: 31 July 2015 16:04
Quoted 3 lines · Viresh Kumar
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
Quoted 7 lines
static inline bool
__must_checkIS_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
Re: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Murali KaricheriQuoted 7 lines · Murali Karicheri
Quoted 3 lines · Viresh Kumar
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
Quoted 7 lines
static inline bool
__must_checkIS_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
Signature · 1 line
viresh
Murali Karicheri
Acked-byRe: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 13 lines · Viresh Kumar
Quoted 12 lines · Murali Karicheri
Quoted 3 lines · Viresh Kumar
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 asstatic inline bool
__must_checkIS_ERR_OR_NULL(__force const void *ptr){ return !ptr || IS_ERR_VALUE((unsigned long)ptr); }
Quoted 7 lines
Quoted 2 lines
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:
Assuming the above change is merged, this patch looks good.
Signature · 2 lines
Murali Karicheri Linux Kernel, Keystone
PATCH 9/15 drivers: rtc: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/rtc/interface.c | 2 +- drivers/rtc/rtc-bfin.c | 2 +- drivers/rtc/rtc-gemini.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/interface.c +1 -1
@@ -564,7 +564,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)void rtc_update_irq (struct rtc_device *rtc,unsigned long num,unsigned long events) { -if (unlikely (IS_ERR_OR_NULL (rtc))) +if (IS_ERR_OR_NULL (rtc))return ;pm_stay_awake (rtc->dev.parent);
drivers/rtc/rtc-bfin.c +1 -1
@@ -361,7 +361,7 @@ static int bfin_rtc_probe(struct platform_device *pdev)/* Register our RTC with the RTC framework */ rtc->rtc_dev =devm_rtc_device_register (dev, pdev->name, &bfin_rtc_ops,THIS_MODULE ); -if (unlikely (IS_ERR (rtc->rtc_dev))) +if (IS_ERR (rtc->rtc_dev))return PTR_ERR (rtc->rtc_dev);/* Grab the IRQ and init the hardware */
drivers/rtc/rtc-gemini.c +1 -1
@@ -148,7 +148,7 @@ static int gemini_rtc_probe(struct platform_device *pdev) rtc->rtc_dev =rtc_device_register (pdev->name, dev, &gemini_rtc_ops,THIS_MODULE ); -if (likely (IS_ERR (rtc->rtc_dev))) +if (IS_ERR (rtc->rtc_dev))return PTR_ERR (rtc->rtc_dev);return 0 ;
Signature · 1 line
2.4.0
PATCH 1/1 drivers: rtc: fix ptr_ret.cocci warnings
From: kbuild test robot <[email protected]>
drivers/rtc/rtc-gemini.c:151:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
Generated by: scripts/coccinelle/api/ptr_ret.cocci
---
Got a cleanup patch from Fengguang, maybe we can apply this too.
rtc-gemini.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/rtc/rtc-gemini.c +1 -4
@@ -148,10 +148,7 @@ static int gemini_rtc_probe(struct platf rtc->rtc_dev =rtc_device_register (pdev->name, dev, &gemini_rtc_ops,THIS_MODULE ); -if (IS_ERR (rtc->rtc_dev)) -return PTR_ERR (rtc->rtc_dev); - -return 0 ; +return PTR_ERR_OR_ZERO (rtc->rtc_dev); }static int gemini_rtc_remove (struct platform_device *pdev)
Alexandre Belloni
AppliedRe: [PATCH] drivers: rtc: fix ptr_ret.cocci warnings
Quoted 9 lines · Viresh Kumar
From: kbuild test robot <[email protected]>
drivers/rtc/rtc-gemini.c:151:1-3: WARNING:
PTR_ERR_OR_ZEROcan be usedUse
PTR_ERR_OR_ZEROrather than if(IS_ERR(...)) +PTR_ERRGenerated by:
scripts/coccinelle/api/ptr_ret.cocci
Quoted 8 lines
Signed-off-by Fengguang Wu <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
Got a cleanup patch from Fengguang, maybe we can apply this too.rtc-gemini.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Applied, thanks.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 9/15 drivers: rtc: Drop (un)likely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
gemini driver was using likely() for a failure case while the rtc driver is getting registered. That looks wrong and it should really be unlikely. But because we are killing all the unlikely() flags, lets kill that too.
---V1->V2:
- Removed the likely() part from gemini driver and the changelog wasn't updated to match that. Fixed the changelog now.
drivers/rtc/interface.c | 2 +- drivers/rtc/rtc-bfin.c | 2 +- drivers/rtc/rtc-gemini.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/interface.c +1 -1
@@ -564,7 +564,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)void rtc_update_irq (struct rtc_device *rtc,unsigned long num,unsigned long events) { -if (unlikely (IS_ERR_OR_NULL (rtc))) +if (IS_ERR_OR_NULL (rtc))return ;pm_stay_awake (rtc->dev.parent);
drivers/rtc/rtc-bfin.c +1 -1
@@ -361,7 +361,7 @@ static int bfin_rtc_probe(struct platform_device *pdev)/* Register our RTC with the RTC framework */ rtc->rtc_dev =devm_rtc_device_register (dev, pdev->name, &bfin_rtc_ops,THIS_MODULE ); -if (unlikely (IS_ERR (rtc->rtc_dev))) +if (IS_ERR (rtc->rtc_dev))return PTR_ERR (rtc->rtc_dev);/* Grab the IRQ and init the hardware */
drivers/rtc/rtc-gemini.c +1 -1
@@ -148,7 +148,7 @@ static int gemini_rtc_probe(struct platform_device *pdev) rtc->rtc_dev =rtc_device_register (pdev->name, dev, &gemini_rtc_ops,THIS_MODULE ); -if (likely (IS_ERR (rtc->rtc_dev))) +if (IS_ERR (rtc->rtc_dev))return PTR_ERR (rtc->rtc_dev);return 0 ;
Signature · 1 line
2.4.0
Re: [PATCH 9/15 V2] drivers: rtc: Drop (un)likely before IS_ERR(_OR_NULL)
Hi
Quoted 62 lines · Viresh Kumar
IS_ERR(_OR_NULL)already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.gemini driver was using
likely()for a failure case while the rtc driver is getting registered. That looks wrong and it should really be unlikely. But because we are killing all theunlikely()flags, lets kill that too.Signed-off-by Viresh Kumar <[email protected]>---
V1->V2:
- Removed thelikely()part from gemini driver and the changelog wasn't updated to match that. Fixed the changelog now.drivers/rtc/interface.c | 2 +- drivers/rtc/rtc-bfin.c | 2 +- drivers/rtc/rtc-gemini.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/rtc/interface.c +1
-1@@ -564,7 +564,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)void rtc_update_irq (struct rtc_device *rtc,unsigned long num,unsigned long events) { -if (unlikely (IS_ERR_OR_NULL (rtc))) +if (IS_ERR_OR_NULL (rtc))return ;pm_stay_awake (rtc->dev.parent);drivers/rtc/rtc-bfin.c +1
-1@@ -361,7 +361,7 @@ static int bfin_rtc_probe(struct platform_device *pdev)/* Register our RTC with the RTC framework */ rtc->rtc_dev =devm_rtc_device_register (dev, pdev->name, &bfin_rtc_ops,THIS_MODULE ); -if (unlikely (IS_ERR (rtc->rtc_dev))) +if (IS_ERR (rtc->rtc_dev))return PTR_ERR (rtc->rtc_dev);/* Grab the IRQ and init the hardware */ drivers/rtc/rtc-gemini.c +1
-1@@ -148,7 +148,7 @@ static int gemini_rtc_probe(struct platform_device *pdev) rtc->rtc_dev =rtc_device_register (pdev->name, dev, &gemini_rtc_ops,THIS_MODULE ); -if (likely (IS_ERR (rtc->rtc_dev))) +if (IS_ERR (rtc->rtc_dev))return PTR_ERR (rtc->rtc_dev);return 0 ;Signature · 1 line
2.4.0
For the mach-gemini part
Alexandre Belloni
AppliedRe: [PATCH 9/15 V2] drivers: rtc: Drop (un)likely before IS_ERR(_OR_NULL)
In reply to Viresh KumarQuoted 14 lines · Viresh Kumar
IS_ERR(_OR_NULL)already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.gemini driver was using
likely()for a failure case while the rtc driver is getting registered. That looks wrong and it should really be unlikely. But because we are killing all theunlikely()flags, lets kill that too.Signed-off-by Viresh Kumar <[email protected]>---
V1->V2:
- Removed thelikely()part from gemini driver and the changelog wasn't updated to match that. Fixed the changelog now.
Quoted 5 lines
drivers/rtc/interface.c | 2 +- drivers/rtc/rtc-bfin.c | 2 +- drivers/rtc/rtc-gemini.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Applied, thanks.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 10/15 drivers: staging: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
This also replaces an IS_ERR(x) + (x == NULL) check to IS_ERR_OR_NULL check.
--- drivers/staging/android/ashmem.c | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 2 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/android/ashmem.c +1 -1
@@ -388,7 +388,7 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)/* ... and allocate the backing shmem file */ vmfile =shmem_file_setup (name, asma->size, vma->vm_flags); -if (unlikely (IS_ERR (vmfile))) { +if (IS_ERR (vmfile)) { ret =PTR_ERR (vmfile); goto out; }
drivers/staging/lustre/include/linux/libcfs/libcfs.h +1 -1
@@ -134,7 +134,7 @@ void cfs_get_random_bytes(void *buf, int size);/* container_of depends on "likely" which is defined in libcfs_private.h */ static inline void *__container_of (void *ptr,unsigned long shift) { -if (unlikely (IS_ERR (ptr) || ptr ==NULL )) +if (IS_ERR_OR_NULL (ptr))return ptr;return (char *)ptr - shift; }
drivers/staging/lustre/lustre/obdclass/lu_object.c +3 -3
@@ -602,7 +602,7 @@ static struct lu_object *lu_object_new(const struct lu_env *env,struct lu_site_bkt_data *bkt; o =lu_object_alloc (env, dev, f, conf); -if (unlikely (IS_ERR (o))) +if (IS_ERR (o))return o; hs = dev->ld_site->ls_obj_hash;
@@ -666,7 +666,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,* operations, including fld queries, inode loading, etc. */ o =lu_object_alloc (env, dev, f, conf); -if (unlikely (IS_ERR (o))) +if (IS_ERR (o))return o;LASSERT (lu_fid_eq (lu_object_fid (o), f));
@@ -1558,7 +1558,7 @@ static int keys_fill(struct lu_context *ctx)LINVRNT (key->lct_index == i); value = key->lct_init (ctx, key); -if (unlikely (IS_ERR (value))) +if (IS_ERR (value))return PTR_ERR (value);if (!(ctx->lc_tags &LCT_NOREF ))
Signature · 1 line
2.4.0
PATCH 11/15 drivers: target: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- drivers/target/tcm_fc/tfc_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/tcm_fc/tfc_cmd.c +1 -1
@@ -255,7 +255,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)struct ft_cmd *cmd = arg;struct fc_frame_header *fh; -if (unlikely (IS_ERR (fp))) { +if (IS_ERR (fp)) {/* XXX need to find cmd if queued */ cmd->seq =NULL ; cmd->aborted = true;
Signature · 1 line
2.4.0
Re: [PATCH 11/15] drivers: target: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 13 lines · Viresh Kumar
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 <[email protected]>--- drivers/target/tcm_fc/tfc_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/target/tcm_fc/tfc_cmd.c +0
-0
drivers/target/tcm_fc/tfc_cmd.c static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) · line 261
Quoted 8 lines
drivers/target/tcm_fc/tfc_cmd.c +1
-1@@ -255,7 +255,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)struct ft_cmd *cmd = arg;struct fc_frame_header *fh; -if (unlikely (IS_ERR (fp))) { +if (IS_ERR (fp)) {/* XXX need to find cmd if queued */ cmd->seq =NULL ; cmd->aborted = true;
Looks fine. Applied to target-pending/for-next.
Thanks Viresh!
PATCH 12/15 fs: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- fs/cifs/readdir.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/ext4/extents.c | 6 +++--- fs/ext4/namei.c | 2 +- fs/namei.c | 4 ++-- fs/ncpfs/dir.c | 2 +- fs/nfs/objlayout/objio_osd.c | 2 +- fs/proc/proc_sysctl.c | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-)
fs/cifs/readdir.c +1 -1
@@ -84,7 +84,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,cifs_dbg (FYI ,"%s: for %s\n" , __func__, name->name); dentry =d_hash_and_lookup (parent, name); -if (unlikely (IS_ERR (dentry))) +if (IS_ERR (dentry))return ;if (dentry) {
fs/ecryptfs/inode.c +1 -1
@@ -270,7 +270,7 @@ ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry, ecryptfs_inode =ecryptfs_do_create (directory_inode, ecryptfs_dentry, mode); -if (unlikely (IS_ERR (ecryptfs_inode))) { +if (IS_ERR (ecryptfs_inode)) {ecryptfs_printk (KERN_WARNING ,"Failed to create file in" "lower filesystem\n" ); rc =PTR_ERR (ecryptfs_inode);
fs/ext4/extents.c +3 -3
@@ -899,7 +899,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block, bh =read_extent_tree_block (inode, path[ppos].p_block, --i, flags); -if (unlikely (IS_ERR (bh))) { +if (IS_ERR (bh)) { ret =PTR_ERR (bh); goto err; }
@@ -5792,7 +5792,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,int split =0 ; path1 =ext4_find_extent (inode1, lblk1,NULL ,EXT4_EX_NOCACHE ); -if (unlikely (IS_ERR (path1))) { +if (IS_ERR (path1)) { *erp =PTR_ERR (path1); path1 =NULL ; finish:
@@ -5800,7 +5800,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1, goto repeat; } path2 =ext4_find_extent (inode2, lblk2,NULL ,EXT4_EX_NOCACHE ); -if (unlikely (IS_ERR (path2))) { +if (IS_ERR (path2)) { *erp =PTR_ERR (path2); path2 =NULL ; goto finish;
fs/ext4/namei.c +1 -1
@@ -1429,7 +1429,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir, } num++; bh =ext4_getblk (NULL , dir, b++,0 ); -if (unlikely (IS_ERR (bh))) { +if (IS_ERR (bh)) {if (ra_max ==0 ) { ret = bh; goto cleanup_and_exit;
fs/namei.c +2 -2
@@ -1942,7 +1942,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)if (err) {const char *s =get_link (nd); -if (unlikely (IS_ERR (s))) +if (IS_ERR (s))return PTR_ERR (s); err =0 ;if (unlikely (!s)) {
@@ -3351,7 +3351,7 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,return ERR_PTR (-ELOOP ); filename =getname_kernel (name); -if (unlikely (IS_ERR (filename))) +if (IS_ERR (filename))return ERR_CAST (filename);set_nameidata (&nd,-1 , filename);
fs/ncpfs/dir.c +1 -1
@@ -597,7 +597,7 @@ ncp_fill_cache(struct file *file, struct dir_context *ctx, qname.name = __name; newdent =d_hash_and_lookup (dentry, &qname); -if (unlikely (IS_ERR (newdent))) +if (IS_ERR (newdent)) goto end_advance;if (!newdent) { newdent =d_alloc (dentry, &qname);
fs/nfs/objlayout/objio_osd.c +1 -1
@@ -124,7 +124,7 @@ objio_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, retry_lookup: od =osduld_info_lookup (&odi); -if (unlikely (IS_ERR (od))) { +if (IS_ERR (od)) { err =PTR_ERR (od);dprintk ("%s: osduld_info_lookup => %d\n" , __func__, err);if (err == -ENODEV && retry_flag) {
fs/proc/proc_sysctl.c +1 -1
@@ -948,7 +948,7 @@ static struct ctl_dir *get_subdir(struct ctl_dir *dir, found: subdir->header.nreg++; failed: -if (unlikely (IS_ERR (subdir))) { +if (IS_ERR (subdir)) {pr_err ("sysctl could not get directory: " );sysctl_print_dir (dir); pr_cont("/%*.*s %ld\n",
Signature · 1 line
2.4.0
Re: [PATCH 12/15] fs: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 4 lines · Viresh Kumar
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 <[email protected]>
PATCH 13/15 blk-cgroup: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- include/linux/blk-cgroup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blk-cgroup.h +1 -1
@@ -374,7 +374,7 @@ static inline struct request_list *blk_get_rl(struct request_queue *q,* root_rl in such cases. */ blkg =blkg_lookup_create (blkcg, q); -if (unlikely (IS_ERR (blkg))) +if (IS_ERR (blkg)) goto root_rl;blkg_get (blkg);
Signature · 1 line
2.4.0
Re: [PATCH 13/15] blk-cgroup: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 4 lines · Viresh Kumar
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 <[email protected]>
Thanks.
Signature · 1 line
tejun
PATCH 14/15 mm: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/huge_memory.c +1 -1
@@ -149,7 +149,7 @@ static int start_stop_khugepaged(void)if (!khugepaged_thread) khugepaged_thread =kthread_run (khugepaged,NULL ,"khugepaged" ); -if (unlikely (IS_ERR (khugepaged_thread))) { +if (IS_ERR (khugepaged_thread)) {pr_err ("khugepaged: kthread_run(khugepaged) failed\n" ); err =PTR_ERR (khugepaged_thread); khugepaged_thread =NULL ;
Signature · 7 lines
2.4.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 14/15] mm: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 4 lines · Viresh Kumar
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 <[email protected]>
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 14/15] mm: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 18 lines · Kirill A. Shutemov
Quoted 4 lines · Viresh Kumar
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 <[email protected]>Signature · 6 lines
Kirill A. Shutemov -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
search in code, there are lots of using like this , does need add this check into checkpatch ?
# grep -r 'likely.*IS_ERR' .
./include/linux/blk-cgroup.h: if (unlikely(IS_ERR(blkg)))
./fs/nfs/objlayout/objio_osd.c: if (unlikely(IS_ERR(od))) {
./fs/cifs/readdir.c: if (unlikely(IS_ERR(dentry)))
./fs/ext4/extents.c: if (unlikely(IS_ERR(bh))) {
./fs/ext4/extents.c: if (unlikely(IS_ERR(path1))) {
./fs/ext4/extents.c: if (unlikely(IS_ERR(path2))) {
./fs/ext4/namei.c: if (unlikely(IS_ERR(bh))) {
./fs/ntfs/lcnalloc.c: if (likely(page && !IS_ERR(page))) {
./fs/ntfs/runlist.c: if (likely(!IS_ERR(old_rl)))
./fs/ntfs/mft.c: if (likely(!IS_ERR(page))) {
./fs/ntfs/mft.c: if (likely(!IS_ERR(m)))
./fs/ntfs/mft.c: if (likely(!IS_ERR(m))) {
./fs/ntfs/mft.c: if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) {
./fs/ntfs/mft.c: if (unlikely(IS_ERR(rl) || !rl->length || rl->lcn < 0)) {
./fs/ntfs/mft.c: if (likely(!IS_ERR(rl2)))
./fs/ntfs/inode.c: if (unlikely(err || IS_ERR(m))) {
./fs/ntfs/namei.c: if (likely(!IS_ERR(dent_inode))) {
./fs/ntfs/super.c: if (unlikely(IS_ERR(tmp_ino) || is_bad_inode(tmp_ino))) {
./fs/namei.c: if (unlikely(IS_ERR(s)))
./fs/namei.c: if (unlikely(IS_ERR(filename)))
./fs/gfs2/dir.c: if (unlikely(dent == NULL || IS_ERR(dent))) {
./fs/ecryptfs/inode.c: if (unlikely(IS_ERR(ecryptfs_inode))) {
./fs/ncpfs/dir.c: if (unlikely(IS_ERR(newdent)))
./fs/proc/proc_sysctl.c: if (unlikely(IS_ERR(subdir))) {
Binary file ./.git/objects/pack/pack-4a5df920db8b8d9df9a91893c9567b4b2f15b782.pack matches
./drivers/target/tcm_fc/tfc_cmd.c: if (unlikely(IS_ERR(fp))) {
./drivers/thermal/intel_powerclamp.c: if (likely(!IS_ERR(thread))) {
./drivers/thermal/intel_powerclamp.c: if (likely(!IS_ERR(thread))) {
./drivers/gpu/drm/vmwgfx/vmwgfx_drv.c: if (unlikely(IS_ERR(vmaster))) {
./drivers/gpu/drm/vmwgfx/vmwgfx_context.c: if (unlikely(IS_ERR(uctx->man))) {
./drivers/gpu/drm/ttm/ttm_tt.c: if (unlikely(IS_ERR(swap_storage))) {
./drivers/gpu/drm/ttm/ttm_tt.c: if (unlikely(IS_ERR(to_page))) {
./drivers/scsi/bnx2fc/bnx2fc_fcoe.c: if (likely(!IS_ERR(thread))) {
./drivers/scsi/bnx2i/bnx2i_init.c: if (likely(!IS_ERR(thread))) {
./drivers/scsi/fcoe/fcoe.c: if (likely(!IS_ERR(thread))) {
./drivers/base/power/opp.c: if (unlikely(IS_ERR_OR_NULL(dev))) {
./drivers/base/power/opp.c: if (unlikely(IS_ERR_OR_NULL(tmp_opp)) || !tmp_opp->available)
./drivers/base/power/opp.c: if (unlikely(IS_ERR_OR_NULL(tmp_opp)) || !tmp_opp->available)
./drivers/tty/serial/serial_core.c: if (likely(!IS_ERR(tty_dev))) {
./drivers/rtc/rtc-bfin.c: if (unlikely(IS_ERR(rtc->rtc_dev)))
./drivers/rtc/rtc-gemini.c: if (likely(IS_ERR(rtc->rtc_dev)))
./drivers/rtc/interface.c: if (unlikely(IS_ERR_OR_NULL(rtc)))
./drivers/md/dm-snap-persistent.c: if (unlikely(IS_ERR(area))) {
./drivers/md/dm-verity.c: if (unlikely(IS_ERR(data)))
./drivers/md/persistent-data/dm-block-manager.c: if (unlikely(IS_ERR(p)))
./drivers/md/persistent-data/dm-block-manager.c: if (unlikely(IS_ERR(p)))
./drivers/md/persistent-data/dm-block-manager.c: if (unlikely(IS_ERR(p)))
./drivers/md/persistent-data/dm-block-manager.c: if (unlikely(IS_ERR(p)))
./drivers/staging/lustre/include/linux/libcfs/libcfs.h: if (unlikely(IS_ERR(ptr) || ptr == NULL))
./drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c: if (likely(!IS_ERR(pfmr))) {
./drivers/staging/lustre/lustre/obdclass/lu_object.c: if (unlikely(IS_ERR(o)))
./drivers/staging/lustre/lustre/obdclass/lu_object.c: if (unlikely(IS_ERR(o)))
./drivers/staging/lustre/lustre/obdclass/lu_object.c: if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
./drivers/staging/lustre/lustre/obdclass/lu_object.c: if (unlikely(IS_ERR(value)))
./drivers/staging/android/ashmem.c: if (unlikely(IS_ERR(vmfile))) {
./drivers/input/mouse/alps.c: } else if (unlikely(IS_ERR_OR_NULL(priv->dev3))) {
./drivers/net/ethernet/marvell/sky2.c: if (unlikely(status & Y2_IS_ERROR))
./drivers/net/ethernet/ti/netcp_core.c: if (unlikely(IS_ERR_OR_NULL(desc))) {
./drivers/net/ethernet/ti/netcp_core.c: if (unlikely(IS_ERR_OR_NULL(ndesc))) {
./drivers/devfreq/devfreq.c: if (unlikely(IS_ERR_OR_NULL(dev))) {
./drivers/devfreq/devfreq.c: if (unlikely(IS_ERR_OR_NULL(name))) {
./drivers/misc/c2port/core.c: if (unlikely(IS_ERR(c2dev->dev))) {
./net/socket.c: if (unlikely(IS_ERR(file))) {
./net/socket.c: if (likely(!IS_ERR(newfile))) {
./net/socket.c: if (unlikely(IS_ERR(newfile1))) {
./net/socket.c: if (unlikely(IS_ERR(newfile))) {
./net/openvswitch/datapath.c: if (unlikely(IS_ERR(reply))) {
./net/openvswitch/datapath.c: if (likely(!IS_ERR(reply))) {
./net/sctp/socket.c: if (unlikely(IS_ERR(newfile))) {
./mm/huge_memory.c: if (unlikely(IS_ERR(khugepaged_thread))) {Thanks
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 14/15] mm: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 4 lines · yalin wang
Quoted 4 lines · Kirill A. Shutemov
On Fri, Jul 31, 2015 at 02:08:34PM +0530, Viresh Kumar wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
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 <[email protected]>search in code, there are lots of using like this , does need add this check into checkpatch ?
cc'd Joe for that. :)
Quoted 7 lines
# grep -r 'likely.*IS_ERR' .
./include/linux/blk-cgroup.h: if (unlikely(IS_ERR(blkg)))
./fs/nfs/objlayout/objio_osd.c: if (unlikely(IS_ERR(od))) {
./fs/cifs/readdir.c: if (unlikely(IS_ERR(dentry)))
./fs/ext4/extents.c: if (unlikely(IS_ERR(bh))) {
./fs/ext4/extents.c: if (unlikely(IS_ERR(path1))) {
./fs/ext4/extents.c: if (unlikely(IS_ERR(path2))) {Btw, my series has fixed all of them :)
Signature · 7 lines
viresh -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 14/15] mm: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 24 lines · Viresh Kumar
Quoted 4 lines · yalin wang
Quoted 4 lines · Kirill A. Shutemov
On Fri, Jul 31, 2015 at 02:08:34PM +0530, Viresh Kumar wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
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 <[email protected]>search in code, there are lots of using like this , does need add this check into checkpatch ?
cc'd Joe for that. :)
Quoted 7 lines
# grep -r 'likely.*IS_ERR' . ./include/linux/blk-cgroup.h: if (unlikely(IS_ERR(blkg))) ./fs/nfs/objlayout/objio_osd.c: if (unlikely(IS_ERR(od))) { ./fs/cifs/readdir.c: if (unlikely(IS_ERR(dentry))) ./fs/ext4/extents.c: if (unlikely(IS_ERR(bh))) { ./fs/ext4/extents.c: if (unlikely(IS_ERR(path1))) { ./fs/ext4/extents.c: if (unlikely(IS_ERR(path2))) {
Quoted 1 line
Btw, my series has fixed all of them :)
If it's all fixed, then it's unlikely to be needed in checkpatch.
But given the unlikely was added when using gcc3.4, I wonder if it's still appropriate to use unlikely in IS_ERR at all.
---
commit b5acea523151452c37cd428437e7576a291dd146
Author: Andrew Morton <[email protected]> Date: Sun Aug 22 23:04:49 2004 -0700
[PATCH] mark IS_ERR as unlikely()
It seems fair to assume that it is always unlikely that IS_ERR will return true.
This patch changes the gcc-3.4-generated kernel text by ~500 bytes (less) so it's fair to assume that the compiler is indeed propagating unlikeliness out of inline functions.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 14/15] mm: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 1 line · Joe Perches
If it's all fixed, then it's unlikely to be needed in checkpatch.
I thought checkpatch is more about not committing new mistakes, rather than finding them in old code.
Signature · 7 lines
viresh -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 14/15] mm: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 5 lines · Viresh Kumar
Quoted 1 line · Joe Perches
If it's all fixed, then it's unlikely to be needed in checkpatch.
I thought checkpatch is more about not committing new mistakes, rather than finding them in old code.
True, but checkpatch is more about style than substance.
There are a lot of things that _could_ be added to the script but don't have to be because of relative rarity.
The unanswered fundamental though is whether the unlikely use in #define IS_ERR_VALUE is useful.
include/linux/err.h:21:#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
How often does using unlikely here make the code smaller/faster with more recent compilers than gcc 3.4? Or even using gcc 3.4.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 14/15] mm: Drop unlikely before IS_ERR(_OR_NULL)
Quoted 12 lines · Joe Perches
Quoted 5 lines · Viresh Kumar
Quoted 1 line · Joe Perches
If it's all fixed, then it's unlikely to be needed in checkpatch.
I thought checkpatch is more about not committing new mistakes, rather than finding them in old code.
True, but checkpatch is more about style than substance.
There are a lot of things that _could_ be added to the script but don't have to be because of relative rarity.
Quoted 7 lines
The unanswered fundamental though is whether the unlikely use in #define
IS_ERR_VALUEis useful.include/linux/err.h:21:#define
IS_ERR_VALUE(x)unlikely((x) >= (unsigned long)-MAX_ERRNO)How often does using unlikely here make the code smaller/faster with more recent compilers than gcc 3.4? Or even using gcc 3.4.
No idea :)
Signature · 7 lines
viresh -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 15/15 net: Drop unlikely before IS_ERR(_OR_NULL)
In reply to Viresh KumarIS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it.
--- net/openvswitch/datapath.c | 2 +- net/sctp/socket.c | 2 +- net/socket.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
net/openvswitch/datapath.c +1 -1
@@ -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; }
net/sctp/socket.c +1 -1
@@ -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);
net/socket.c +3 -3
@@ -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);
Signature · 6 lines
2.4.0 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
Quoted 5 lines · Viresh Kumar
Hi,
This cleans up the usage of IS_ERR(_OR_NULL)(), where the callers have added additional unlikely compiler flag to them. It also fixes the definition of
IS_ERR_OR_NULL(), to use unlikely for all checks it does.
[+CC Steven Rostedt]
Any idea what the compiler does in the case of
"if (likely(IS_ERR(...)))"? There are apparently such cases in the source.
does the "likely" somehow override the "unlikely" of IS_ERR, or is the resulting code a mess?
Vlastimil
Quoted 51 lines
Viresh Kumar (15):
err.h: add (missing)unlikely()toIS_ERR_OR_NULL()PM / OPP: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: devfreq: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: gpu: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: input: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: md: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: misc: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: net: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: rtc: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: staging: Drop unlikely beforeIS_ERR(_OR_NULL)
drivers: target: Drop unlikely beforeIS_ERR(_OR_NULL)
fs: Drop unlikely beforeIS_ERR(_OR_NULL)
blk-cgroup: Drop unlikely beforeIS_ERR(_OR_NULL)
mm: Drop unlikely beforeIS_ERR(_OR_NULL)
net: Drop unlikely beforeIS_ERR(_OR_NULL)drivers/base/power/opp.c | 6 +++--- drivers/devfreq/devfreq.c | 4 ++-- drivers/gpu/drm/ttm/ttm_tt.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- drivers/input/mouse/alps.c | 2 +- drivers/md/dm-snap-persistent.c | 2 +- drivers/md/dm-verity.c | 2 +- drivers/md/persistent-data/dm-block-manager.c | 8 ++++---- drivers/misc/c2port/core.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 4 ++-- drivers/rtc/interface.c | 2 +- drivers/rtc/rtc-bfin.c | 2 +- drivers/rtc/rtc-gemini.c | 2 +- drivers/staging/android/ashmem.c | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 2 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 6 +++--- drivers/target/tcm_fc/tfc_cmd.c | 2 +- fs/cifs/readdir.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/ext4/extents.c | 6 +++--- fs/ext4/namei.c | 2 +- fs/namei.c | 4 ++-- fs/ncpfs/dir.c | 2 +- fs/nfs/objlayout/objio_osd.c | 2 +- fs/proc/proc_sysctl.c | 2 +- include/linux/blk-cgroup.h | 2 +- include/linux/err.h | 2 +- mm/huge_memory.c | 2 +- net/openvswitch/datapath.c | 2 +- net/sctp/socket.c | 2 +- net/socket.c | 6 +++--- 32 files changed, 47 insertions(+), 47 deletions(-)
Quoted 7 lines · Vlastimil Babka
[+CC Steven Rostedt]
Any idea what the compiler does in the case of
"if (likely(IS_ERR(...)))"? There are apparently such cases in the source.does the "likely" somehow override the "unlikely" of
IS_ERR, or is the resulting code a mess?
Good point. While fixing all the sites, I saw some code like that. Then before posting the series, I tried to look at what compilers do to such codes and they generated exactly same code for:
likely(unlikely(x)) and unlikely(x).
So, either those call sites should drop the likely bits or we supply them with another raw version of the macro :)
Or if my tests were wrong, then please lemme know.
Signature · 1 line
viresh
Quoted 11 lines · Vlastimil Babka
Quoted 5 lines · Viresh Kumar
Hi,
This cleans up the usage of IS_ERR(_OR_NULL)(), where the callers have added additional unlikely compiler flag to them. It also fixes the definition of
IS_ERR_OR_NULL(), to use unlikely for all checks it does.[+CC Steven Rostedt]
Any idea what the compiler does in the case of
"if (likely(IS_ERR(...)))"? There are apparently such cases in the source.
We have two cases in code:
drivers/rtc/rtc-gemini.c: if (likely(IS_ERR(rtc->rtc_dev)))drivers/staging/lustre/lustre/obdclass/lu_object.c: if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
The first one is mistake, I think. Or do we expect rtc_device_register() to fail?
The second is redundant. "if (PTR_ERR(shadow) == -ENOENT)" should do the job.
Signature · 1 line
Kirill A. Shutemov
PATCH 1/1 staging: lustre: drop redundant check
There is no need to verify that its an error, as we are anyway going to match the error value to -ENOENT. Drop the redundant check.
--- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/lu_object.c +1 -1
@@ -674,7 +674,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,cfs_hash_bd_lock (hs, &bd,1 ); shadow =htable_lookup (s, &bd, f, waiter, &version); -if (likely (IS_ERR (shadow) &&PTR_ERR (shadow) == -ENOENT )) { +if (likely (PTR_ERR (shadow) == -ENOENT )) {struct lu_site_bkt_data *bkt; bkt =cfs_hash_bd_extra_get (hs, &bd);
Signature · 1 line
2.4.0
Quoted 8 lines · Kirill A. Shutemov
Quoted 7 lines · Vlastimil Babka
Quoted 5 lines · Viresh Kumar
Hi,
This cleans up the usage of IS_ERR(_OR_NULL)(), where the callers have added additional unlikely compiler flag to them. It also fixes the definition of
IS_ERR_OR_NULL(), to use unlikely for all checks it does.
Quoted 8 lines
Quoted 4 lines
[+CC Steven Rostedt]
Any idea what the compiler does in the case of
"if (likely(IS_ERR(...)))"? There are apparently such cases in the source.We have two cases in code:
drivers/rtc/rtc-gemini.c: if (likely(IS_ERR(rtc->rtc_dev)))
This one is already fixed in my series (sent a v2 to fix changelog as well)
Quoted 1 line
drivers/staging/lustre/lustre/obdclass/lu_object.c: if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
And I have sent a patch for this (in reply the your mail).
Signature · 1 line
viresh
Quoted 15 lines · On Fri, 31 Jul 2015 13:23:10 +0300 "Kirill A. Shutemov" <[email protected]>…
Quoted 11 lines · Vlastimil Babka
Quoted 5 lines · Viresh Kumar
Hi,
This cleans up the usage of IS_ERR(_OR_NULL)(), where the callers have added additional unlikely compiler flag to them. It also fixes the definition of
IS_ERR_OR_NULL(), to use unlikely for all checks it does.[+CC Steven Rostedt]
Any idea what the compiler does in the case of
"if (likely(IS_ERR(...)))"? There are apparently such cases in the source.We have two cases in code:
Quoted 9 lines
drivers/rtc/rtc-gemini.c: if (likely(IS_ERR(rtc->rtc_dev)))drivers/staging/lustre/lustre/obdclass/lu_object.c: if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {The first one is mistake, I think. Or do we expect
rtc_device_register()to fail?The second is redundant. "if (
PTR_ERR(shadow)==-ENOENT)" should do the job.
Yep, those look like bugs to me.
-- Steve
Quoted 7 lines · Steven Rostedt
Quoted 5 lines · On Fri, 31 Jul 2015 13:23:10 +0300 "Kirill A. Shutemov" <[email protected]>…
We have two cases in code:
drivers/rtc/rtc-gemini.c: if (likely(IS_ERR(rtc->rtc_dev)))drivers/staging/lustre/lustre/obdclass/lu_object.c: if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
Quoted 8 lines
Quoted 6 lines
The first one is mistake, I think. Or do we expect
rtc_device_register()to fail?The second is redundant. "if (
PTR_ERR(shadow)==-ENOENT)" should do the job.Yep, those look like bugs to me.
Yeah, I have fixed both of them :)
Signature · 1 line
viresh