mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keith Adamson <keith.adamson@attbi.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] automatic initcalls
Date: 28 Jul 2002 04:50:59 -0400	[thread overview]
Message-ID: <1027846262.29344.183.camel@h00d0700074d1.ne.client2.attbi.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0207272145050.6125-100000@home.transmeta.com>

[-- Attachment #1: Type: text/plain, Size: 1325 bytes --]

On Sun, 2002-07-28 at 00:47, Linus Torvalds wrote:
> 
> 
> On Sat, 27 Jul 2002, Jeff Garzik wrote:
> >
> > I've always preferred a system where one simply lists dependencies [as
> > you describe above], and some program actually does the hard work of
> > chasing down all the initcall dependency checking and ordering.
> >
> > Linus has traditionally poo-pooed this so I haven't put any work towards
> > it...
> 
> I don't hate the notion, but at the same time every time it comes up I
> feel that there are reasonably simple ways to just avoid the ordering
> problems.
> 
> Rusty had a script, but somebody complained about the speed of it. I
> haven't looked at it myself.
> 
> 		Linus

There is a relatively simple and fast recursive algorithm I've used
before to generating a sequence from a dependency list.
For initcall sequence it would be something like this (bash scripts
attached);

Dependency database: dependency_list_database
Main programs:       make_initcall_seqence.sh
Recursive routine:   generate_initcall.sh

Output sequence:     initcall_sequence

See attached files.

Normally I have error checking for bad dependencies (you can get into a
infinite recursive loop if for instance "foo1" needs "foo2" and also
"foo2" needs "foo1") ... but I didn't do it to keep the algorithm more
understandable. 

Keith

[-- Attachment #2: make_initcall_seqence.sh --]
[-- Type: text/x-sh, Size: 618 bytes --]

#!/bin/bash
#
#   make_initcall_seqence.sh - generate initcall sequence, file
#                          "initcall_sequence", from an initcall
#                          dependency list database, file
#                          "dependency_list_database"
#
# A random list of initcalls (will sequence them acording to the
# dependency database
initcall_list=$(sed 's,:.*$,,' dependency_list_database)
#
# Initialize the initcall_sequence file
rm -f initcall_sequence
touch initcall_sequence
#
# build the initcall_sequence file
for name in $initcall_list
do
        generate_initcall.sh $name
done

[-- Attachment #3: generate_initcall.sh --]
[-- Type: text/x-sh, Size: 1372 bytes --]

#!/bin/bash
#
#   generate_initcall.sh - Insert initcall into the "initcall_sequence"
#                          file in correct sequence
#
# First arg is the initcall
initcall=$1
#
# Get dependency initcall list for this initcall from the dependency
# database
dependency_initcall_list=$(
        grep '^'$initcall'[ :]' dependency_list_database | \
                sed 's,^.*:,,'
        )
#
#  function to find a missing initcall in initcall_sequence
function find_missing_initcall()
{
        need_initcall=""
        for name in $dependency_initcall_list
        do
                # test if initcall not done in initcall_sequence
                if [ "$(grep '^'$name'$' initcall_sequence)" = "" ]
                then
                        # return needed initcall
                        need_initcall=$name
                        break
                fi
        done
}
#
#  generate missing initcalls that this initcall needs done first
#
find_missing_initcall
while [ -n "$need_initcall" ]    # loop while adding missing initcalls
do
        generate_initcall.sh $need_initcall  # NOTE THE RECURSIVE CALL
        find_missing_initcall
done
#
#  Finally add this initcall to initcall_sequence (if missing)
if [ "$(grep '^'$initcall'$' initcall_sequence)" = "" ]
then
        echo $initcall >> initcall_sequence
fi

[-- Attachment #4: dependency_list_database --]
[-- Type: text/plain, Size: 71 bytes --]

foo1 : foo2 foo3
foo2 : foo5
foo3 : foo2 foo4
foo4 :
foo5 : foo4 

  reply	other threads:[~2002-07-28  8:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-27 20:22 Roman Zippel
2002-07-28  3:31 ` Rusty Russell
2002-07-28  3:51   ` Jeff Garzik
2002-07-28  4:47     ` Linus Torvalds
2002-07-28  8:50       ` Keith Adamson [this message]
2002-07-28 18:59       ` Oliver Xymoron
2002-07-29 23:39       ` Rusty Russell
2002-07-29  8:39     ` Ingo Oeser
2002-07-30  2:49       ` Keith Adamson
2002-07-30  2:51         ` Keith Adamson
2002-07-28 12:18   ` Roman Zippel
2002-07-29 23:46     ` Rusty Russell
2002-07-30 23:04       ` [PATCH] automatic module_init ordering Roman Zippel
2002-07-31  2:33         ` Kai Germaschewski
2002-07-31  3:26           ` Rusty Russell
2002-07-31 17:06             ` Kai Germaschewski
2002-07-31 23:28               ` Rusty Russell
2002-07-28 21:59   ` [PATCH] automatic initcalls Kai Germaschewski
2002-07-29 18:56   ` Patrick Mochel
2002-07-29 20:14     ` Roman Zippel

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=1027846262.29344.183.camel@h00d0700074d1.ne.client2.attbi.com \
    --to=keith.adamson@attbi.com \
    --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®