All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Michael Opdenacker <michael.opdenacker@free-electrons.com>
Cc: mmarek@suse.cz, akpm@linux-foundation.org, joe@perches.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts/checkkconfig.py: find unused Kconfig parameters
Date: Tue, 29 Oct 2013 19:06:19 +0100	[thread overview]
Message-ID: <20131029180619.GC3411@free.fr> (raw)
In-Reply-To: <1382592209-10246-1-git-send-email-michael.opdenacker@free-electrons.com>

Michael, All,

On 2013-10-24 07:23 +0200, Michael Opdenacker spake thusly:
> This is the first version of a script to look for
> Kconfig parameters which are still defined but no longer
> used in the kernel source code.
> 
> The script may be extended in the future to perform
> more checks. This explains why a rather generic name was chosen.
> 
> Several issues have already been reported and fixed
> thanks to the use of this script. It is time to share it now!

I'm not much of a Python guy, so I'll gleefully rely on the previous
comments to guide you in your endeavour.

/me is feeling poetical, tonight! ;-)

I however have a suggestion, see below.

> Signed-off-by: Michael Opdenacker <michael.opdenacker@free-electrons.com>
> ---
>  scripts/checkkconfig.py | 131 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 131 insertions(+)
>  create mode 100755 scripts/checkkconfig.py
> 
> diff --git a/scripts/checkkconfig.py b/scripts/checkkconfig.py
> new file mode 100755
> index 0000000..4155656
> --- /dev/null
> +++ b/scripts/checkkconfig.py
> @@ -0,0 +1,131 @@
[--SNIP--]
> +def count_param(param):
> +
> +    global source_file, bad_params_in_file
> +
> +    if os.path.isdir('.git'):
> +       # Use git grep when available
> +       count = subprocess.check_output('git grep ' + param + '| grep -v defconfig | wc -l', shell=True)
> +    else:
> +       # Fallback to regular grep
> +       count = subprocess.check_output('grep -R ' + param + ' . | grep -v defconfig | wc -l', shell=True)
> +
> +    num = int(count.strip())
> +
> +    if num == 1:
> +       'WARNING: parameter ' + param + ' is used nowhere'
> +
> +       file=source_file[param]
> +
> +       if bad_params_in_file.has_key(file):
> +          bad_params_in_file[file].append(param)
> +       else:
> +	  bad_params_in_file[file]=[param]
> +
> +
> +########################################################
> +# Main program
> +########################################################
[--SNIP--]
> +for param in has_select.keys():
> +
> +    # Progress information... running the script can take hours!

I guess all these grep spawning are what makes it slow.

I wonder if it would not be possible to invert the loop (in pseudo
Python code):

    for f in all_interesting_files:
        read f in memory
        for s in all_symbols:
            if symbol is in f:
                remove f from all_symbols
                break the inner-most loop

This way:
  - you scan the tree only once
  - as soon as a symbol is matched, it is removed, thus decreasing
    the amount of checks done in further loops.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

  parent reply	other threads:[~2013-10-29 18:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24  5:23 [PATCH] scripts/checkkconfig.py: find unused Kconfig parameters Michael Opdenacker
2013-10-24  7:30 ` Joe Perches
2013-10-25 13:38   ` Michael Opdenacker
2013-10-25 13:45     ` Michal Marek
2013-10-30  3:07       ` Michael Opdenacker
2013-10-24  9:39 ` Michal Marek
2013-10-29 18:06 ` Yann E. MORIN [this message]
2013-10-30  3:14   ` Michael Opdenacker

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=20131029180619.GC3411@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=akpm@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.opdenacker@free-electrons.com \
    --cc=mmarek@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.