mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergiy Lozovsky <serge_lozovsky@yahoo.com>
To: Helge Hafting <helgehaf@aitel.hist.no>
Cc: linux-kernel@vger.kernel.org
Subject: Re: kernel stack challenge
Date: Tue, 6 Apr 2004 10:44:12 -0700 (PDT)	[thread overview]
Message-ID: <20040406174412.7850.qmail@web40511.mail.yahoo.com> (raw)
In-Reply-To: <20040406133246.GA19091@hh.idb.hist.no>

If stack will shrink - i'll come up with something.
Rearchitecture of LISP interpreter - is too much work.
(and I'm lazy - I prefer computer to do a work, not me
:-)

I checked what is going on with the stack - it is used
to pass parameters, some functions have one or two
local variables (4 bytes each) and that's it.

I like to develop tools and general solutions :-) To
solve the stack problem in a way which will not cause
big changes in any existing code - I can make stack
virtualization. API can be different, but idea is the
same. Task has some memory allocated by malloc
(vstack) which is used for saving data from real
stack. One of the APIs - scall function:

scall(pointer_to_vstack, number_of_arguments,
pointer_to_function_to_call, arg1, arg2,...)

scall checks if real stack is full enough - it stores
it's content in the vstack and moves %esp to the
bottom of the real stack. When user function returns -
information from vstack moves to the real one (one
movl instruction at Intel x86).

In case of LISP there is only one place where it will
be enough to use scall - eval function.

In other subsystems - it can be needed to call in a
few places. But in such way a new 4K stack could be
used without serious rewriting of existing code.

vstack can grow dynamically if needed (within defined
limit).

Serge.

--- Helge Hafting <helgehaf@aitel.hist.no> wrote:
> On Mon, Apr 05, 2004 at 10:05:37AM -0700, Sergiy
> Lozovsky wrote:
> > > Consider rewriting your function to use
> allocated
> > > memory instead of stack, this isn't all that
> hard.
> > 
> > I put LISP interpreter inside the Kernel -
> > http://vxe.quercitron.com
> > 
> > It works, but it use a lot of stack memory. It's
> > impossible to rewrite it easily, though I'll
> > investigate why exactly it uses so much of stack
> > memory (though it's nature of LISP). There are no
> > serious kernel memory allocation (as of my
> interpreter
> > code review, only function calls; recursions in
> LISP
> > application itself are eliminated for sure), but
> I'll
> > trace stack usage more thouroughly.
> > 
> Consider this.  We're currently experimenting with a
> transition from 8k to 4k stacks on x86, and that is
> considered a very good thing.  Allocating a single-
> page stack is easy, two (contigous) pages might
> fail.
> 
> So a bigger kernel stack is out.
> 
> As for rewriting code so it doesn't use stack - it
> _is_ easy, but it might be a lot of _work_.
> 
> The simple approach is to replace all (big) stack
> allocations with an explicit stack structure that
> you manages
> on the heap. There'll be more code, but it won't be
> slower
> because all the extra code is stuff that happen
> automatically
> with the hw stack. (I.e. stuff the compiler normally
> take
> care of.)
> 
> There is some more work if your interpreter also
> does deep recursion.
> It involves making one big function of those that do
> the recursion
> and manage the "calls" yourself with an array and a
> switch statement.
> Again, not particularly hard, but it could take some
> time to implement.
> 
> Helge Hafting  


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

  reply	other threads:[~2004-04-06 17:44 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-04  6:48 Sergiy Lozovsky
2004-04-05  9:39 ` Helge Hafting
2004-04-05 17:05   ` Sergiy Lozovsky
2004-04-05 18:06     ` Timothy Miller
2004-04-05 17:59       ` Sergiy Lozovsky
2004-04-05 19:27         ` Valdis.Kletnieks
2004-04-05 21:14           ` Timothy Miller
2004-04-05 20:09         ` John Stoffel
2004-04-05 20:54           ` Sergiy Lozovsky
2004-04-05 21:08             ` Chris Wright
2004-04-05 21:40               ` Sergiy Lozovsky
2004-04-05 21:53                 ` Chris Wright
2004-04-05 22:22                 ` Timothy Miller
2004-04-05 23:49                   ` Sergiy Lozovsky
2004-04-06 13:25                     ` Jesse Pollard
     [not found]                     ` <20040406132750$3d4e@grapevine.lcs.mit.edu>
     [not found]                       ` <mit.lcs.mail.linux-kernel/20040406132750$3d4e@grapevine.lcs.mit.edu>
2004-04-06 16:40                         ` Patrick J. LoPresti
2004-04-06 19:10                           ` Timothy Miller
2004-04-06 20:53                             ` Patrick J. LoPresti
2004-04-06 21:24                               ` Timothy Miller
2004-04-07 14:36                           ` Jesse Pollard
2004-04-05 21:28             ` Timothy Miller
2004-04-05 21:21               ` Stephen Smoogen
2004-04-05 22:25                 ` Timothy Miller
2004-04-05 21:30               ` Sergiy Lozovsky
2004-04-05 21:45                 ` Kevin Fox
2004-04-05 21:59                 ` Robin Rosenberg
2004-04-05 22:52                   ` Sergiy Lozovsky
2004-04-06  0:46                     ` Robin Rosenberg
2004-04-06  0:55                     ` Robin Rosenberg
2004-04-06  3:02                       ` Sergiy Lozovsky
2004-04-06  3:04                         ` Randy.Dunlap
2004-04-05 22:20                 ` Timothy Miller
2004-04-05 23:27                   ` Sergiy Lozovsky
2004-04-06 20:16                 ` Horst von Brand
2004-04-06 20:58                   ` Timothy Miller
2004-04-06 22:05                     ` Sergiy Lozovsky
2004-04-06 22:56                       ` Timothy Miller
2004-04-06 23:17                         ` Sergiy Lozovsky
2004-04-08 13:11                           ` Martin Waitz
2004-04-08 22:33                             ` Sergiy Lozovsky
2004-04-07  2:44                       ` Horst von Brand
2004-04-07 17:54                         ` Sergiy Lozovsky
2004-04-08  2:43                           ` Horst von Brand
2004-04-08  4:07                             ` Sergiy Lozovsky
2004-04-08  4:29                               ` Horst von Brand
2004-04-08 22:51                                 ` Sergiy Lozovsky
2004-04-08 15:44                               ` Valdis.Kletnieks
2004-04-08 22:22                                 ` Sergiy Lozovsky
2004-04-09 15:27                                   ` Jesse Pollard
2004-04-05 21:12         ` Timothy Miller
2004-04-06 13:32     ` Helge Hafting
2004-04-06 17:44       ` Sergiy Lozovsky [this message]
2004-04-07  1:02         ` Horst von Brand
2004-04-07  1:34           ` Sergiy Lozovsky
2004-04-07  8:57             ` David Weinehall
2004-04-07 13:38               ` Chris Friesen
2004-04-07 17:12                 ` Sergiy Lozovsky
2004-04-07 17:16               ` Sergiy Lozovsky
2004-04-07  2:30           ` viro
2004-04-06 18:33       ` Jamie Lokier
2004-04-06 18:51         ` Sergiy Lozovsky
     [not found] <1H9LV-5Jb-1@gated-at.bofh.it>
2004-04-04 11:27 ` Andi Kleen
2004-04-04 18:24   ` Sergiy Lozovsky
2004-04-04 18:38     ` Muli Ben-Yehuda
     [not found] <200404052043.i35KhDvS020176@turing-police.cc.vt.edu>
2004-04-05 21:06 ` Sergiy Lozovsky
     [not found] <200404052026.i35KQh5g004342@eeyore.valparaiso.cl>
2004-04-05 21:21 ` Sergiy Lozovsky
2004-04-06 20:01   ` Horst von Brand
     [not found] <200404061606.i36G6YLE003375@eeyore.valparaiso.cl>
2004-04-06 18:04 ` Sergiy Lozovsky
2004-04-06 18:28   ` John Stoffel
2004-04-06 18:48     ` Sergiy Lozovsky
2004-04-06 18:57   ` Richard B. Johnson
2004-04-06 21:15     ` Sergiy Lozovsky
2004-04-06 22:44       ` Timothy Miller
2004-04-06 22:57         ` viro
2004-04-06 23:32           ` Sergiy Lozovsky
2004-04-06 23:45             ` Robin Rosenberg
2004-04-07  2:25       ` Horst von Brand
     [not found] <200404061618.i36GIHgW003419@eeyore.valparaiso.cl>
2004-04-06 18:16 ` Sergiy Lozovsky
2004-04-06 20:01   ` Valdis.Kletnieks
2004-04-06 21:38     ` Sergiy Lozovsky
2004-04-06 22:46       ` Timothy Miller
     [not found] <24DA9B48-8827-11D8-87A5-000A9585C204@able.es>
2004-04-07  0:27 ` Sergiy Lozovsky
     [not found] <58907794@toto.iv>
2004-04-07  4:29 ` Peter Chubb
     [not found] <20040409182517.330.qmail@web40508.mail.yahoo.com>
2004-04-10  4:17 ` Horst von Brand

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=20040406174412.7850.qmail@web40511.mail.yahoo.com \
    --to=serge_lozovsky@yahoo.com \
    --cc=helgehaf@aitel.hist.no \
    --cc=linux-kernel@vger.kernel.org \
    /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®