All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
@ 2011-04-11 13:11 Graeme Russ
  2011-04-14  6:17 ` Albert ARIBAUD
  2011-04-14  9:14 ` Kumar Gala
  0 siblings, 2 replies; 7+ messages in thread
From: Graeme Russ @ 2011-04-11 13:11 UTC (permalink / raw)
  To: u-boot

Hi All,

As a bit of a lark, I ran the following shell command:

grep -r -h -o -G "#define CONFIG.*" * | \
sed 's/#define[ \t]*//' | \
sed 's/^\([A-Za-z0-9_]*\).*/\1/' | \
sort -u > README.configuration.options

I then ran the result through the following script into
README.configuration.options.counted

#!/bin/bash
INPUT=doc/README.configuration.options

#!/bin/bash
INPUT=doc/README.configuration.options

for i in `cat $INPUT`
do
	grep -rcs --exclude-dir=doc '\<'${i}'\>' * | \
	cut -d : -f 2 | \
	awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i
done

The result? 5539 lines of pure configuration option goodness :)

Here's a little snippet:

6	CONFIG_100MHz
8	CONFIG_133MHZ_DRAM
7	CONFIG_300MHz
13	CONFIG_405
24	CONFIG_405CR
88	CONFIG_405EP
81	CONFIG_405EX

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

* [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
  2011-04-11 13:11 [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones) Graeme Russ
@ 2011-04-14  6:17 ` Albert ARIBAUD
  2011-04-14  8:36   ` Graeme Russ
  2011-04-14  9:14 ` Kumar Gala
  1 sibling, 1 reply; 7+ messages in thread
From: Albert ARIBAUD @ 2011-04-14  6:17 UTC (permalink / raw)
  To: u-boot

Hi Graeme,

Le 11/04/2011 15:11, Graeme Russ a ?crit :

> So my RFC is twofold:
>   1) Should we start to systematically remove unused options

I would tend to answer 'yes'. Unused options should not clobber code or 
documentation.

>   2) Should we centralise all options in a single README (or two, one for
> standard CONFIG options and one for CONFIG_SYS options)?

That would be nice indeed, but it requires all options to have the same 
semantics over all arches. While this is highly desirable, it may not be 
true ATM -- just thinking out loud, haven't checked. But even if some 
options only make sense only for some arch(es), then we could always do 
it this way:

	doc/README.CONFIG_options
	doc/README.CONFIG_SYS_options
	doc/arch/README.CONFIG_options

> Regards,
>
> Graeme

Amicalement,
-- 
Albert.

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

* [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
  2011-04-14  6:17 ` Albert ARIBAUD
@ 2011-04-14  8:36   ` Graeme Russ
  0 siblings, 0 replies; 7+ messages in thread
From: Graeme Russ @ 2011-04-14  8:36 UTC (permalink / raw)
  To: u-boot

On 14/04/11 16:17, Albert ARIBAUD wrote:
> Hi Graeme,
> 
> Le 11/04/2011 15:11, Graeme Russ a ?crit :
> 
>> So my RFC is twofold:
>>   1) Should we start to systematically remove unused options
> 
> I would tend to answer 'yes'. Unused options should not clobber code or 
> documentation.
> 
>>   2) Should we centralise all options in a single README (or two, one for
>> standard CONFIG options and one for CONFIG_SYS options)?
> 
> That would be nice indeed, but it requires all options to have the same 
> semantics over all arches. While this is highly desirable, it may not be 
> true ATM -- just thinking out loud, haven't checked. But even if some 
> options only make sense only for some arch(es), then we could always do 
> it this way:
> 
> 	doc/README.CONFIG_options
> 	doc/README.CONFIG_SYS_options
> 	doc/arch/README.CONFIG_options

Hmm, I have a better idea after I can to the realisation that the central
location for configuration options is Ctrl^F in the doc/ directory :)

	doc/README.CONFIG_options.unused
	doc/README.CONFIG_options.undocumented

I will tweak my scripts to produce these two files and see what the result is.

Regards,

Graeme

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

* [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
  2011-04-11 13:11 [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones) Graeme Russ
  2011-04-14  6:17 ` Albert ARIBAUD
@ 2011-04-14  9:14 ` Kumar Gala
  2011-04-16  7:16   ` Graeme Russ
  1 sibling, 1 reply; 7+ messages in thread
From: Kumar Gala @ 2011-04-14  9:14 UTC (permalink / raw)
  To: u-boot

>> From this it is easy to find unused options (CONFIG_ARIA is found only as a
> #define in include/configs/aria.h for example)
> 
> So my RFC is twofold:
> 1) Should we start to systematically remove unused options
> 2) Should we centralise all options in a single README (or two, one for
> standard CONFIG options and one for CONFIG_SYS options)?

Can you post data for which options are not used.  While I think automatic removal is harsh, I think something close to automatic is reasonable.

- k

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

* [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
  2011-04-14  9:14 ` Kumar Gala
@ 2011-04-16  7:16   ` Graeme Russ
  2011-04-17 13:30     ` Timur Tabi
  0 siblings, 1 reply; 7+ messages in thread
From: Graeme Russ @ 2011-04-16  7:16 UTC (permalink / raw)
  To: u-boot

On 14/04/11 19:14, Kumar Gala wrote:
>>> From this it is easy to find unused options (CONFIG_ARIA is found only as a
>> #define in include/configs/aria.h for example)
>>
>> So my RFC is twofold:
>> 1) Should we start to systematically remove unused options
>> 2) Should we centralise all options in a single README (or two, one for
>> standard CONFIG options and one for CONFIG_SYS options)?
> 
> Can you post data for which options are not used.  While I think automatic removal is harsh, I think something close to automatic is reasonable.
> 
> - k

OK, here are some quick stats:

Total CONFIG_ options : 5559
Total CONFIG_ options not documented(*)/ : 4907
Total CONFIG_ options not used in code(+) : 1136
Total CONFIG_ options not used in any board config : 645

(*) README moved into doc/ to make the count of documented options more
accurate
(+) i.e. only found in either doc/ or include/configs/

As you can see, there is scope for a LOT of code cleanup within the CONFIG_
namespace

Here is the script:

#!/bin/bash
INPUT=doc/README.configuration.options.list
OUTPUT1=doc/README.configuration.options.counted.code_usage
OUTPUT2=doc/README.configuration.options.counted.doc
OUTPUT3=doc/README.configuration.options.counted.config

echo "Catalogue Configuration Options"
grep -rhos "#define CONFIG.*" * | \
	sed 's/#define[ \t]*//' | \
	sed 's/^\([A-Za-z0-9_]*\).*/\1/' | \
	sort -u > $INPUT

echo "Counting usage of configuration options in code"
rm $OUTPUT1 2> /dev/null
for i in `cat $INPUT`
do
	x=${i}'\s'
	grep -rcs --exclude-dir=include/configs --exclude-dir=doc '\<'${i}'\>' * | \
	cut -d : -f 2 | \
	awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i >> $OUTPUT1
done
sort -n $OUTPUT1 > tmp
rm $OUTPUT1 2> /dev/null
mv tmp $OUTPUT1


echo "Counting documented options"
rm $OUTPUT2 2> /dev/null
for i in `cat $INPUT`
do
	x=${i}'\s'
	grep -rcs '\<'${i}'\>' doc/* --exclude=README.configuration.* | \
	cut -d : -f 2 | \
	awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i >> $OUTPUT2
done
sort -n $OUTPUT2 > tmp
rm $OUTPUT2 2> /dev/null
mv tmp $OUTPUT2

echo "Counting usage of configuration options in board configuration files"
rm $OUTPUT3 2> /dev/null
for i in `cat $INPUT`
do
	x=${i}'\s'
	grep -rcs '\<'${i}'\>' include/configs/* | \
	cut -d : -f 2 | \
	awk '{sum+=$1} END {printf("%d\t%s\n", sum, f);}' f=$i >> $OUTPUT3
done
sort -n $OUTPUT3 > tmp
rm $OUTPUT3 2> /dev/null
mv tmp $OUTPUT3

echo "Done"

Regards,

Graeme

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

* [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
  2011-04-16  7:16   ` Graeme Russ
@ 2011-04-17 13:30     ` Timur Tabi
  2011-04-17 19:26       ` Graeme Russ
  0 siblings, 1 reply; 7+ messages in thread
From: Timur Tabi @ 2011-04-17 13:30 UTC (permalink / raw)
  To: u-boot

On Sat, Apr 16, 2011 at 2:16 AM, Graeme Russ <graeme.russ@gmail.com> wrote:

> #!/bin/bash
> INPUT=doc/README.configuration.options.list
> OUTPUT1=doc/README.configuration.options.counted.code_usage
> OUTPUT2=doc/README.configuration.options.counted.doc
> OUTPUT3=doc/README.configuration.options.counted.config

How about Makefiles?  Sometimes a CONFIG option is used only in a Makefiles.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones)
  2011-04-17 13:30     ` Timur Tabi
@ 2011-04-17 19:26       ` Graeme Russ
  0 siblings, 0 replies; 7+ messages in thread
From: Graeme Russ @ 2011-04-17 19:26 UTC (permalink / raw)
  To: u-boot

On Sunday, April 17, 2011, Timur Tabi <timur@freescale.com> wrote:
> On Sat, Apr 16, 2011 at 2:16 AM, Graeme Russ <graeme.russ@gmail.com> wrote:
>
>> #!/bin/bash
>> INPUT=doc/README.configuration.options.list
>> OUTPUT1=doc/README.configuration.options.counted.code_usage
>> OUTPUT2=doc/README.configuration.options.counted.doc
>> OUTPUT3=doc/README.configuration.options.counted.config
>
> How about Makefiles? ?Sometimes a CONFIG option is used only in a Makefiles.
>

code_usage includes Makefiles

Regards,

Graeme

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

end of thread, other threads:[~2011-04-17 19:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-11 13:11 [U-Boot] [RFC] Centralise documentation of CONFIG_ options (and finding unused ones) Graeme Russ
2011-04-14  6:17 ` Albert ARIBAUD
2011-04-14  8:36   ` Graeme Russ
2011-04-14  9:14 ` Kumar Gala
2011-04-16  7:16   ` Graeme Russ
2011-04-17 13:30     ` Timur Tabi
2011-04-17 19:26       ` Graeme Russ

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.