* [PATCH 1/3] scsi: drop unlikely behind BUG_ON() @ 2015-10-04 6:18 Geliang Tang 2015-10-04 6:18 ` [PATCH 2/3] sched/core: " Geliang Tang 2015-10-04 14:33 ` [PATCH 1/3] scsi: " Bart Van Assche 0 siblings, 2 replies; 10+ messages in thread From: Geliang Tang @ 2015-10-04 6:18 UTC (permalink / raw) To: James E.J. Bottomley; +Cc: Geliang Tang, linux-scsi, linux-kernel BUG_ON() already contain an unlikely compiler flag. Drop it. Signed-off-by: Geliang Tang <geliangtang@163.com> --- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index f570b48..3b5faab 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1164,8 +1164,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; -- 2.5.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] sched/core: drop unlikely behind BUG_ON() 2015-10-04 6:18 [PATCH 1/3] scsi: drop unlikely behind BUG_ON() Geliang Tang @ 2015-10-04 6:18 ` Geliang Tang 2015-10-04 6:18 ` [PATCH 3/3] mm/nommu: " Geliang Tang 2015-10-04 14:33 ` [PATCH 1/3] scsi: " Bart Van Assche 1 sibling, 1 reply; 10+ messages in thread From: Geliang Tang @ 2015-10-04 6:18 UTC (permalink / raw) To: Ingo Molnar, Peter Zijlstra; +Cc: Geliang Tang, linux-kernel BUG_ON() already contain an unlikely compiler flag. Drop it. Signed-off-by: Geliang Tang <geliangtang@163.com> --- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index fe81929..a3518789 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2947,7 +2947,7 @@ static noinline void __schedule_bug(struct task_struct *prev) static inline void schedule_debug(struct task_struct *prev) { #ifdef CONFIG_SCHED_STACK_END_CHECK - BUG_ON(unlikely(task_stack_end_corrupted(prev))); + BUG_ON(task_stack_end_corrupted(prev)); #endif /* * Test if we are atomic. Since do_exit() needs to call into -- 2.5.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] mm/nommu: drop unlikely behind BUG_ON() 2015-10-04 6:18 ` [PATCH 2/3] sched/core: " Geliang Tang @ 2015-10-04 6:18 ` Geliang Tang 2015-10-04 11:02 ` Leon Romanovsky 2015-10-05 1:50 ` Davidlohr Bueso 0 siblings, 2 replies; 10+ messages in thread From: Geliang Tang @ 2015-10-04 6:18 UTC (permalink / raw) To: Andrew Morton, Kirill A. Shutemov, Hugh Dickins, Peter Zijlstra (Intel), Andrea Arcangeli, Davidlohr Bueso, Joonsoo Kim, Arnd Bergmann, Paul Gortmaker, Leon Romanovsky, Oleg Nesterov Cc: Geliang Tang, linux-mm, linux-kernel BUG_ON() already contain an unlikely compiler flag. Drop it. Signed-off-by: Geliang Tang <geliangtang@163.com> --- mm/nommu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/nommu.c b/mm/nommu.c index 1e0f168..92be862 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -578,16 +578,16 @@ static noinline void validate_nommu_regions(void) return; last = rb_entry(lastp, struct vm_region, vm_rb); - BUG_ON(unlikely(last->vm_end <= last->vm_start)); - BUG_ON(unlikely(last->vm_top < last->vm_end)); + BUG_ON(last->vm_end <= last->vm_start); + BUG_ON(last->vm_top < last->vm_end); while ((p = rb_next(lastp))) { region = rb_entry(p, struct vm_region, vm_rb); last = rb_entry(lastp, struct vm_region, vm_rb); - BUG_ON(unlikely(region->vm_end <= region->vm_start)); - BUG_ON(unlikely(region->vm_top < region->vm_end)); - BUG_ON(unlikely(region->vm_start < last->vm_top)); + BUG_ON(region->vm_end <= region->vm_start); + BUG_ON(region->vm_top < region->vm_end); + BUG_ON(region->vm_start < last->vm_top); lastp = p; } -- 2.5.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] mm/nommu: drop unlikely behind BUG_ON() 2015-10-04 6:18 ` [PATCH 3/3] mm/nommu: " Geliang Tang @ 2015-10-04 11:02 ` Leon Romanovsky 2015-10-05 2:04 ` Davidlohr Bueso 2015-10-05 1:50 ` Davidlohr Bueso 1 sibling, 1 reply; 10+ messages in thread From: Leon Romanovsky @ 2015-10-04 11:02 UTC (permalink / raw) To: Geliang Tang Cc: Andrew Morton, Kirill A. Shutemov, Hugh Dickins, Peter Zijlstra (Intel), Andrea Arcangeli, Davidlohr Bueso, Joonsoo Kim, Arnd Bergmann, Paul Gortmaker, Oleg Nesterov, Linux-MM, linux-kernel@vger.kernel.org On Sun, Oct 4, 2015 at 9:18 AM, Geliang Tang <geliangtang@163.com> wrote: > BUG_ON() already contain an unlikely compiler flag. Drop it. It is not the case if CONFIG_BUG and HAVE_ARCH_BUG_ON are not set. > > Signed-off-by: Geliang Tang <geliangtang@163.com> > --- > mm/nommu.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/mm/nommu.c b/mm/nommu.c > index 1e0f168..92be862 100644 > --- a/mm/nommu.c > +++ b/mm/nommu.c > @@ -578,16 +578,16 @@ static noinline void validate_nommu_regions(void) > return; > > last = rb_entry(lastp, struct vm_region, vm_rb); > - BUG_ON(unlikely(last->vm_end <= last->vm_start)); > - BUG_ON(unlikely(last->vm_top < last->vm_end)); > + BUG_ON(last->vm_end <= last->vm_start); > + BUG_ON(last->vm_top < last->vm_end); > > while ((p = rb_next(lastp))) { > region = rb_entry(p, struct vm_region, vm_rb); > last = rb_entry(lastp, struct vm_region, vm_rb); > > - BUG_ON(unlikely(region->vm_end <= region->vm_start)); > - BUG_ON(unlikely(region->vm_top < region->vm_end)); > - BUG_ON(unlikely(region->vm_start < last->vm_top)); > + BUG_ON(region->vm_end <= region->vm_start); > + BUG_ON(region->vm_top < region->vm_end); > + BUG_ON(region->vm_start < last->vm_top); > > lastp = p; > } > -- > 2.5.0 > > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> -- Leon Romanovsky | Independent Linux Consultant www.leon.nu | leon@leon.nu ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] mm/nommu: drop unlikely behind BUG_ON() 2015-10-04 11:02 ` Leon Romanovsky @ 2015-10-05 2:04 ` Davidlohr Bueso 2015-10-05 7:49 ` Leon Romanovsky 0 siblings, 1 reply; 10+ messages in thread From: Davidlohr Bueso @ 2015-10-05 2:04 UTC (permalink / raw) To: Leon Romanovsky Cc: Geliang Tang, Andrew Morton, Kirill A. Shutemov, Hugh Dickins, Peter Zijlstra (Intel), Andrea Arcangeli, Joonsoo Kim, Arnd Bergmann, Paul Gortmaker, Oleg Nesterov, Linux-MM, linux-kernel@vger.kernel.org On Sun, 04 Oct 2015, Leon Romanovsky wrote: >On Sun, Oct 4, 2015 at 9:18 AM, Geliang Tang <geliangtang@163.com> wrote: >> BUG_ON() already contain an unlikely compiler flag. Drop it. >It is not the case if CONFIG_BUG and HAVE_ARCH_BUG_ON are not set. Yeah, but that's like the 1% of the cases -- and those probably don't even care about the branch prediction (I could be wrong). So overall I like getting rid of explicit BUG_ON(unlikely(... calls. In fact there's a _reason_ why there are so few of them in the kernel. Thanks, Davidlohr ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] mm/nommu: drop unlikely behind BUG_ON() 2015-10-05 2:04 ` Davidlohr Bueso @ 2015-10-05 7:49 ` Leon Romanovsky 0 siblings, 0 replies; 10+ messages in thread From: Leon Romanovsky @ 2015-10-05 7:49 UTC (permalink / raw) To: Geliang Tang, Andrew Morton, Kirill A. Shutemov, Hugh Dickins, Peter Zijlstra (Intel), Andrea Arcangeli, Joonsoo Kim, Arnd Bergmann, Paul Gortmaker, Oleg Nesterov, Linux-MM, linux-kernel@vger.kernel.org On Sun, Oct 04, 2015 at 07:04:06PM -0700, Davidlohr Bueso wrote: > On Sun, 04 Oct 2015, Leon Romanovsky wrote: > > >On Sun, Oct 4, 2015 at 9:18 AM, Geliang Tang <geliangtang@163.com> wrote: > >>BUG_ON() already contain an unlikely compiler flag. Drop it. > >It is not the case if CONFIG_BUG and HAVE_ARCH_BUG_ON are not set. > > Yeah, but that's like the 1% of the cases -- and those probably don't even care > about the branch prediction (I could be wrong). So overall I like getting rid of > explicit BUG_ON(unlikely(... calls. In fact there's a _reason_ why there are so > few of them in the kernel. I agree with you that this change is welcomed and I would like to see it is accepted. My main concern that I would expect to see it's coming after the change of BUG_ON definition to be similar in all places, with "unlikely" in all definitions, and not instead. > > Thanks, > Davidlohr ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] mm/nommu: drop unlikely behind BUG_ON() 2015-10-04 6:18 ` [PATCH 3/3] mm/nommu: " Geliang Tang 2015-10-04 11:02 ` Leon Romanovsky @ 2015-10-05 1:50 ` Davidlohr Bueso 2015-10-05 2:30 ` Geliang Tang 1 sibling, 1 reply; 10+ messages in thread From: Davidlohr Bueso @ 2015-10-05 1:50 UTC (permalink / raw) To: Geliang Tang Cc: Andrew Morton, Kirill A. Shutemov, Hugh Dickins, Peter Zijlstra (Intel), Andrea Arcangeli, Joonsoo Kim, Arnd Bergmann, Paul Gortmaker, Leon Romanovsky, Oleg Nesterov, linux-mm, linux-kernel On Sun, 04 Oct 2015, Geliang Tang wrote: >BUG_ON() already contain an unlikely compiler flag. Drop it. > >Signed-off-by: Geliang Tang <geliangtang@163.com> Acked-by: Davidlohr Bueso <dave@stgolabs.net> ... but I believe you do have some left: drivers/scsi/scsi_lib.c: BUG_ON(unlikely(count > ivecs)); drivers/scsi/scsi_lib.c: BUG_ON(unlikely(count > queue_max_integrity_segments(rq->q))); kernel/sched/core.c: BUG_ON(unlikely(task_stack_end_corrupted(prev))); ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] mm/nommu: drop unlikely behind BUG_ON() 2015-10-05 1:50 ` Davidlohr Bueso @ 2015-10-05 2:30 ` Geliang Tang 2015-10-05 3:37 ` Davidlohr Bueso 0 siblings, 1 reply; 10+ messages in thread From: Geliang Tang @ 2015-10-05 2:30 UTC (permalink / raw) To: Davidlohr Bueso Cc: Andrew Morton, Kirill A. Shutemov, Hugh Dickins, Peter Zij lstra (Intel), Andrea Arcangeli, Joonsoo Kim, Arnd Bergmann, Paul Gortmaker, Leon Romanovsky, Oleg Nesterov, linux-mm, linux-kernel On Sun, Oct 04, 2015 at 06:50:55PM -0700, Davidlohr Bueso wrote: > On Sun, 04 Oct 2015, Geliang Tang wrote: > > >BUG_ON() already contain an unlikely compiler flag. Drop it. > > > >Signed-off-by: Geliang Tang <geliangtang@163.com> > > Acked-by: Davidlohr Bueso <dave@stgolabs.net> > > ... but I believe you do have some left: > > drivers/scsi/scsi_lib.c: BUG_ON(unlikely(count > ivecs)); > drivers/scsi/scsi_lib.c: BUG_ON(unlikely(count > queue_max_integrity_segments(rq->q))); > kernel/sched/core.c: BUG_ON(unlikely(task_stack_end_corrupted(prev))); Thanks for your review, the left have been sended out already in two other patches. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] mm/nommu: drop unlikely behind BUG_ON() 2015-10-05 2:30 ` Geliang Tang @ 2015-10-05 3:37 ` Davidlohr Bueso 0 siblings, 0 replies; 10+ messages in thread From: Davidlohr Bueso @ 2015-10-05 3:37 UTC (permalink / raw) To: Geliang Tang Cc: Andrew Morton, Kirill A. Shutemov, Hugh Dickins, Peter Zij lstra (Intel), Andrea Arcangeli, Joonsoo Kim, Arnd Bergmann, Paul Gortmaker, Leon Romanovsky, Oleg Nesterov, linux-mm, linux-kernel On Mon, 05 Oct 2015, Geliang Tang wrote: >On Sun, Oct 04, 2015 at 06:50:55PM -0700, Davidlohr Bueso wrote: >> On Sun, 04 Oct 2015, Geliang Tang wrote: >> >> >BUG_ON() already contain an unlikely compiler flag. Drop it. >> > >> >Signed-off-by: Geliang Tang <geliangtang@163.com> >> >> Acked-by: Davidlohr Bueso <dave@stgolabs.net> >> >> ... but I believe you do have some left: >> >> drivers/scsi/scsi_lib.c: BUG_ON(unlikely(count > ivecs)); >> drivers/scsi/scsi_lib.c: BUG_ON(unlikely(count > queue_max_integrity_segments(rq->q))); >> kernel/sched/core.c: BUG_ON(unlikely(task_stack_end_corrupted(prev))); > >Thanks for your review, the left have been sended out already in two other patches. So given that the 'unlikely' is based on CONFIG_BUG/HAVE_ARCH_BUG_ON, the changelog needs to be rewritten. Ie mentioning at least why it should be ok to drop the redundant predictions: (1) For !CONFIG_BUG cases, the bug call is a no-op, so we couldn't care less and the change is ok. (2) ppc and mips, which HAVE_ARCH_BUG_ON, do not rely on branch predictions as it seems to be pointless[1] and thus callers should not be trying to push an optimization in the first place. Also, I think that all the changes should be in the same patch. Logically, this is a tree wide change, and trivial enough. But I don't really have a preference. Thanks, Davidlohr [1] http://lkml.iu.edu/hypermail/linux/kernel/1101.3/02289.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] scsi: drop unlikely behind BUG_ON() 2015-10-04 6:18 [PATCH 1/3] scsi: drop unlikely behind BUG_ON() Geliang Tang 2015-10-04 6:18 ` [PATCH 2/3] sched/core: " Geliang Tang @ 2015-10-04 14:33 ` Bart Van Assche 1 sibling, 0 replies; 10+ messages in thread From: Bart Van Assche @ 2015-10-04 14:33 UTC (permalink / raw) To: Geliang Tang, James E.J. Bottomley; +Cc: linux-scsi, linux-kernel On 10/03/15 23:18, Geliang Tang wrote: > BUG_ON() already contain an unlikely compiler flag. Drop it. > > Signed-off-by: Geliang Tang <geliangtang@163.com> Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-10-05 7:53 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-04 6:18 [PATCH 1/3] scsi: drop unlikely behind BUG_ON() Geliang Tang 2015-10-04 6:18 ` [PATCH 2/3] sched/core: " Geliang Tang 2015-10-04 6:18 ` [PATCH 3/3] mm/nommu: " Geliang Tang 2015-10-04 11:02 ` Leon Romanovsky 2015-10-05 2:04 ` Davidlohr Bueso 2015-10-05 7:49 ` Leon Romanovsky 2015-10-05 1:50 ` Davidlohr Bueso 2015-10-05 2:30 ` Geliang Tang 2015-10-05 3:37 ` Davidlohr Bueso 2015-10-04 14:33 ` [PATCH 1/3] scsi: " Bart Van Assche
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox