lkml.org 
[lkml]   [1998]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: context_switching&machine_suspend()
> > I'd like work on a new project. Its main goal would be that [preferably]
> > all of the state of the machine would be saved on disk when pressing a
> > magic sysrq key and this could be restored later [e.g. one day later].
>
> hm, another tough problem is how to restore hardware state. Say you have a
> video card with write-only registers. (but on the bright side, this should
> be rather seldom, so it would work if you'd extend _your_ device drivers
> to handle suspension, then extend the number of 'supported' drivers
> slowly, as the architecture stabilizes)
Yes, e.g. for this purpose save/restore functions needed.

> you could just save the whole physical memory image without caring about
> data structures. Maybe define some trampoline area that serves as a 'work
> area' to do this 'switchover'. Explicitly registering/unregistering data
> structures increases the comlpexity of the feature _alot_ i think. It's
> enough fun already to do the hardware state stuff ...
Complex or not I think I should care about them. I think there's no
problem with dynamically allocated memory coz the mm layer knows about
them, so its save function would save all memory that cannot be restored
from anywhere else [mmap-ed not dirty pages].
I'm more afraid of local variables. Currently I don't know where they get
memory.
I mean:

void some_function()
{
int blah;
char sg;

...

if(need_resched)
schedule();

...
}

>
> > The problem right now is that I don't know anything about context
> > swichting.
> > I mean.. e.g. what happens when a process calls sleep_on or its time slice
> > is over? Both cases schedule() is called. But.. since it will return
> > sometime a stack is have to be managed by the processor.. It's all clean
> > by a single threaded program of course but what happens here?
> > Is the individual stacks for all processes or so? How will I be able to
> > save them? I'd like to make this platform independent of course.
I've found where stacks reside :) They're allocated when a new process
is forked by __get_free_page(..,1);

> there are lots of 'chicken and egg' problems here. You need a working
> kernel to do the IO to load a saved kernel. The switchover probably has to
> involve some assembly functions too, to jump from the trampoline area into
> a (pre-defined) entry point of the saved kernel. The problem is very
> analogous to 'booting', so one possible solution could be to make such a
> saved image bootable. (the kernel then would do the restore itself after
> booting the kernel code) Thus you could do the switchover via a reboot.
> (the reboot itself is not a problem, as you lose the original kernel
> anyway, so it's not a problem to do a small reboot, the kernel will load a
> possibly hundreds of megabytes memory image anyway)
Hm, I didn't mean that difficult way.. I hope this isn't the one anyway.

What I've got so far in my mind:
- by pressing Sysrq-Q a kernel_thread is started
- in this thread all the runnable processes are sent to sleep by sleep_on
[and somehow I'd have to prevent that schedule() would wake up another
one], so this thread is running only.
- I do sync and drop unneeded buffer_heads
- Open a file where the image will be written [yes, here comes the chicken
& egg problem....]
- Call all save functions [linked list].

By booting I let the init functions do their job and when init would run I
open the saved image and call restore functions which read all their info
back and restore structs.

Of course the image would be protected by magic numbers and CRC-s but that
isn't a question now..

> also there are other problems like TCP connections to the outside world,
> and disk contents. (what if the disk got modified since the last time that
> image was booted and the image has a disk cache that is out-of-date). What
> about the system date, is it going to be 'saved' too? So it's a _very_
> difficult problem. Some people argue this should be done in user-space,
> just like Condor does. (but doing it in the kernel is indeed more sexy).
Well TCP connections should be broken by the time of saving, they would
timeout anyway.. NFS is a more difficult problem [but what if I drop all
buffer_heads?].
Hm, I don't know how could it be done in user-space.. discount that case
when /dev/kmem is dumped..
But I don't think that dumping the whole memory is the Good Way (tm)..


Seasons
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
"One who has time to complain has time to submit patches." <chinese proverb>
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:0.032 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site