All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] use BUG_ON correctly
@ 2011-01-26 18:39 Coly Li
  2011-01-26 18:39 ` [PATCH 1/6] mm: use BUG_ON correctly in nommu.c Coly Li
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, Andrew Morton, Greg KH

BUG_ON() already uses unlikely() inside its definition if possible,
therefore code should not use BUG_ON() with explicit unlikely()
like BUG_ON(unlikely(...)), an explicit unlikely() doesn't make
things better.

This patch set fixes all incorrect usage of BUG_ON() as the above
line mentioned.

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/dma/iop-adma.c                           |    6 +++---
 drivers/dma/mv_xor.c                             |    6 +++---
 drivers/dma/ppc4xx/adma.c                        |    8 ++++----
 drivers/scsi/scsi_lib.c                          |    4 ++--
 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c |   14 +++++++-------
 mm/nommu.c                                       |   10 +++++-----
 6 files changed, 24 insertions(+), 24 deletions(-)

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

* [PATCH 1/6] mm: use BUG_ON correctly in nommu.c
  2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
@ 2011-01-26 18:39 ` Coly Li
  2011-01-26 18:39 ` [PATCH 2/6] dma: use BUG_ON correctly in iop-adma.c Coly Li
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, David Howells, Christoph Hellwig, Andrew Morton

This patch makes BUG_ON() usage correct in mm/nommu.c. Since there
are 2 lines even before 2.6.12, I am not able to find out the original
author, Cc Andrew as well.

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 mm/nommu.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/nommu.c b/mm/nommu.c
index f59e142..eccff36 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -534,16 +534,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;
 	}
-- 
1.7.3.2


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

* [PATCH 2/6] dma: use BUG_ON correctly in iop-adma.c
  2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
  2011-01-26 18:39 ` [PATCH 1/6] mm: use BUG_ON correctly in nommu.c Coly Li
@ 2011-01-26 18:39 ` Coly Li
  2011-01-26 18:39 ` [PATCH 3/6] dma: use BUG_ON correctly in mv_xor.c Coly Li
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, Greg KH

This patch mekes BUG_ON() usage correct in drivers/dma/iop-adma.c.

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/dma/iop-adma.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index c6b01f5..e03f811 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -619,7 +619,7 @@ iop_adma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dma_dest,
 
 	if (unlikely(!len))
 		return NULL;
-	BUG_ON(unlikely(len > IOP_ADMA_MAX_BYTE_COUNT));
+	BUG_ON(len > IOP_ADMA_MAX_BYTE_COUNT);
 
 	dev_dbg(iop_chan->device->common.dev, "%s len: %u\n",
 		__func__, len);
@@ -652,7 +652,7 @@ iop_adma_prep_dma_memset(struct dma_chan *chan, dma_addr_t dma_dest,
 
 	if (unlikely(!len))
 		return NULL;
-	BUG_ON(unlikely(len > IOP_ADMA_MAX_BYTE_COUNT));
+	BUG_ON(len > IOP_ADMA_MAX_BYTE_COUNT);
 
 	dev_dbg(iop_chan->device->common.dev, "%s len: %u\n",
 		__func__, len);
@@ -686,7 +686,7 @@ iop_adma_prep_dma_xor(struct dma_chan *chan, dma_addr_t dma_dest,
 
 	if (unlikely(!len))
 		return NULL;
-	BUG_ON(unlikely(len > IOP_ADMA_XOR_MAX_BYTE_COUNT));
+	BUG_ON(len > IOP_ADMA_XOR_MAX_BYTE_COUNT);
 
 	dev_dbg(iop_chan->device->common.dev,
 		"%s src_cnt: %d len: %u flags: %lx\n",
-- 
1.7.3.2


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

* [PATCH 3/6] dma: use BUG_ON correctly in mv_xor.c
  2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
  2011-01-26 18:39 ` [PATCH 1/6] mm: use BUG_ON correctly in nommu.c Coly Li
  2011-01-26 18:39 ` [PATCH 2/6] dma: use BUG_ON correctly in iop-adma.c Coly Li
@ 2011-01-26 18:39 ` Coly Li
  2011-01-26 18:39 ` [PATCH 4/6] dma: use BUG_ON correctly in ppc4xx/adam.c Coly Li
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, Greg KH

This patch mekes BUG_ON() usage correct in drivers/dma/mv_xor.c

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/dma/mv_xor.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index a25f5f6..954e334 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -671,7 +671,7 @@ mv_xor_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
 	if (unlikely(len < MV_XOR_MIN_BYTE_COUNT))
 		return NULL;
 
-	BUG_ON(unlikely(len > MV_XOR_MAX_BYTE_COUNT));
+	BUG_ON(len > MV_XOR_MAX_BYTE_COUNT);
 
 	spin_lock_bh(&mv_chan->lock);
 	slot_cnt = mv_chan_memcpy_slot_count(len);
@@ -710,7 +710,7 @@ mv_xor_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
 	if (unlikely(len < MV_XOR_MIN_BYTE_COUNT))
 		return NULL;
 
-	BUG_ON(unlikely(len > MV_XOR_MAX_BYTE_COUNT));
+	BUG_ON(len > MV_XOR_MAX_BYTE_COUNT);
 
 	spin_lock_bh(&mv_chan->lock);
 	slot_cnt = mv_chan_memset_slot_count(len);
@@ -744,7 +744,7 @@ mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
 	if (unlikely(len < MV_XOR_MIN_BYTE_COUNT))
 		return NULL;
 
-	BUG_ON(unlikely(len > MV_XOR_MAX_BYTE_COUNT));
+	BUG_ON(len > MV_XOR_MAX_BYTE_COUNT);
 
 	dev_dbg(mv_chan->device->common.dev,
 		"%s src_cnt: %d len: dest %x %u flags: %ld\n",
-- 
1.7.3.2


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

* [PATCH 4/6] dma: use BUG_ON correctly in ppc4xx/adam.c
  2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
                   ` (2 preceding siblings ...)
  2011-01-26 18:39 ` [PATCH 3/6] dma: use BUG_ON correctly in mv_xor.c Coly Li
@ 2011-01-26 18:39 ` Coly Li
  2011-01-26 18:39 ` [PATCH 5/6] wl_cfg80211.c: use BUG_ON correctly Coly Li
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, Greg KH

This patch mekes BUG_ON() usage correct in drivers/dma/ppc4xx/adam.c

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/dma/ppc4xx/adma.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index cef5845..a2b62e9 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -2313,7 +2313,7 @@ static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_memcpy(
 	if (unlikely(!len))
 		return NULL;
 
-	BUG_ON(unlikely(len > PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT));
+	BUG_ON(len > PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT);
 
 	spin_lock_bh(&ppc440spe_chan->lock);
 
@@ -2354,7 +2354,7 @@ static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_memset(
 	if (unlikely(!len))
 		return NULL;
 
-	BUG_ON(unlikely(len > PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT));
+	BUG_ON(len > PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT);
 
 	spin_lock_bh(&ppc440spe_chan->lock);
 
@@ -2397,7 +2397,7 @@ static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_xor(
 				     dma_dest, dma_src, src_cnt));
 	if (unlikely(!len))
 		return NULL;
-	BUG_ON(unlikely(len > PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT));
+	BUG_ON(len > PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT);
 
 	dev_dbg(ppc440spe_chan->device->common.dev,
 		"ppc440spe adma%d: %s src_cnt: %d len: %u int_en: %d\n",
@@ -2887,7 +2887,7 @@ static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_pq(
 	ADMA_LL_DBG(prep_dma_pq_dbg(ppc440spe_chan->device->id,
 				    dst, src, src_cnt));
 	BUG_ON(!len);
-	BUG_ON(unlikely(len > PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT));
+	BUG_ON(len > PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT);
 	BUG_ON(!src_cnt);
 
 	if (src_cnt == 1 && dst[1] == src[0]) {
-- 
1.7.3.2


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

* [PATCH 5/6] wl_cfg80211.c: use BUG_ON correctly
  2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
                   ` (3 preceding siblings ...)
  2011-01-26 18:39 ` [PATCH 4/6] dma: use BUG_ON correctly in ppc4xx/adam.c Coly Li
@ 2011-01-26 18:39 ` Coly Li
  2011-01-26 18:39 ` [PATCH 6/6] scsi_lib.c: " Coly Li
  2011-01-27  2:02 ` [PATCH 0/6] " Yong Zhang
  6 siblings, 0 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, Greg KH

This patch removes explicit unlikely() when using BUG_ON() in
wl_cfg80211.c

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c
index 991463f..35124b1 100644
--- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c
@@ -673,7 +673,7 @@ wl_dev_iovar_setbuf(struct net_device *dev, s8 * iovar, void *param,
 	s32 iolen;
 
 	iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
-	BUG_ON(unlikely(!iolen));
+	BUG_ON(!iolen);
 
 	return wl_dev_ioctl(dev, WLC_SET_VAR, bufptr, iolen);
 }
@@ -685,7 +685,7 @@ wl_dev_iovar_getbuf(struct net_device *dev, s8 * iovar, void *param,
 	s32 iolen;
 
 	iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
-	BUG_ON(unlikely(!iolen));
+	BUG_ON(!iolen);
 
 	return wl_dev_ioctl(dev, WLC_GET_VAR, bufptr, buflen);
 }
@@ -704,7 +704,7 @@ wl_run_iscan(struct wl_iscan_ctrl *iscan, struct wlc_ssid *ssid, u16 action)
 	if (unlikely(!params))
 		return -ENOMEM;
 	memset(params, 0, params_size);
-	BUG_ON(unlikely(params_size >= WLC_IOCTL_SMLEN));
+	BUG_ON(params_size >= WLC_IOCTL_SMLEN);
 
 	wl_iscan_prep(&params->params, ssid);
 
@@ -875,7 +875,7 @@ static s32 wl_dev_intvar_set(struct net_device *dev, s8 *name, s32 val)
 
 	val = htod32(val);
 	len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf));
-	BUG_ON(unlikely(!len));
+	BUG_ON(!len);
 
 	err = wl_dev_ioctl(dev, WLC_SET_VAR, buf, len);
 	if (unlikely(err)) {
@@ -899,7 +899,7 @@ wl_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval)
 	len =
 	    bcm_mkiovar(name, (char *)(&data_null), 0, (char *)(&var),
 			sizeof(var.buf));
-	BUG_ON(unlikely(!len));
+	BUG_ON(!len);
 	err = wl_dev_ioctl(dev, WLC_GET_VAR, &var, len);
 	if (unlikely(err)) {
 		WL_ERR("error (%d)\n", err);
@@ -2436,7 +2436,7 @@ wl_dev_bufvar_set(struct net_device *dev, s8 *name, s8 *buf, s32 len)
 	u32 buflen;
 
 	buflen = bcm_mkiovar(name, buf, len, wl->ioctl_buf, WL_IOCTL_LEN_MAX);
-	BUG_ON(unlikely(!buflen));
+	BUG_ON(!buflen);
 
 	return wl_dev_ioctl(dev, WLC_SET_VAR, wl->ioctl_buf, buflen);
 }
@@ -2450,7 +2450,7 @@ wl_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf,
 	s32 err = 0;
 
 	len = bcm_mkiovar(name, NULL, 0, wl->ioctl_buf, WL_IOCTL_LEN_MAX);
-	BUG_ON(unlikely(!len));
+	BUG_ON(!len);
 	err = wl_dev_ioctl(dev, WLC_GET_VAR, (void *)wl->ioctl_buf,
 			WL_IOCTL_LEN_MAX);
 	if (unlikely(err)) {
-- 
1.7.3.2


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

* [PATCH 6/6] scsi_lib.c: use BUG_ON correctly
  2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
                   ` (4 preceding siblings ...)
  2011-01-26 18:39 ` [PATCH 5/6] wl_cfg80211.c: use BUG_ON correctly Coly Li
@ 2011-01-26 18:39 ` Coly Li
  2011-01-27  2:02 ` [PATCH 0/6] " Yong Zhang
  6 siblings, 0 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, Martin K. Petersen, Greg KH

This patch mekes BUG_ON() usage correct in drivers/scsi/scsi_lib.c

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Martin K. Petersen<martin.petersen@oracle.com>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/scsi/scsi_lib.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9045c52..7790a51 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1002,8 +1002,8 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
 
 		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;
-- 
1.7.3.2


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

* Re: [PATCH 0/6] use BUG_ON correctly
  2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
                   ` (5 preceding siblings ...)
  2011-01-26 18:39 ` [PATCH 6/6] scsi_lib.c: " Coly Li
@ 2011-01-27  2:02 ` Yong Zhang
  2011-01-27  6:21   ` Coly Li
  6 siblings, 1 reply; 15+ messages in thread
From: Yong Zhang @ 2011-01-27  2:02 UTC (permalink / raw)
  To: Coly Li; +Cc: linux-kernel, Andrew Morton, Greg KH

On Thu, Jan 27, 2011 at 2:39 AM, Coly Li <bosong.ly@taobao.com> wrote:
> BUG_ON() already uses unlikely() inside its definition if possible,

It's true for asm-generic/bug.h.

But for archs which has defined HAVE_ARCH_BUG,
unlikely() is not always included in it.

Thanks,
Yong

-- 
Only stand for myself

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

* Re: [PATCH 0/6] use BUG_ON correctly
  2011-01-27  6:21   ` Coly Li
@ 2011-01-27  6:07     ` Yong Zhang
  2011-01-27  6:38       ` Coly Li
  0 siblings, 1 reply; 15+ messages in thread
From: Yong Zhang @ 2011-01-27  6:07 UTC (permalink / raw)
  To: i; +Cc: linux-kernel, Andrew Morton, Greg KH

On Thu, Jan 27, 2011 at 2:21 PM, Coly Li <i@coly.li> wrote:
> On 2011年01月27日 10:02, Yong Zhang Wrote:
>>
>> On Thu, Jan 27, 2011 at 2:39 AM, Coly Li<bosong.ly@taobao.com>  wrote:
>>>
>>> BUG_ON() already uses unlikely() inside its definition if possible,
>>
>> It's true for asm-generic/bug.h.
>>
>> But for archs which has defined HAVE_ARCH_BUG,
>> unlikely() is not always included in it.
>>
>
> IMHO, if this condition happens, it should be a bug of the arch
> implementation,

So that means we should fix that first :)

Thanks,
Yong

-- 
Only stand for myself

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

* Re: [PATCH 0/6] use BUG_ON correctly
  2011-01-27  6:38       ` Coly Li
@ 2011-01-27  6:20         ` Yong Zhang
  2011-01-27  7:19           ` Coly Li
  0 siblings, 1 reply; 15+ messages in thread
From: Yong Zhang @ 2011-01-27  6:20 UTC (permalink / raw)
  To: i; +Cc: linux-kernel, Andrew Morton, Greg KH

On Thu, Jan 27, 2011 at 2:38 PM, Coly Li <i@coly.li> wrote:
> On 2011年01月27日 14:07, Yong Zhang Wrote:
>>
>> On Thu, Jan 27, 2011 at 2:21 PM, Coly Li<i@coly.li>  wrote:
>>>
>>> On 2011年01月27日 10:02, Yong Zhang Wrote:
>>>>
>>>> On Thu, Jan 27, 2011 at 2:39 AM, Coly Li<bosong.ly@taobao.com>    wrote:
>>>>>
>>>>> BUG_ON() already uses unlikely() inside its definition if possible,
>>>>
>>>> It's true for asm-generic/bug.h.
>>>>
>>>> But for archs which has defined HAVE_ARCH_BUG,
>>>> unlikely() is not always included in it.
>>>>
>>>
>>> IMHO, if this condition happens, it should be a bug of the arch
>>> implementation,
>>
>> So that means we should fix that first :)
>>
>
> Could you please to identify a piece of kernel code which provides an
> example as the condition you mentioned ?
> So I can have a look firstly.

   #   line  filename / context / line
   1     35  arch/mips/include/asm/bug.h <<HAVE_ARCH_BUG_ON>>
             #define HAVE_ARCH_BUG_ON
   2    115  arch/powerpc/include/asm/bug.h <<HAVE_ARCH_BUG_ON>>
             #define HAVE_ARCH_BUG_ON

Thanks,
Yong


-- 
Only stand for myself

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

* Re: [PATCH 0/6] use BUG_ON correctly
  2011-01-27  2:02 ` [PATCH 0/6] " Yong Zhang
@ 2011-01-27  6:21   ` Coly Li
  2011-01-27  6:07     ` Yong Zhang
  0 siblings, 1 reply; 15+ messages in thread
From: Coly Li @ 2011-01-27  6:21 UTC (permalink / raw)
  To: Yong Zhang; +Cc: linux-kernel, Andrew Morton, Greg KH

On 2011年01月27日 10:02, Yong Zhang Wrote:
> On Thu, Jan 27, 2011 at 2:39 AM, Coly Li<bosong.ly@taobao.com>  wrote:
>> BUG_ON() already uses unlikely() inside its definition if possible,
>
> It's true for asm-generic/bug.h.
>
> But for archs which has defined HAVE_ARCH_BUG,
> unlikely() is not always included in it.
>

IMHO, if this condition happens, it should be a bug of the arch implementation, unless unlikely() is not really supported.

Coly

-- 
Coly Li

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

* Re: [PATCH 0/6] use BUG_ON correctly
  2011-01-27  6:07     ` Yong Zhang
@ 2011-01-27  6:38       ` Coly Li
  2011-01-27  6:20         ` Yong Zhang
  0 siblings, 1 reply; 15+ messages in thread
From: Coly Li @ 2011-01-27  6:38 UTC (permalink / raw)
  To: Yong Zhang; +Cc: linux-kernel, Andrew Morton, Greg KH

On 2011年01月27日 14:07, Yong Zhang Wrote:
> On Thu, Jan 27, 2011 at 2:21 PM, Coly Li<i@coly.li>  wrote:
>> On 2011年01月27日 10:02, Yong Zhang Wrote:
>>>
>>> On Thu, Jan 27, 2011 at 2:39 AM, Coly Li<bosong.ly@taobao.com>    wrote:
>>>>
>>>> BUG_ON() already uses unlikely() inside its definition if possible,
>>>
>>> It's true for asm-generic/bug.h.
>>>
>>> But for archs which has defined HAVE_ARCH_BUG,
>>> unlikely() is not always included in it.
>>>
>>
>> IMHO, if this condition happens, it should be a bug of the arch
>> implementation,
>
> So that means we should fix that first :)
>

Could you please to identify a piece of kernel code which provides an example as the condition you mentioned ?
So I can have a look firstly.

-- 
Coly Li

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

* Re: [PATCH 0/6] use BUG_ON correctly
  2011-01-27  6:20         ` Yong Zhang
@ 2011-01-27  7:19           ` Coly Li
  2011-01-27  7:41             ` WANG Cong
  0 siblings, 1 reply; 15+ messages in thread
From: Coly Li @ 2011-01-27  7:19 UTC (permalink / raw)
  To: Yong Zhang; +Cc: linux-kernel

On 2011年01月27日 14:20, Yong Zhang Wrote:
> On Thu, Jan 27, 2011 at 2:38 PM, Coly Li<i@coly.li>  wrote:
>> On 2011年01月27日 14:07, Yong Zhang Wrote:
>>>
>>> On Thu, Jan 27, 2011 at 2:21 PM, Coly Li<i@coly.li>    wrote:
>>>>
>>>> On 2011年01月27日 10:02, Yong Zhang Wrote:
>>>>>
>>>>> On Thu, Jan 27, 2011 at 2:39 AM, Coly Li<bosong.ly@taobao.com>      wrote:
>>>>>>
>>>>>> BUG_ON() already uses unlikely() inside its definition if possible,
>>>>>
>>>>> It's true for asm-generic/bug.h.
>>>>>
>>>>> But for archs which has defined HAVE_ARCH_BUG,
>>>>> unlikely() is not always included in it.
>>>>>
>>>>
>>>> IMHO, if this condition happens, it should be a bug of the arch
>>>> implementation,
>>>
>>> So that means we should fix that first :)
>>>
>>
>> Could you please to identify a piece of kernel code which provides an
>> example as the condition you mentioned ?
>> So I can have a look firstly.
>
>     #   line  filename / context / line
>     1     35  arch/mips/include/asm/bug.h<<HAVE_ARCH_BUG_ON>>
>               #define HAVE_ARCH_BUG_ON
>     2    115  arch/powerpc/include/asm/bug.h<<HAVE_ARCH_BUG_ON>>
>               #define HAVE_ARCH_BUG_ON

I don't find arch dependent implementation of BUG_ON from the above files. Do I miss something ?

-- 
Coly Li

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

* Re: [PATCH 0/6] use BUG_ON correctly
  2011-01-27  7:19           ` Coly Li
@ 2011-01-27  7:41             ` WANG Cong
  0 siblings, 0 replies; 15+ messages in thread
From: WANG Cong @ 2011-01-27  7:41 UTC (permalink / raw)
  To: linux-kernel

On Thu, 27 Jan 2011 15:19:05 +0800, Coly Li wrote:
>>>>
>>> Could you please to identify a piece of kernel code which provides an
>>> example as the condition you mentioned ? So I can have a look firstly.
>>
>>     #   line  filename / context / line
>>     1     35  arch/mips/include/asm/bug.h<<HAVE_ARCH_BUG_ON>>
>>               #define HAVE_ARCH_BUG_ON
>>     2    115  arch/powerpc/include/asm/bug.h<<HAVE_ARCH_BUG_ON>>
>>               #define HAVE_ARCH_BUG_ON
> 
> I don't find arch dependent implementation of BUG_ON from the above
> files. Do I miss something ?

arch/mips/include/asm/bug.h:

static inline void  __BUG_ON(unsigned long condition)
{
        if (__builtin_constant_p(condition)) {
                if (condition)
                        BUG();
                else
                        return;
        }
        __asm__ __volatile__("tne $0, %0, %1"
                             : : "r" (condition), "i" (BRK_BUG));
}

#define BUG_ON(C) __BUG_ON((unsigned long)(C))

#define HAVE_ARCH_BUG_ON


arch/powerpc/include/asm/bug.h:

#define BUG_ON(x) do {                                          \
        if (__builtin_constant_p(x)) {                          \
                if (x)                                          \
                        BUG();                                  \
        } else {                                                \
                __asm__ __volatile__(                           \
                "1:     "PPC_TLNEI"     %4,0\n"                 \
                _EMIT_BUG_ENTRY                                 \
                : : "i" (__FILE__), "i" (__LINE__), "i" (0),    \
                  "i" (sizeof(struct bug_entry)),               \
                  "r" ((__force long)(x)));                     \
        }                                                       \
} while (0)


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

* [PATCH 0/6] use BUG_ON correctly
@ 2011-01-26 18:54 Coly Li
  0 siblings, 0 replies; 15+ messages in thread
From: Coly Li @ 2011-01-26 18:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: Coly Li, Andrew Morton, Greg KH

BUG_ON() already uses unlikely() inside its definition if possible,
therefore code should not use BUG_ON() with explicit unlikely()
like BUG_ON(unlikely(...)), an explicit unlikely() doesn't make
things better.

This patch set fixes all incorrect usage of BUG_ON() as the above
line mentioned.

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/dma/iop-adma.c                           |    6 +++---
 drivers/dma/mv_xor.c                             |    6 +++---
 drivers/dma/ppc4xx/adma.c                        |    8 ++++----
 drivers/scsi/scsi_lib.c                          |    4 ++--
 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c |   14 +++++++-------
 mm/nommu.c                                       |   10 +++++-----
 6 files changed, 24 insertions(+), 24 deletions(-)

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

end of thread, other threads:[~2011-01-27  7:42 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26 18:39 [PATCH 0/6] use BUG_ON correctly Coly Li
2011-01-26 18:39 ` [PATCH 1/6] mm: use BUG_ON correctly in nommu.c Coly Li
2011-01-26 18:39 ` [PATCH 2/6] dma: use BUG_ON correctly in iop-adma.c Coly Li
2011-01-26 18:39 ` [PATCH 3/6] dma: use BUG_ON correctly in mv_xor.c Coly Li
2011-01-26 18:39 ` [PATCH 4/6] dma: use BUG_ON correctly in ppc4xx/adam.c Coly Li
2011-01-26 18:39 ` [PATCH 5/6] wl_cfg80211.c: use BUG_ON correctly Coly Li
2011-01-26 18:39 ` [PATCH 6/6] scsi_lib.c: " Coly Li
2011-01-27  2:02 ` [PATCH 0/6] " Yong Zhang
2011-01-27  6:21   ` Coly Li
2011-01-27  6:07     ` Yong Zhang
2011-01-27  6:38       ` Coly Li
2011-01-27  6:20         ` Yong Zhang
2011-01-27  7:19           ` Coly Li
2011-01-27  7:41             ` WANG Cong
2011-01-26 18:54 Coly Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.