public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* copy to user
@ 2001-11-20 20:54 Luis Miguel Correia Henriques
  2001-11-20 21:28 ` John Alvord
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Luis Miguel Correia Henriques @ 2001-11-20 20:54 UTC (permalink / raw)
  To: linux-kernel

The reason that I need it to spend CPU time is that I'm developing a fault
injector. The purpose of a fault injection tool is, as you could imagine,
to test some critical systems and it's capacity to recover from fails. The
reason for changing the code of a process is that process must be delayed
but without leaving the CPU - everything must look like nothing wrong is
happening, except for other processes that are waiting for something from
the delayed process...

Maybe I should have explained this before... sorry.

I suppose now you can understand why SIGSTOP won't work. Hope you can help
me :)

About using udelay... this soluction seemed fine to me at first but if I
hang the CPU with udelay the scheduler will no be doing it's job (isn't
it?). This would give me even more intrusiveness (another requirement: the
less intrusiveness as possible).

Isn't there any doubt that copy_to_user can handle my problem? When I use
it to change CS, this function returns the correct number of bytes (and no
error) but, when I try to read... the old data is still there. I suppose
there is a page/segment protection against writing to CS, isn't it?

Luis Henriques


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

* Re: copy to user
  2001-11-20 20:54 Luis Miguel Correia Henriques
@ 2001-11-20 21:28 ` John Alvord
  2001-11-20 21:44 ` Andreas Dilger
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: John Alvord @ 2001-11-20 21:28 UTC (permalink / raw)
  To: Luis Miguel Correia Henriques; +Cc: linux-kernel

On Tue, 20 Nov 2001 20:54:42 +0000 (WET), Luis Miguel Correia
Henriques <umiguel@alunos.deis.isec.pt> wrote:

>The reason that I need it to spend CPU time is that I'm developing a fault
>injector. The purpose of a fault injection tool is, as you could imagine,
>to test some critical systems and it's capacity to recover from fails. The
>reason for changing the code of a process is that process must be delayed
>but without leaving the CPU - everything must look like nothing wrong is
>happening, except for other processes that are waiting for something from
>the delayed process...
>
>Maybe I should have explained this before... sorry.
>
>I suppose now you can understand why SIGSTOP won't work. Hope you can help
>me :)
>
>About using udelay... this soluction seemed fine to me at first but if I
>hang the CPU with udelay the scheduler will no be doing it's job (isn't
>it?). This would give me even more intrusiveness (another requirement: the
>less intrusiveness as possible).
>
>Isn't there any doubt that copy_to_user can handle my problem? When I use
>it to change CS, this function returns the correct number of bytes (and no
>error) but, when I try to read... the old data is still there. I suppose
>there is a page/segment protection against writing to CS, isn't it?

Maybe the kernel logic could lock the relevent page so it couldn't be
paged out...

john alvord

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

* Re: copy to user
  2001-11-20 20:54 Luis Miguel Correia Henriques
  2001-11-20 21:28 ` John Alvord
@ 2001-11-20 21:44 ` Andreas Dilger
  2001-11-21 11:02   ` Luís Henriques
  2001-11-20 22:02 ` n0ano
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Andreas Dilger @ 2001-11-20 21:44 UTC (permalink / raw)
  To: Luis Miguel Correia Henriques; +Cc: linux-kernel

On Nov 20, 2001  20:54 +0000, Luis Miguel Correia Henriques wrote:
> The reason that I need it to spend CPU time is that I'm developing a fault
> injector. The purpose of a fault injection tool is, as you could imagine,
> to test some critical systems and it's capacity to recover from fails. The
> reason for changing the code of a process is that process must be delayed
> but without leaving the CPU - everything must look like nothing wrong is
> happening, except for other processes that are waiting for something from
> the delayed process...
>
> I suppose now you can understand why SIGSTOP won't work.

If you put the process in (un)interruptible sleep in the kernel, won't this
be enough?  This is different than SIGSTOP.  Is the requirement that this
process not leave the kernel call, or that it is actually consuming CPU
cycles as well?

> About using udelay... this soluction seemed fine to me at first but if I
> hang the CPU with udelay the scheduler will no be doing it's job (isn't
> it?). This would give me even more intrusiveness (another requirement: the
> less intrusiveness as possible).

It would probably work OK on an SMP system, since tasks can still be run
on the other CPU.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/


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

* Re: copy to user
  2001-11-20 20:54 Luis Miguel Correia Henriques
  2001-11-20 21:28 ` John Alvord
  2001-11-20 21:44 ` Andreas Dilger
@ 2001-11-20 22:02 ` n0ano
  2001-11-20 22:05 ` Chris Wright
  2001-11-21  8:43 ` Mathijs Mohlmann
  4 siblings, 0 replies; 9+ messages in thread
From: n0ano @ 2001-11-20 22:02 UTC (permalink / raw)
  To: Luis Miguel Correia Henriques; +Cc: linux-kernel

Ignoring the merits of what you are trying to do why don't you put your
new code on the target's stack?  This avoids all of the problems associated
with changing the code section (which is doable but tricky, after all if
`gdb' can change the code section you certainly could).

On Tue, Nov 20, 2001 at 08:54:42PM +0000, Luis Miguel Correia Henriques wrote:
> The reason that I need it to spend CPU time is that I'm developing a fault
> injector. The purpose of a fault injection tool is, as you could imagine,
> to test some critical systems and it's capacity to recover from fails. The
> reason for changing the code of a process is that process must be delayed
> but without leaving the CPU - everything must look like nothing wrong is
> happening, except for other processes that are waiting for something from
> the delayed process...
> 
> Maybe I should have explained this before... sorry.
> 
> I suppose now you can understand why SIGSTOP won't work. Hope you can help
> me :)
> 
> About using udelay... this soluction seemed fine to me at first but if I
> hang the CPU with udelay the scheduler will no be doing it's job (isn't
> it?). This would give me even more intrusiveness (another requirement: the
> less intrusiveness as possible).
> 
> Isn't there any doubt that copy_to_user can handle my problem? When I use
> it to change CS, this function returns the correct number of bytes (and no
> error) but, when I try to read... the old data is still there. I suppose
> there is a page/segment protection against writing to CS, isn't it?
> 
> Luis Henriques
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
n0ano@indstorage.com
Ph: 303/652-0870x117

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

* Re: copy to user
  2001-11-20 20:54 Luis Miguel Correia Henriques
                   ` (2 preceding siblings ...)
  2001-11-20 22:02 ` n0ano
@ 2001-11-20 22:05 ` Chris Wright
  2001-11-21  8:43 ` Mathijs Mohlmann
  4 siblings, 0 replies; 9+ messages in thread
From: Chris Wright @ 2001-11-20 22:05 UTC (permalink / raw)
  To: Luis Miguel Correia Henriques; +Cc: linux-kernel

* Luis Miguel Correia Henriques (umiguel@alunos.deis.isec.pt) wrote:
> The reason that I need it to spend CPU time is that I'm developing a fault
> injector. The purpose of a fault injection tool is, as you could imagine,
> to test some critical systems and it's capacity to recover from fails. The
> reason for changing the code of a process is that process must be delayed
> but without leaving the CPU - everything must look like nothing wrong is
> happening, except for other processes that are waiting for something from
> the delayed process...

with ptrace(2) you can write into the program's .bss, whatever...add a
little shellcode and you're dangerous ;-)

-chris

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

* RE: copy to user
  2001-11-20 20:54 Luis Miguel Correia Henriques
                   ` (3 preceding siblings ...)
  2001-11-20 22:05 ` Chris Wright
@ 2001-11-21  8:43 ` Mathijs Mohlmann
  2001-11-21 10:12   ` Jan Hudec
  4 siblings, 1 reply; 9+ messages in thread
From: Mathijs Mohlmann @ 2001-11-21  8:43 UTC (permalink / raw)
  To: Luis Miguel Correia Henriques; +Cc: linux-kernel


On 20-Nov-2001 Luis Miguel Correia Henriques wrote:
> I suppose now you can understand why SIGSTOP won't work. Hope you can help
> me :)

how about making a signal handler for SIGUSR1 that checks a global variable and
loops. an other signal handler for SIGUSR2 to clear the variable so the SIGUSR1
handler can exit.

All in user space. (to delay execution kill -USR1 $pid, to continue: kill -USR2
$pid)

        me


-- 
        me

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

* Re: copy to user
  2001-11-21  8:43 ` Mathijs Mohlmann
@ 2001-11-21 10:12   ` Jan Hudec
  0 siblings, 0 replies; 9+ messages in thread
From: Jan Hudec @ 2001-11-21 10:12 UTC (permalink / raw)
  To: linux-kernel

> > I suppose now you can understand why SIGSTOP won't work. Hope you can help
> > me :)
> 
> how about making a signal handler for SIGUSR1 that checks a global variable and
> loops. an other signal handler for SIGUSR2 to clear the variable so the SIGUSR1
> handler can exit.
> 
> All in user space. (to delay execution kill -USR1 $pid, to continue: kill -USR2
> $pid)

The same is possible within the kernel too! Add default handler to some
unused signals (there are more user-defineable signals than SIGUSR[12]
and noone cares to install handler for them) to do the loop in kernel.
Just make sure, that you call shedule() from time to time in that loop,
because in kernel you can't be preempted as you would in user-space.

--------------------------------------------------------------------------------
                  				- Jan Hudec `Bulb' <bulb@ucw.cz>

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

* Re: copy to user
  2001-11-20 21:44 ` Andreas Dilger
@ 2001-11-21 11:02   ` Luís Henriques
  0 siblings, 0 replies; 9+ messages in thread
From: Luís Henriques @ 2001-11-21 11:02 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-kernel

> If you put the process in (un)interruptible sleep in the kernel, won't this
> be enough?  This is different than SIGSTOP.  Is the requirement that this
> process not leave the kernel call, or that it is actually consuming CPU
> cycles as well?

The process needs to be using CPU time, however, there must be a chance to 
the scheduler to change the current process... if this occurs, than the delay 
has to be aborted. 

>
> > About using udelay... this soluction seemed fine to me at first but if I
> > hang the CPU with udelay the scheduler will no be doing it's job (isn't
> > it?). This would give me even more intrusiveness (another requirement:
> > the less intrusiveness as possible).
>
> It would probably work OK on an SMP system, since tasks can still be run
> on the other CPU.
>
> Cheers, Andreas

-- 
Luís Henriques

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

* Re: copy to user
@ 2001-11-25 21:58 Marco C. Mason
  0 siblings, 0 replies; 9+ messages in thread
From: Marco C. Mason @ 2001-11-25 21:58 UTC (permalink / raw)
  To: umiguel, linux-kernel

Luis Henriques--

Before making my suggestion: Apologies to the list if this has already
been settled.  I'm trying to catch up on my LKML reading, and I'm only
up to Nov 20 so far...

Anyway:  Here's what I'd do, if I had to do such a apalling thing  8^)

Drop a function in your code something like:

_xyzzy:
    db 0x18, 0xfe    ; jr $

Then, when you detect the condition where you want to waste time, then
put the address of this function on top of the user stack (along with
whatever else in the stack frame is required) so that the code just sits
there burning CPU.  To clean it up, you'd simply restore the original
stack frame to the process.

It's hideous & gross, but if you need it.....

--marco



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

end of thread, other threads:[~2001-11-25 21:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-25 21:58 copy to user Marco C. Mason
  -- strict thread matches above, loose matches on Subject: below --
2001-11-20 20:54 Luis Miguel Correia Henriques
2001-11-20 21:28 ` John Alvord
2001-11-20 21:44 ` Andreas Dilger
2001-11-21 11:02   ` Luís Henriques
2001-11-20 22:02 ` n0ano
2001-11-20 22:05 ` Chris Wright
2001-11-21  8:43 ` Mathijs Mohlmann
2001-11-21 10:12   ` Jan Hudec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox