From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andreas Dilger <adilger@clusterfs.com>, linux-kernel@vger.kernel.org
Subject: Re: How can I force a read to hit the disk?
Date: Tue, 9 Sep 2003 10:51:44 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.53.0309091037150.5368@chaos> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0309090952560.887-100000@ida.rowland.org>
On Tue, 9 Sep 2003, Alan Stern wrote:
> On Tue, 9 Sep 2003, Richard B. Johnson wrote:
>
> > On Mon, 8 Sep 2003, Alan Stern wrote:
> >
> > > > When your thread code starts up, execute
> > > > init_rwsem(¤t->mm->mmap_sem);
> > > >
> > > > ... This is in the thread's code, not the module init code.
> > >
> > > That doesn't work either; it also causes a segmentation violation. As I
> > > said before, current->mm is NULL. It gets set that way by exit_mm() which
> > > is called from daemonize().
> > >
> > > Alan Stern
> > >
> >
> > Gawd. I assumed you knew how to initialize a pointer. I just
> > located the procedure used to initialize the semaphore.
>
> Shucks, I know how to initialize a pointer. I even know how to initialize
> a read-write semaphore. The problem here is not _doing_ the
> initialization; it's what _value_ to use. Kernel threads don't have a
> userpace memory component, so naturally current->mm is NULL -- there's no
> memory map for it to point to. Without having a memory map, of course
> there's no semaphore to initialize, since the semaphore is _part_ of the
> memory map structure.
>
> Alan Stern
>
The semaphore location exists in the memory map structure, mm_struct.
You only need to allocate some memory the size of that structure to
contain the semaphore. You can readily see what happens in
../kernel/fork.c ...:
Something like:
if((current->mm = mm_alloc()) == NULL)
printk("Some problem with mm_alloc()\n");
else
init_rwsem(¤t->mm->mmap_sem);
... should get you going.
If, in all your code, the only problem you had was an allocation
problem with your semaphore, and not a problem with actual memory
access, then you are golden. If you are even going to shut down your
kernel thread, you probably need to add your allocation to the
linked list. If not, don't bother.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (794.73 BogoMips).
Note 96.31% of all statistics are fiction.
next prev parent reply other threads:[~2003-09-09 14:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-05 17:46 Alan Stern
2003-09-05 18:15 ` Andreas Dilger
2003-09-05 18:49 ` Alan Stern
2003-09-05 19:09 ` Jörn Engel
2003-09-05 19:56 ` Alan Stern
2003-09-05 20:12 ` Alan Stern
2003-09-08 19:22 ` Alan Stern
2003-09-08 19:42 ` Richard B. Johnson
2003-09-08 20:36 ` Alan Stern
2003-09-09 12:13 ` Richard B. Johnson
2003-09-09 13:56 ` Alan Stern
2003-09-09 14:51 ` Richard B. Johnson [this message]
2003-09-09 20:16 ` Alan Stern
2003-09-05 18:42 ` Richard B. Johnson
2003-09-05 19:16 ` Alan Stern
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=Pine.LNX.4.53.0309091037150.5368@chaos \
--to=root@chaos.analogic.com \
--cc=adilger@clusterfs.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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
all inboxes | Powered by JetHome®