2009-07-12 11:13:28

by Rakib Mullick

[permalink] [raw]
Subject: [PATCH] block: Mark virtio_blk with __refdata in virtio_blk.c

Impact: Fix false positive warning.

The variable virtio_blk references the function virtblk_probe() (which
is in .devinit section) and also references the function
virtblk_remove() ( which is in .devexit section). So, virtio_blk
simultaneously refers .devinit and .devexit section. To avoid this
messup, we mark virtio_blk as __refdata.

We were warned by the following warning:

LD drivers/block/built-in.o
WARNING: drivers/block/built-in.o(.data+0xc8dc): Section mismatch in
reference from the variable virtio_blk to the function
.devinit.text:virtblk_probe()
The variable virtio_blk references
the function __devinit virtblk_probe()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,

WARNING: drivers/block/built-in.o(.data+0xc8e0): Section mismatch in
reference from the variable virtio_blk to the function
.devexit.text:virtblk_remove()
The variable virtio_blk references
the function __devexit virtblk_remove()
If the reference is valid then annotate the
variable with __exit* (see linux/init.h) or name the variable:
*driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,

---
Signed-off-by: Rakib Mullick <[email protected]>

--- linus/drivers/block/virtio_blk.c 2009-07-10 12:30:16.000000000 +0600
+++ rakib/drivers/block/virtio_blk.c 2009-07-12 11:44:43.000000000 +0600
@@ -424,7 +424,8 @@ static unsigned int features[] = {
VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_IDENTIFY
};

-static struct virtio_driver virtio_blk = {
+/* We were warned by false positive warning, so __refdata comes into rescue. */
+static struct virtio_driver __refdata virtio_blk = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name = KBUILD_MODNAME,


2009-07-17 06:00:22

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH] block: Mark virtio_blk with __refdata in virtio_blk.c

Hello,

Rakib Mullick wrote:
> Impact: Fix false positive warning.
>
> The variable virtio_blk references the function virtblk_probe() (which
> is in .devinit section) and also references the function
> virtblk_remove() ( which is in .devexit section). So, virtio_blk
> simultaneously refers .devinit and .devexit section. To avoid this
> messup, we mark virtio_blk as __refdata.
>
> We were warned by the following warning:
>
> LD drivers/block/built-in.o
> WARNING: drivers/block/built-in.o(.data+0xc8dc): Section mismatch in
> reference from the variable virtio_blk to the function
> .devinit.text:virtblk_probe()
> The variable virtio_blk references
> the function __devinit virtblk_probe()
> If the reference is valid then annotate the
> variable with __init* or __refdata (see linux/init.h) or name the variable:
> *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,
>
> WARNING: drivers/block/built-in.o(.data+0xc8e0): Section mismatch in
> reference from the variable virtio_blk to the function
> .devexit.text:virtblk_remove()
> The variable virtio_blk references
> the function __devexit virtblk_remove()
> If the reference is valid then annotate the
> variable with __exit* (see linux/init.h) or name the variable:
> *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,
> Signed-off-by: Rakib Mullick <[email protected]>

Generally looks good to me.

> +/* We were warned by false positive warning, so __refdata comes into rescue. */
> +static struct virtio_driver __refdata virtio_blk = {

But it would be nicer if the comment contains a bit more of detail.
Can you please beef it up a bit? After that I'll queue it in my temp
tree and send to Linus' way.

Thanks.

--
tejun

2009-07-17 14:13:28

by Rakib Mullick

[permalink] [raw]
Subject: Re: [PATCH] block: Mark virtio_blk with __refdata in virtio_blk.c

On 7/17/09, Tejun Heo <[email protected]> wrote:
> Hello,
>
> Generally looks good to me.
>
>
> > +/* We were warned by false positive warning, so __refdata comes into rescue. */
> > +static struct virtio_driver __refdata virtio_blk = {
>
>
> But it would be nicer if the comment contains a bit more of detail.
> Can you please beef it up a bit? After that I'll queue it in my temp
> tree and send to Linus' way.
>
Ok. Assuming that changelog is ok. I'm just sending the patch here
with a beefed up comment. Hopefully everyone will like it. If not or
if requires resend please notice.

Thanks,

----
Signed-off-by: Rakib Mullick <[email protected]>

--- linus/drivers/block/virtio_blk.c 2009-07-17 21:07:40.000000000 +0600
+++ rakib/drivers/block/virtio_blk.c 2009-07-17 21:14:36.000000000 +0600
@@ -424,7 +424,13 @@ static unsigned int features[] = {
VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_IDENTIFY
};

-static struct virtio_driver virtio_blk = {
+/*
+ * virtio_blk messes up by simultaneously refering to a __devinit and
+ * a __devexit function. Which causes a false positive warning. So we
+ * use __refdata to avoid this warning.
+ */
+
+static struct virtio_driver __refdata virtio_blk = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name = KBUILD_MODNAME,

2009-07-19 01:49:13

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH] block: Mark virtio_blk with __refdata in virtio_blk.c

I slightly massaged the commit message and comment and committed it to
#tj-block-for-linus. Will push it out in a few days.

Thanks.

>From 4fbfff76079a5c0e1751b0ddf53160d33f7831e7 Mon Sep 17 00:00:00 2001
From: Rakib Mullick <[email protected]>
Date: Fri, 17 Jul 2009 20:13:22 +0600
Subject: [PATCH] virtio_blk: mark virtio_blk with __refdata to kill spurious section mismatch

The variable virtio_blk references the function virtblk_probe() (which
is in .devinit section) and also references the function
virtblk_remove() ( which is in .devexit section). So, virtio_blk
simultaneously refers .devinit and .devexit section. To avoid this
messup, we mark virtio_blk as __refdata.

We were warned by the following warning:

LD drivers/block/built-in.o
WARNING: drivers/block/built-in.o(.data+0xc8dc): Section mismatch in
reference from the variable virtio_blk to the function
.devinit.text:virtblk_probe()
The variable virtio_blk references
the function __devinit virtblk_probe()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,

WARNING: drivers/block/built-in.o(.data+0xc8e0): Section mismatch in
reference from the variable virtio_blk to the function
.devexit.text:virtblk_remove()
The variable virtio_blk references
the function __devexit virtblk_remove()
If the reference is valid then annotate the
variable with __exit* (see linux/init.h) or name the variable:
*driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,

Signed-off-by: Rakib Mullick <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
---
drivers/block/virtio_blk.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 43db3ea..024f2d2 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -424,7 +424,12 @@ static unsigned int features[] = {
VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_IDENTIFY
};

-static struct virtio_driver virtio_blk = {
+/*
+ * virtio_blk causes spurious section mismatch warning by
+ * simultaneously referring to a __devinit and a __devexit function.
+ * Use __refdata to avoid this warning.
+ */
+static struct virtio_driver __refdata virtio_blk = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name = KBUILD_MODNAME,
--
1.6.0.2