From: Julian Andres Klode <jak@jak-linux.org>
To: Manavendra Nath Manav <mnm.kernel@gmail.com>
Cc: kernelnewbies@kernelnewbies.org, devel@driverdev.osuosl.org,
Greg KH <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: Why exported const value modified by another driver not updated in original driver
Date: Tue, 4 Sep 2012 12:39:05 +0200 [thread overview]
Message-ID: <20120904103905.GA21953@jak-linux.org> (raw)
In-Reply-To: <CAJKgH8CNJM2SyR7bD8nXae13-Fq1MP1Xn7+383YU-HPwKBe+Zg@mail.gmail.com>
On Tue, Sep 04, 2012 at 03:58:20PM +0530, Manavendra Nath Manav wrote:
> On Tue, Sep 4, 2012 at 3:00 PM, Manavendra Nath Manav
> <mnm.kernel@gmail.com> wrote:
> > Hi,
> >
> > I have declared a static const int variable in one driver and exported
> > that variable symbol. In another driver i am modifying that variable.
No, you did not export it. It's static (and static is kind of the opposite
of extern). And then you try to assign a value to a non-static variable with
the same name, which might not even exist (as the other is static, this should
not even work in my opinion).
> > The other driver prints the modified value but the original driver
> > retains the original value. When both virtual and physical addresses
> > of the variable as seen by both drivers are same, how is this even
> > possible. Is it a kernel bug?
It only works because the compiler optimized the value = 123 away,
and replaced value with 123 in the first module everywhere, as it
is declared const and thus cannot be changed, so there's no reason
to read it from memory.
--
Julian Andres Klode - Debian Developer, Ubuntu Member
See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
next prev parent reply other threads:[~2012-09-04 10:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-04 9:30 Why exported const value modified by another driver not updated in original driver Manavendra Nath Manav
2012-09-04 10:28 ` Manavendra Nath Manav
2012-09-04 10:39 ` Julian Andres Klode [this message]
2012-09-04 10:59 ` Manavendra Nath Manav
2012-09-04 11:49 ` Chinmay V S
2012-09-04 12:25 ` Dan Carpenter
2012-09-05 8:27 ` Manavendra Nath Manav
2012-09-04 10:46 ` Alan Cox
2012-09-04 12:06 ` Bernd Petrovitsch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120904103905.GA21953@jak-linux.org \
--to=jak@jak-linux.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernelnewbies@kernelnewbies.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mnm.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox