infiniband: nes: add unlikely() to assert()
Subsystems (27)
PATCH 1/23 infiniband: nes: add unlikely() to assert()
In reply to a message not in the archiveTypically the assert is expected to not fail.
--- drivers/infiniband/hw/nes/nes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/nes/nes.h +1 -1
@@ -151,7 +151,7 @@ do { \#define assert (expr) \ do { \ - if (!(expr)) { \ + if (unlikely(!(expr))) { \ printk(KERN_ERR PFX "Assertion failed! %s, %s, %s, line %d\n", \ #expr, __FILE__, __func__, __LINE__); \ } \
Signature · 1 line
2.17.1
PATCH 2/23 ethernet: hnae: add unlikely() to assert()
In reply to a message not in the archiveThe assert() condition is likely to be true.
--- drivers/net/ethernet/hisilicon/hns/hnae.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns/hnae.h +1 -1
@@ -47,7 +47,7 @@#ifndef assert#define assert (expr) \ do { \ - if (!(expr)) { \ + if (unlikely(!(expr))) { \ pr_err("Assertion failed! %s, %s, %s, line %d\n", \ #expr, __FILE__, __func__, __LINE__); \ } \
Signature · 1 line
2.17.1
PATCH 3/23 asm-generic: bug: add unlikely() to BUG_ON()
In reply to a message not in the archiveAdd a hint to the compiler.
If BUG_ON() is used instead of BUG(), it means that probably the preferred outcome is to not BUG().
--- include/asm-generic/bug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/bug.h +1 -1
@@ -183,7 +183,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint,#endif #ifndef HAVE_ARCH_BUG_ON -#define BUG_ON (condition) do { if (condition) BUG(); } while (0) +#define BUG_ON (condition) do { if (unlikely(condition)) BUG(); } while (0)#endif #ifndef HAVE_ARCH_WARN_ON
Signature · 1 line
2.17.1
PATCH 4/23 mips: bug: add unlikely() to BUG_ON()
In reply to a message not in the archiveAdd a hint to the compiler that probably it won't be necessary to BUG()
--- arch/mips/include/asm/bug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/bug.h +1 -1
@@ -31,7 +31,7 @@ static inline void __BUG_ON(unsigned long condition) : : "r" (condition), "i" (BRK_BUG)); } -#define BUG_ON (C ) __BUG_ON((unsigned long)(C)) +#define BUG_ON (C ) __BUG_ON(unlikely((unsigned long)(C)))#define HAVE_ARCH_BUG_ON
Signature · 1 line
2.17.1
PATCH 5/23 selftest: vm: add unlikely() to BUG_ON()
In reply to a message not in the archiveBUG_ON() is unlikely() to BUG()
--- tools/testing/selftests/vm/map_populate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/map_populate.c +1 -1
@@ -23,7 +23,7 @@#define BUG_ON (condition, description) \ do { \ - if (condition) { \ + if (unlikely(condition)) { \ fprintf(stderr, "[FAIL]\t%s:%d\t%s:%s\n", __func__, \ __LINE__, (description), strerror(errno)); \ exit(1); \
Signature · 1 line
2.17.1
PATCH 6/23 virtio: add unlikely() to WARN_ON_ONCE()
In reply to a message not in the archiveThe condition to test is unlikely() to be true. Add the hint.
--- tools/virtio/linux/kernel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtio/linux/kernel.h +1 -1
@@ -123,7 +123,7 @@ static inline void free_page(unsigned long addr)#define dev_err (dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)#define dev_warn (dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__) -#define WARN_ON_ONCE (cond) ((cond) ? fprintf (stderr, "WARNING\n") : 0) +#define WARN_ON_ONCE (cond) (unlikely(cond) ? fprintf (stderr, "WARNING\n") : 0)#define min (x, y) ({ \ typeof(x) _min1 = (x); \
Signature · 1 line
2.17.1
PATCH 7/23 seccomp: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- kernel/seccomp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/seccomp.c +2 -2
@@ -195,7 +195,7 @@ static u32 seccomp_run_filters(const struct seccomp_data *sd,READ_ONCE (current->seccomp.filter);/* Ensure unexpected behavior doesn't result in failing open. */ -if (unlikely (WARN_ON (f ==NULL ))) +if (WARN_ON (f ==NULL ))return SECCOMP_RET_KILL_PROCESS ;if (!sd) {
@@ -297,7 +297,7 @@ static inline pid_t seccomp_can_sync_threads(void)/* Return the first thread that cannot be synchronized. */ failed =task_pid_vnr (thread);/* If the pid cannot be resolved, then return -ESRCH */ -if (unlikely (WARN_ON (failed ==0 ))) +if (WARN_ON (failed ==0 )) failed = -ESRCH ;return failed; }
Signature · 1 line
2.17.1
PATCH 8/23 drm: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_ctl.c | 4 ++-- drivers/gpu/drm/msm/disp/mdp_format.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_ctl.c +2 -2
@@ -261,7 +261,7 @@ int mdp5_ctl_set_cursor(struct mdp5_ctl *ctl, struct mdp5_pipeline *pipeline,u32 blend_cfg;struct mdp5_hw_mixer *mixer = pipeline->mixer; -if (unlikely (WARN_ON (!mixer))) { +if (WARN_ON (!mixer)) {dev_err (ctl_mgr->dev->dev,"CTL %d cannot find LM" , ctl->id);return -EINVAL ;
@@ -703,7 +703,7 @@ struct mdp5_ctl_manager *mdp5_ctlm_init(struct drm_device *dev, goto fail; } -if (unlikely (WARN_ON (ctl_cfg->count >MAX_CTL ))) { +if (WARN_ON (ctl_cfg->count >MAX_CTL )) {dev_err (dev->dev,"Increase static pool size to at least %d\n" , ctl_cfg->count); ret = -ENOSPC ;
drivers/gpu/drm/msm/disp/mdp_format.c +1 -1
@@ -185,7 +185,7 @@ const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format,struct csc_cfg *mdp_get_default_csc_cfg (enum csc_type type) { -if (unlikely (WARN_ON (type >=CSC_MAX ))) +if (WARN_ON (type >=CSC_MAX ))return NULL ;return &csc_convert[type];
Signature · 1 line
2.17.1
PATCH 9/23 cpufreq: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
@@ -403,7 +403,7 @@ EXPORT_SYMBOL_GPL(cpufreq_freq_transition_begin);void cpufreq_freq_transition_end (struct cpufreq_policy *policy,struct cpufreq_freqs *freqs,int transition_failed) { -if (unlikely (WARN_ON (!policy->transition_ongoing))) +if (WARN_ON (!policy->transition_ongoing))return ;cpufreq_notify_post_transition (policy, freqs, transition_failed);
Signature · 1 line
2.17.1
PATCH 10/23 wireless: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON_ONCE() already contains an unlikely(), and the logical or of two of them is still unlikely(), so it's not necessary to wrap them into another.
--- drivers/net/wireless/ath/carl9170/tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/carl9170/tx.c +2 -2
@@ -246,8 +246,8 @@ static void carl9170_release_dev_space(struct ar9170 *ar, struct sk_buff *skb)* of available memory blocks, so the number can * never execeed the mem_blocks count. */ -if (unlikely (WARN_ON_ONCE (cookie ==0 ) || -WARN_ON_ONCE (cookie > ar->fw.mem_blocks))) +if (WARN_ON_ONCE (cookie ==0 ) || +WARN_ON_ONCE (cookie > ar->fw.mem_blocks))return ; atomic_add(DIV_ROUND_UP(skb->len, ar->fw.mem_block_size),
Signature · 1 line
2.17.1
PATCH 11/23 wireless: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON_ONCE() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/net/wireless/ath/ath10k/htt_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +2 -2
@@ -1176,11 +1176,11 @@ static void ath10k_htt_rx_h_undecap_raw(struct ath10k *ar,*/ /* This probably shouldn't happen but warn just in case */ -if (unlikely (WARN_ON_ONCE (!is_first))) +if (WARN_ON_ONCE (!is_first))return ;/* This probably shouldn't happen but warn just in case */ -if (unlikely (WARN_ON_ONCE (!(is_first && is_last)))) +if (WARN_ON_ONCE (!(is_first && is_last)))return ;skb_trim (msdu, msdu->len -FCS_LEN );
Signature · 1 line
2.17.1
PATCH 12/23 wireless: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/net/wireless/broadcom/b43/dma.c | 2 +- drivers/net/wireless/broadcom/b43legacy/dma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/b43/dma.c +1 -1
@@ -1432,7 +1432,7 @@ int b43_dma_tx(struct b43_wldev *dev, struct sk_buff *skb) goto out; } -if (unlikely (WARN_ON (free_slots (ring) <TX_SLOTS_PER_FRAME ))) { +if (WARN_ON (free_slots (ring) <TX_SLOTS_PER_FRAME )) {/* If we get here, we have a real error with the queue * full, but queues not stopped. */ b43err (dev->wl,"DMA queue overflow\n" );
drivers/net/wireless/broadcom/b43legacy/dma.c +1 -1
@@ -1149,7 +1149,7 @@ int b43legacy_dma_tx(struct b43legacy_wldev *dev,return -ENOSPC ; } -if (unlikely (WARN_ON (free_slots (ring) <SLOTS_PER_PACKET ))) { +if (WARN_ON (free_slots (ring) <SLOTS_PER_PACKET )) {/* If we get here, we have a real error with the queue * full, but queues not stopped. */ b43legacyerr (dev->wl,"DMA queue overflow\n" );
Signature · 1 line
2.17.1
PATCH 13/23 freescale: ethernet: remove unnecessary unlikely()
In reply to a message not in the archiveBoth WARN_ON() and WARN_ONCE() already contain an unlikely(), so it's not necessary to wrap it into another.
--- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +3 -5
@@ -1280,7 +1280,7 @@ static int dpaa_bman_release(const struct dpaa_bp *dpaa_bp, err =bman_release (dpaa_bp->pool, bmb, cnt);/* Should never occur, address anyway to avoid leaking the buffers */ -if (unlikely (WARN_ON (err)) && dpaa_bp->free_buf_cb) +if (WARN_ON (err) && dpaa_bp->free_buf_cb)while (cnt-- >0 ) dpaa_bp->free_buf_cb (dpaa_bp, &bmb[cnt]);
@@ -1704,10 +1704,8 @@ static struct sk_buff *contig_fd_to_skb(const struct dpaa_priv *priv, skb =build_skb (vaddr, dpaa_bp->size +SKB_DATA_ALIGN (sizeof (struct skb_shared_info ))); -if (unlikely (!skb)) { -WARN_ONCE (1 ,"Build skb failure on Rx\n" ); +if (WARN_ONCE (!skb,"Build skb failure on Rx\n" )) goto free_buffer; - }WARN_ON (fd_off != priv->rx_headroom);skb_reserve (skb, fd_off);skb_put (skb,qm_fd_get_length (fd));
@@ -1770,7 +1768,7 @@ static struct sk_buff *sg_fd_to_skb(const struct dpaa_priv *priv, sz = dpaa_bp->size +SKB_DATA_ALIGN (sizeof (struct skb_shared_info )); skb =build_skb (sg_vaddr, sz); -if (WARN_ON (unlikely (!skb))) +if (WARN_ON (!skb)) goto free_buffers; skb->ip_summed =rx_csum_offload (priv, fd);
Signature · 1 line
2.17.1
PATCH 14/23 wimax: i2400m: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/net/wimax/i2400m/tx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wimax/i2400m/tx.c +1 -2
@@ -655,8 +655,7 @@ void i2400m_tx_close(struct i2400m *i2400m) padding = aligned_size - tx_msg_moved->size;if (padding >0 ) { pad_buf =i2400m_tx_fifo_push (i2400m, padding,0 ,0 ); -if (unlikely (WARN_ON (pad_buf ==NULL - || pad_buf ==TAIL_FULL ))) { +if (WARN_ON (!pad_buf || pad_buf ==TAIL_FULL )) {/* This should not happen -- append should verify * there is always space left at least to append * tx_block_size */
Signature · 1 line
2.17.1
PATCH 15/23 lvm: device mapper: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/md/dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm.c +1 -1
@@ -1653,7 +1653,7 @@ static blk_qc_t __process_bio(struct mapped_device *md,* Defend against IO still getting in during teardown * - as was seen for a time with nvme-fcloop */ -if (unlikely (WARN_ON_ONCE (!ti || !dm_target_is_valid (ti)))) { +if (WARN_ON_ONCE (!ti || !dm_target_is_valid (ti))) { error = -EIO ; goto out; }
Signature · 1 line
2.17.1
PATCH 16/23 lvm: device mapper: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/md/dm-cache-policy-smq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-cache-policy-smq.c +1 -1
@@ -1200,7 +1200,7 @@ static void queue_demotion(struct smq_policy *mq)struct policy_work work;struct entry *e; -if (unlikely (WARN_ON_ONCE (!mq->migrations_allowed))) +if (WARN_ON_ONCE (!mq->migrations_allowed))return ; e =q_peek (&mq->clean, mq->clean.nr_levels /2 , true);
Signature · 1 line
2.17.1
PATCH 17/23 usb: octeon-hcd: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/staging/octeon-usb/octeon-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/octeon-usb/octeon-hcd.c +1 -1
@@ -2768,7 +2768,7 @@ static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel) (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)) pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING; -if (unlikely (WARN_ON_ONCE (bytes_this_transfer <0 ))) { +if (WARN_ON_ONCE (bytes_this_transfer <0 )) {/* * In some rare cases the DMA engine seems to get stuck and * keeps substracting same byte count over and over again. In
Signature · 1 line
2.17.1
PATCH 18/23 infiniband: scsi: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -1
@@ -2708,7 +2708,7 @@ static void srpt_queue_response(struct se_cmd *cmd)break ; } -if (unlikely (WARN_ON_ONCE (state ==SRPT_STATE_CMD_RSP_SENT ))) +if (WARN_ON_ONCE (state ==SRPT_STATE_CMD_RSP_SENT ))return ;/* For read commands, transfer the data to the initiator. */
Signature · 1 line
2.17.1
PATCH 19/23 pinctrl: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- drivers/pinctrl/aspeed/pinctrl-aspeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/aspeed/pinctrl-aspeed.c +1 -1
@@ -715,7 +715,7 @@ int aspeed_pin_config_set(struct pinctrl_dev *pctldev, unsigned int offset, pmap =find_pinconf_map (param,MAP_TYPE_ARG , arg); -if (unlikely (WARN_ON (!pmap))) +if (WARN_ON (!pmap))return -EINVAL ; val = pmap->val << pconf->bit;
Signature · 1 line
2.17.1
PATCH 20/23 mm: percpu: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- mm/percpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu.c +1 -1
@@ -2588,7 +2588,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,BUG_ON (ai->nr_groups !=1 ); upa = ai->alloc_size/ai->unit_size; nr_g0_units =roundup (num_possible_cpus (), upa); -if (unlikely (WARN_ON (ai->groups[0 ].nr_units != nr_g0_units))) { +if (WARN_ON (ai->groups[0 ].nr_units != nr_g0_units)) {pcpu_free_alloc_info (ai);return -EINVAL ; }
Signature · 1 line
2.17.1
PATCH 21/23 filesystems: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- fs/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/open.c +1 -1
@@ -750,7 +750,7 @@ static int do_dentry_open(struct file *f, f->f_mode |=FMODE_ATOMIC_POS ; f->f_op =fops_get (inode->i_fop); -if (unlikely (WARN_ON (!f->f_op))) { +if (WARN_ON (!f->f_op)) { error = -ENODEV ; goto cleanup_all; }
Signature · 1 line
2.17.1
PATCH 22/23 powerpc: remove unnecessary unlikely()
In reply to a message not in the archiveWARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.
--- arch/powerpc/mm/tlb_nohash.c | 2 +- arch/powerpc/sysdev/xive/common.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/tlb_nohash.c +1 -1
@@ -302,7 +302,7 @@ void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,* This function as well as __local_flush_tlb_page() must only be called * for user contexts. */ -if (unlikely (WARN_ON (!mm))) +if (WARN_ON (!mm))return ;preempt_disable ();
arch/powerpc/sysdev/xive/common.c +1 -1
@@ -442,7 +442,7 @@ static void xive_dec_target_count(int cpu)struct xive_cpu *xc =per_cpu (xive_cpu, cpu);struct xive_q *q = &xc->queue[xive_irq_priority]; -if (unlikely (WARN_ON (cpu <0 || !xc))) { +if (WARN_ON (cpu <0 || !xc)) {pr_err ("%s: cpu=%d xc=%p\n" , __func__, cpu, xc);return ; }
Signature · 1 line
2.17.1
PATCH 23/23 scsi: remove unnecessary unlikely()
In reply to a message not in the archiveBUG_ON() already contains an unlikely(), there is no need for another one.
--- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +2 -2
@@ -1207,8 +1207,8 @@ int scsi_init_io(struct scsi_cmnd *cmd) count =blk_rq_map_integrity_sg (rq->q, rq->bio, prot_sdb->table.sgl); -BUG_ON (unlikely (count > ivecs)); -BUG_ON (unlikely (count >queue_max_integrity_segments (rq->q))); +BUG_ON (count > ivecs); +BUG_ON (count >queue_max_integrity_segments (rq->q)); cmd->prot_sdb = prot_sdb; cmd->prot_sdb->table.nents = count;
Signature · 1 line
2.17.1
Re: [PATCH 18/23] infiniband: scsi: remove unnecessary unlikely()
In reply to Igor StoppaQuoted 3 lines · Igor Stoppa
WARN_ON()already contains anunlikely(), so it's not necessary to wrap it into another.
Re: [PATCH 05/23] selftest: vm: add unlikely() to BUG_ON()
In reply to Igor StoppaHi Igor,
Quoted 1 line · Igor Stoppa
BUG_ON()isunlikely()toBUG()
This selftest runs in userspace..
So, we should define the macro somehow, as i.e:
rseq/rseq.h:#define rseq_unlikely(x) __builtin_expect(!!(x), 0)
Otherwise,
[selftests]$ make vm/map_populate
cc vm/map_populate.c -o vm/map_populatevm/map_populate.c: In function ‘parent_f’:vm/map_populate.c:26:7: warning: implicit declaration of function ‘unlikely’; did you mean ‘unlinkat’? [-Wimplicit-function-declaration]
if (unlikely(condition)) { \
^vm/map_populate.c:38:2: note: in expansion of macro ‘BUG_ON’
BUG_ON(ret <= 0, "read(sock)");
^~~~~~/tmp/cc7evGVG.o: In function `parent_f':
map_populate.c:(.text+0x3d): undefined reference to unlikely' map_populate.c:(.text+0xbb): undefined reference to unlikely' map_populate.c:(.text+0x135): undefined reference to unlikely' map_populate.c:(.text+0x1b0): undefined reference to unlikely'
Not sure if we care for this at all for userspace test.
I don't mind as it runs each time by kbuild robot and cumulatively may save something. But it's better be at least compile-tested.
Signature · 1 line
Dima
Re: [PATCH 05/23] selftest: vm: add unlikely() to BUG_ON()
Quoted 27 lines · Dmitry Safonov
Hi Igor,
Quoted 1 line · Igor Stoppa
BUG_ON()isunlikely()toBUG()This selftest runs in userspace..
So, we should define the macro somehow, as i.e:
rseq/rseq.h:#definerseq_unlikely(x)__builtin_expect(!!(x), 0)Otherwise,
[selftests]$ make vm/map_populate
ccvm/map_populate.c-o vm/map_populatevm/map_populate.c: In function ‘parent_f’:vm/map_populate.c:26:7: warning: implicit declaration of function ‘unlikely’; did you mean ‘unlinkat’? [-Wimplicit-function- declaration]if (unlikely(condition)) { \ ^
vm/map_populate.c:38:2: note: in expansion of macro ‘BUG_ON’
BUG_ON(ret <= 0, "read(sock)");
^~~~~~/tmp/cc7evGVG.o: In function `parent_f':
map_populate.c:(.text+0x3d): undefined reference tounlikely' map_populate.c:(.text+0xbb): undefined reference tounlikely' map_populate.c:(.text+0x135): undefined reference tounlikely' map_populate.c:(.text+0x1b0): undefined reference tounlikely'
Quoted 4 lines
Not sure if we care for this at all for userspace test. I don't mind as it runs each time by kbuild robot and cumulatively may
save something. But it's better be at least compile-tested.
JFI, there are a plenty of definitions for unlikely():
[linux]$ git grep 'define unlikely' tools +rseq_unlikely() from tools/testing/selftests/rseq/rseq.h
Probably, the one from "tools/include/linux/compiler.h" can be used in tools directory.
Signature · 1 line
Dima
Re: [PATCH 20/23] mm: percpu: remove unnecessary unlikely()
In reply to Igor StoppaQuoted 28 lines · Igor Stoppa
WARN_ON()already contains anunlikely(), so it's not necessary to wrap it into another.Signed-off-by Igor Stoppa <[email protected]>Cc zijun_hu <[email protected]>Cc Tejun Heo <[email protected]>Cc Christoph Lameter <[email protected]>Cc Dennis Zhou <[email protected]>--- mm/percpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/percpu.c +1
-1@@ -2588,7 +2588,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,BUG_ON (ai->nr_groups !=1 ); upa = ai->alloc_size/ai->unit_size; nr_g0_units =roundup (num_possible_cpus (), upa); -if (unlikely (WARN_ON (ai->groups[0 ].nr_units != nr_g0_units))) { +if (WARN_ON (ai->groups[0 ].nr_units != nr_g0_units)) {pcpu_free_alloc_info (ai);return -EINVAL ; }Signature · 1 line
2.17.1
Thanks,
Dennis
Re: [PATCH 19/23] pinctrl: remove unnecessary unlikely()
In reply to Igor StoppaQuoted 6 lines · Igor Stoppa
WARN_ON()already contains anunlikely(), so it's not necessary to wrap it into another.Signed-off-by Igor Stoppa <[email protected]>Cc Andrew Jeffery <[email protected]>Cc Linus Walleij <[email protected]>
Patch applied as obviously correct.
Yours,
Linus Walleij
Re: [PATCH 10/23] wireless: remove unnecessary unlikely()
In reply to Igor Stoppa+ linux-wireless
Quoted 6 lines · Igor Stoppa
WARN_ON_ONCE()already contains anunlikely(), and the logical or of two of them is stillunlikely(), so it's not necessary to wrap them into another.Signed-off-by Igor Stoppa <[email protected]>Cc Christian Lamparter <[email protected]>Cc Kalle Valo <[email protected]>
IMHO you could fold patches 10, 11 and 12 into one to avoid having three patches with duplicate titles. Or alternatively use proper driver prefixes like "ath10k:", "b43:" and so on.
But how do you want these to be applied? For the wireless patches you didn't Cc linux-wireless so our patchwork won't see them and hence I can't take them. So if you want me to take these, please resend and include linux-wireless.
Signature · 1 line
Kalle Valo
Re: [PATCH 10/23] wireless: remove unnecessary unlikely()
Quoted 5 lines · Kalle Valo
+ linux-wireless
IMHO you could fold patches 10, 11 and 12 into one to avoid having three patches with duplicate titles. Or alternatively use proper driver prefixes like "ath10k:", "b43:" and so on.
I was wondering if it would be ok to fold them, but it's easier to fold than to split, so I started with 3
Quoted 4 lines
But how do you want these to be applied? For the wireless patches you didn't Cc linux-wireless so our patchwork won't see them and hence I can't take them. So if you want me to take these, please resend and include linux-wireless.
ok, I was hoping to avoid joining the ml but it's done
I had patches for about 20 different trees, so I decided to first see if the patches could be taken in right away. In at least one case (pinctrl) I got lucky :-)
--
thanks, igor
Quoted 8 lines · Igor Stoppa
Typically the assert is expected to not fail.
Signed-off-by Igor Stoppa <[email protected]>Cc Chien Tung <[email protected]>Cc Roland Dreier <[email protected]>Cc Faisal Latif <[email protected]>Cc Doug Ledford <[email protected]>Cc Jason Gunthorpe <[email protected]>
Quoted 17 lines
--- drivers/infiniband/hw/nes/nes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/nes/nes.h +1
-1@@ -151,7 +151,7 @@ do { \#define assert (expr) \ do { \ - if (!(expr)) { \ + if (unlikely(!(expr))) { \ printk(KERN_ERR PFX "Assertion failed! %s, %s, %s, line %d\n", \ #expr, __FILE__, __func__, __LINE__); \ } \
Signature · 3 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
Arnd Bergmann
maintainerRe: [PATCH 00/23] Make use of unlikely() more consistently.
In reply to a message not in the archiveQuoted 12 lines · Igor Stoppa
In some cases, checks that are expected to not fail, do not take advantage of specifying that the condition being tested is
unlikely().Ex:
#define assert(condition)
...if (!(condition)) error_action()...
Quoted 7 lines
should be
#define assert(condition)
...if (unlikely(!(condition))) error_action()...
There is a potential that this introduces false-postive -Wmaybe-uninitialized warnings when CONFIG_PROFILE_ANNOTATED_BRANCHES is
set, since that turns unlikely() into a complex operation that in turn confuses the compiler so it no longer keeps track of which variables are initialized or not.
It's possible that none of your patches do that, but one needs to be aware of the problem, and possibly revert some of your patches if it does cause warning regressions in drivers that don't actually benefit from the micro-optimization.
Quoted 7 lines
In other cases, the hint is given twice: once explicitly and once inside whatever test is being performed:
assert(),BUG_ON(),WARN_ON(), etc.Ex:
if (
unlikely(WARN_ON(condition, message)))
...
Removing those is definitely fine.
Arnd
Re: [PATCH 00/23] Make use of unlikely() more consistently.
On 31/08/18 17:09, Arnd Bergmann wrote:
[...]
Quoted 12 lines
Quoted 5 lines
#define assert(condition)
...if (unlikely(!(condition))) error_action()...
There is a potential that this introduces false-postive -Wmaybe-uninitialized warnings when
CONFIG_PROFILE_ANNOTATED_BRANCHESis
set, since that turnsunlikely()into a complex operation that in turn confuses the compiler so it no longer keeps track of which variables are initialized or not.
Quoted 4 lines
It's possible that none of your patches do that, but one needs to be aware of the problem, and possibly revert some of your patches if it does cause warning regressions in drivers that don't actually benefit from the micro-optimization.
I see.
But if such case might arise, it might be possible, instead of reverting these patches, to locally - and conditionally - turn unlikely() into an identity macro.
For example:
#ifdef CONFIG_PROFILE_ANNOTATOED_BRANCHES
#define unlikely(x) (x)
#endif
Without giving up the hint for the case of normal compilation.
--
igor
Re: [PATCH 05/23] selftest: vm: add unlikely() to BUG_ON()
In reply to Dmitry SafonovHi Dmitry,
Quoted 2 lines · Dmitry Safonov
Probably, the one from "
tools/include/linux/compiler.h" can be used in tools directory.
Thank you for the advice. It seems to work now.
--
igor
Re: [PATCH 07/23] seccomp: remove unnecessary unlikely()
In reply to Igor StoppaQuoted 5 lines · Igor Stoppa
WARN_ON()already contains anunlikely(), so it's not necessary to wrap it into another.Signed-off-by Igor Stoppa <[email protected]>Cc Kees Cook <[email protected]>
-Kees
Quoted 29 lines
--- kernel/seccomp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/seccomp.c +2
-3@@ -195,7 +195,7 @@ static u32 seccomp_run_filters(const struct seccomp_data *sd,READ_ONCE (current->seccomp.filter);/* Ensure unexpected behavior doesn't result in failing open. */ -if (unlikely (WARN_ON (f ==NULL ))) +if (WARN_ON (f ==NULL ))return SECCOMP_RET_KILL_PROCESS ;if (!sd) {@@ -297,7 +297,7 @@ static inline pid_t seccomp_can_sync_threads(void)/* Return the first thread that cannot be synchronized. */ failed =task_pid_vnr (thread);/* If the pid cannot be resolved, then return -ESRCH */ -if (unlikely (WARN_ON (failed ==0 ))) +if (WARN_ON (failed ==0 )) failed = -ESRCH ;return failed; } --2.17.1
Signature · 2 lines
Kees Cook Pixel Security