<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/scripts/kconfig/expr.c, branch v6.12.80</title>
<subtitle>Clone of https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git</subtitle>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/'/>
<entry>
<title>kconfig: clear expr::val_is_valid when allocated</title>
<updated>2024-10-01T08:05:30+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-30T17:02:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=8d095547debdd26583171a6b589acbc9fd76aa9f'/>
<id>8d095547debdd26583171a6b589acbc9fd76aa9f</id>
<content type='text'>
Since commit 95573cac25c6 ("kconfig: cache expression values"), xconfig
emits a lot of false-positive "unmet direct dependencies" warnings.

While conf_read() clears val_is_valid flags, 'make xconfig' calculates
symbol values even before the conf_read() call. This is another issue
that should be addressed separately, but it has revealed that the
val_is_valid field is not initialized.

Fixes: 95573cac25c6 ("kconfig: cache expression values")
Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since commit 95573cac25c6 ("kconfig: cache expression values"), xconfig
emits a lot of false-positive "unmet direct dependencies" warnings.

While conf_read() clears val_is_valid flags, 'make xconfig' calculates
symbol values even before the conf_read() call. This is another issue
that should be addressed separately, but it has revealed that the
val_is_valid field is not initialized.

Fixes: 95573cac25c6 ("kconfig: cache expression values")
Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: cache expression values</title>
<updated>2024-09-20T00:21:53+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-08T12:43:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=95573cac25c6b11f02d599d18e9a1c778706e838'/>
<id>95573cac25c6b11f02d599d18e9a1c778706e838</id>
<content type='text'>
Cache expression values to avoid recalculating them repeatedly.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Cache expression values to avoid recalculating them repeatedly.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: use hash table to reuse expressions</title>
<updated>2024-09-20T00:21:52+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-08T12:43:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=f93d6bfbd2f74d79041c153a59df5336f6e9a14a'/>
<id>f93d6bfbd2f74d79041c153a59df5336f6e9a14a</id>
<content type='text'>
Currently, every expression in Kconfig files produces a new abstract
syntax tree (AST), even if it is identical to a previously encountered
one.

Consider the following code:

    config FOO
           bool "FOO"
           depends on (A || B) &amp;&amp; C

    config BAR
           bool "BAR"
           depends on (A || B) &amp;&amp; C

    config BAZ
           bool "BAZ"
           depends on A || B

The "depends on" lines are similar, but currently a separate AST is
allocated for each one.

The current data structure looks like this:

  FOO-&gt;dep ==&gt; AND        BAR-&gt;dep ==&gt; AND        BAZ-&gt;dep ==&gt; OR
              /   \                   /   \                   /  \
            OR     C                OR     C                 A    B
           /  \                    /  \
          A    B                  A    B

This is redundant; FOO-&gt;dep and BAR-&gt;dep have identical ASTs but
different memory instances.

We can optimize this; FOO-&gt;dep and BAR-&gt;dep can share the same AST, and
BAZ-&gt;dep can reference its sub tree.

The optimized data structure looks like this:

  FOO-&gt;dep, BAR-&gt;dep ==&gt; AND
                        /   \
         BAZ-&gt;dep ==&gt; OR     C
                     /  \
                    A    B

This commit introduces a hash table to keep track of allocated
expressions. If an identical expression is found, it is reused.

This does not necessarily result in memory savings, as menu_finalize()
transforms expressions without freeing up stale ones. This will be
addressed later.

One optimization that can be easily implemented is caching the
expression's value. Once FOO's dependency, (A || B) &amp;&amp; C, is calculated,
it can be cached, eliminating the need to recalculate it for BAR.

This commit also reverts commit e983b7b17ad1 ("kconfig/menu.c: fix
multiple references to expressions in menu_add_prop()").

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, every expression in Kconfig files produces a new abstract
syntax tree (AST), even if it is identical to a previously encountered
one.

Consider the following code:

    config FOO
           bool "FOO"
           depends on (A || B) &amp;&amp; C

    config BAR
           bool "BAR"
           depends on (A || B) &amp;&amp; C

    config BAZ
           bool "BAZ"
           depends on A || B

The "depends on" lines are similar, but currently a separate AST is
allocated for each one.

The current data structure looks like this:

  FOO-&gt;dep ==&gt; AND        BAR-&gt;dep ==&gt; AND        BAZ-&gt;dep ==&gt; OR
              /   \                   /   \                   /  \
            OR     C                OR     C                 A    B
           /  \                    /  \
          A    B                  A    B

This is redundant; FOO-&gt;dep and BAR-&gt;dep have identical ASTs but
different memory instances.

We can optimize this; FOO-&gt;dep and BAR-&gt;dep can share the same AST, and
BAZ-&gt;dep can reference its sub tree.

The optimized data structure looks like this:

  FOO-&gt;dep, BAR-&gt;dep ==&gt; AND
                        /   \
         BAZ-&gt;dep ==&gt; OR     C
                     /  \
                    A    B

This commit introduces a hash table to keep track of allocated
expressions. If an identical expression is found, it is reused.

This does not necessarily result in memory savings, as menu_finalize()
transforms expressions without freeing up stale ones. This will be
addressed later.

One optimization that can be easily implemented is caching the
expression's value. Once FOO's dependency, (A || B) &amp;&amp; C, is calculated,
it can be cached, eliminating the need to recalculate it for BAR.

This commit also reverts commit e983b7b17ad1 ("kconfig/menu.c: fix
multiple references to expressions in menu_add_prop()").

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: refactor expr_eliminate_dups()</title>
<updated>2024-09-20T00:21:52+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-08T12:43:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=440f67ccdcd31ca33d8d0439b16e4b6d4d7aba17'/>
<id>440f67ccdcd31ca33d8d0439b16e4b6d4d7aba17</id>
<content type='text'>
Currently, expr_eliminate_dups() passes two identical pointers down to
expr_eliminate_dups1(), which later skips processing identical leaves.

This approach is somewhat tricky and, more importantly, it will not work
with the refactoring made in the next commit.

This commit slightly changes the recursion logic; it deduplicates both
the left and right arms, and then passes them to expr_eliminate_dups1().
expr_eliminate_dups() should produce the same result.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, expr_eliminate_dups() passes two identical pointers down to
expr_eliminate_dups1(), which later skips processing identical leaves.

This approach is somewhat tricky and, more importantly, it will not work
with the refactoring made in the next commit.

This commit slightly changes the recursion logic; it deduplicates both
the left and right arms, and then passes them to expr_eliminate_dups1().
expr_eliminate_dups() should produce the same result.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: add comments to expression transformations</title>
<updated>2024-09-20T00:21:52+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-08T12:43:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=4fa146eaecaee6301e8f5b104fe63b41afdf83e6'/>
<id>4fa146eaecaee6301e8f5b104fe63b41afdf83e6</id>
<content type='text'>
Provide explanations for complex transformations.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Provide explanations for complex transformations.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: change some expr_*() functions to bool</title>
<updated>2024-09-20T00:21:52+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-09-08T12:43:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=d607e0e7a8d2ea6565f11064d28b0825a95748aa'/>
<id>d607e0e7a8d2ea6565f11064d28b0825a95748aa</id>
<content type='text'>
This clarifies the behavior of these functions.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This clarifies the behavior of these functions.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kbuild: split x*alloc() functions in kconfig to scripts/include/xalloc.h</title>
<updated>2024-09-01T11:34:48+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-08-12T12:48:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=a9d83d74783b00f9189c14180f77bbed133b092c'/>
<id>a9d83d74783b00f9189c14180f77bbed133b092c</id>
<content type='text'>
These functions will be useful for other host programs.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These functions will be useful for other host programs.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: remove 'e1' and 'e2' macros from expression deduplication</title>
<updated>2024-07-20T04:34:18+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-07-07T15:38:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=3c2f84cedaeb2fe9575dd3f6edddf0d875b3b97c'/>
<id>3c2f84cedaeb2fe9575dd3f6edddf0d875b3b97c</id>
<content type='text'>
I do not think the macros 'e1' and 'e2' are readable.

The statement:

    e1 = expr_alloc_symbol(...);

affects the caller's variable, but this is not sufficiently clear from the code.

Remove the macros. No functional change intended.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I do not think the macros 'e1' and 'e2' are readable.

The statement:

    e1 = expr_alloc_symbol(...);

affects the caller's variable, but this is not sufficiently clear from the code.

Remove the macros. No functional change intended.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: add const qualifiers to several function arguments</title>
<updated>2024-07-16T07:07:14+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-07-07T15:38:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=6425e3b247b1eff04c64091b2af8811d05546a86'/>
<id>6425e3b247b1eff04c64091b2af8811d05546a86</id>
<content type='text'>
Clarify that the given structures are not modified.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Clarify that the given structures are not modified.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kconfig: call expr_eliminate_yn() at least once in expr_eliminate_dups()</title>
<updated>2024-07-16T07:07:14+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-07-07T15:38:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=8bfd6f0923cd7e48aa5d9e5a4e20af818a32c30a'/>
<id>8bfd6f0923cd7e48aa5d9e5a4e20af818a32c30a</id>
<content type='text'>
Kconfig simplifies expressions, but redundant '&amp;&amp;' and '||' operators
involving constant symbols 'y' and 'n' are sometimes trimmed and
sometimes not.

[Test Code]

    config DEP
            def_bool y

    config A
            bool "A"
            depends on DEP &amp;&amp; y

    config B
            bool "B"
            depends on DEP &amp;&amp; y &amp;&amp; y

[Result]

    $ make helpnewconfig
      [ snip ]
    -----

    There is no help available for this option.
    Symbol: A [=n]
    Type  : bool
    Defined at Kconfig:4
      Prompt: A
      Depends on: DEP [=y] &amp;&amp; y [=y]
      Location:
        -&gt; A (A [=n])

    -----
    -----

    There is no help available for this option.
    Symbol: B [=n]
    Type  : bool
    Defined at Kconfig:8
      Prompt: B
      Depends on: DEP [=y]
      Location:
        -&gt; B (B [=n])

    -----

The dependency for A, 'DEP &amp;&amp; y', remains as-is, while that for B,
'DEP &amp;&amp; y &amp;&amp; y', has been reduced to 'DEP'.

Currently, expr_eliminate_dups() calls expr_eliminate_yn() only when
trans_count != 0, in other words, only when expr_eliminate_dups1() has
trimmed at least one leaf. It fails to trim a single '&amp;&amp; y', etc.

To fix this inconsistent behavior, expr_eliminate_yn() should be called
at least once even if no leaf has been trimmed.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Kconfig simplifies expressions, but redundant '&amp;&amp;' and '||' operators
involving constant symbols 'y' and 'n' are sometimes trimmed and
sometimes not.

[Test Code]

    config DEP
            def_bool y

    config A
            bool "A"
            depends on DEP &amp;&amp; y

    config B
            bool "B"
            depends on DEP &amp;&amp; y &amp;&amp; y

[Result]

    $ make helpnewconfig
      [ snip ]
    -----

    There is no help available for this option.
    Symbol: A [=n]
    Type  : bool
    Defined at Kconfig:4
      Prompt: A
      Depends on: DEP [=y] &amp;&amp; y [=y]
      Location:
        -&gt; A (A [=n])

    -----
    -----

    There is no help available for this option.
    Symbol: B [=n]
    Type  : bool
    Defined at Kconfig:8
      Prompt: B
      Depends on: DEP [=y]
      Location:
        -&gt; B (B [=n])

    -----

The dependency for A, 'DEP &amp;&amp; y', remains as-is, while that for B,
'DEP &amp;&amp; y &amp;&amp; y', has been reduced to 'DEP'.

Currently, expr_eliminate_dups() calls expr_eliminate_yn() only when
trans_count != 0, in other words, only when expr_eliminate_dups1() has
trimmed at least one leaf. It fails to trim a single '&amp;&amp; y', etc.

To fix this inconsistent behavior, expr_eliminate_yn() should be called
at least once even if no leaf has been trimmed.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
