<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/scripts/coccicheck, branch v6.18.21</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>kbuild: change working directory to external module directory with M=</title>
<updated>2024-11-27T23:10:23+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2024-11-10T01:34:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=13b25489b6f8bd73ed65f07928f7c27a481f1820'/>
<id>13b25489b6f8bd73ed65f07928f7c27a481f1820</id>
<content type='text'>
Currently, Kbuild always operates in the output directory of the kernel,
even when building external modules. This increases the risk of external
module Makefiles attempting to write to the kernel directory.

This commit switches the working directory to the external module
directory, allowing the removal of the $(KBUILD_EXTMOD)/ prefix from
some build artifacts.

The command for building external modules maintains backward
compatibility, but Makefiles that rely on working in the kernel
directory may break. In such cases, $(objtree) and $(srctree) should
be used to refer to the output and source directories of the kernel.

The appearance of the build log will change as follows:

[Before]

  $ make -C /path/to/my/linux M=/path/to/my/externel/module
  make: Entering directory '/path/to/my/linux'
    CC [M]  /path/to/my/externel/module/helloworld.o
    MODPOST /path/to/my/externel/module/Module.symvers
    CC [M]  /path/to/my/externel/module/helloworld.mod.o
    CC [M]  /path/to/my/externel/module/.module-common.o
    LD [M]  /path/to/my/externel/module/helloworld.ko
  make: Leaving directory '/path/to/my/linux'

[After]

  $ make -C /path/to/my/linux M=/path/to/my/externel/module
  make: Entering directory '/path/to/my/linux'
  make[1]: Entering directory '/path/to/my/externel/module'
    CC [M]  helloworld.o
    MODPOST Module.symvers
    CC [M]  helloworld.mod.o
    CC [M]  .module-common.o
    LD [M]  helloworld.ko
  make[1]: Leaving directory '/path/to/my/externel/module'
  make: Leaving directory '/path/to/my/linux'

Printing "Entering directory" twice is cumbersome. This will be
addressed later.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Reviewed-by: Nicolas Schier &lt;n.schier@avm.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, Kbuild always operates in the output directory of the kernel,
even when building external modules. This increases the risk of external
module Makefiles attempting to write to the kernel directory.

This commit switches the working directory to the external module
directory, allowing the removal of the $(KBUILD_EXTMOD)/ prefix from
some build artifacts.

The command for building external modules maintains backward
compatibility, but Makefiles that rely on working in the kernel
directory may break. In such cases, $(objtree) and $(srctree) should
be used to refer to the output and source directories of the kernel.

The appearance of the build log will change as follows:

[Before]

  $ make -C /path/to/my/linux M=/path/to/my/externel/module
  make: Entering directory '/path/to/my/linux'
    CC [M]  /path/to/my/externel/module/helloworld.o
    MODPOST /path/to/my/externel/module/Module.symvers
    CC [M]  /path/to/my/externel/module/helloworld.mod.o
    CC [M]  /path/to/my/externel/module/.module-common.o
    LD [M]  /path/to/my/externel/module/helloworld.ko
  make: Leaving directory '/path/to/my/linux'

[After]

  $ make -C /path/to/my/linux M=/path/to/my/externel/module
  make: Entering directory '/path/to/my/linux'
  make[1]: Entering directory '/path/to/my/externel/module'
    CC [M]  helloworld.o
    MODPOST Module.symvers
    CC [M]  helloworld.mod.o
    CC [M]  .module-common.o
    LD [M]  helloworld.ko
  make[1]: Leaving directory '/path/to/my/externel/module'
  make: Leaving directory '/path/to/my/linux'

Printing "Entering directory" twice is cumbersome. This will be
addressed later.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Reviewed-by: Nicolas Schier &lt;n.schier@avm.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: Use /usr/bin/env</title>
<updated>2023-02-25T19:11:06+00:00</updated>
<author>
<name>Jarkko Sakkinen</name>
<email>jarkko@kernel.org</email>
</author>
<published>2023-01-26T21:56:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=2b2d50bdd258f8ef37c25f7d5f0d7ba694066dec'/>
<id>2b2d50bdd258f8ef37c25f7d5f0d7ba694066dec</id>
<content type='text'>
If bash is not located under /bin, coccicheck fails to run.  In the real
world, this happens for instance when NixOS is used in the host.  Instead,
use /usr/bin/env to locate the executable binary for bash.

Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Tested-by: Deepak R Varma &lt;drv@mailo.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If bash is not located under /bin, coccicheck fails to run.  In the real
world, this happens for instance when NixOS is used in the host.  Instead,
use /usr/bin/env to locate the executable binary for bash.

Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Tested-by: Deepak R Varma &lt;drv@mailo.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: Avoid warning about spurious escape</title>
<updated>2023-02-25T19:08:50+00:00</updated>
<author>
<name>Peter Foley</name>
<email>pefoley2@pefoley.com</email>
</author>
<published>2023-01-13T17:29:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=180da5ef84fba0a8ea06870a38d6d657d689944a'/>
<id>180da5ef84fba0a8ea06870a38d6d657d689944a</id>
<content type='text'>
e.g.
grep: warning: stray \ before -

Signed-off-by: Peter Foley &lt;pefoley2@pefoley.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
e.g.
grep: warning: stray \ before -

Signed-off-by: Peter Foley &lt;pefoley2@pefoley.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: use "grep -E" instead of "egrep"</title>
<updated>2022-09-21T19:23:56+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2022-09-21T09:13:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=2d63e6a3d97132449451c2f66fe24a2dc4e2938f'/>
<id>2d63e6a3d97132449451c2f66fe24a2dc4e2938f</id>
<content type='text'>
The latest version of grep claims that egrep is now obsolete so the build
now contains warnings that look like:
        egrep: warning: egrep is obsolescent; using grep -E
fix this up by moving the vdso Makefile to use "grep -E" instead.

Cc: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
Cc: Nicolas Palix &lt;nicolas.palix@imag.fr&gt;
Cc: cocci@inria.fr
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The latest version of grep claims that egrep is now obsolete so the build
now contains warnings that look like:
        egrep: warning: egrep is obsolescent; using grep -E
fix this up by moving the vdso Makefile to use "grep -E" instead.

Cc: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
Cc: Nicolas Palix &lt;nicolas.palix@imag.fr&gt;
Cc: cocci@inria.fr
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: fix troubles on non-English builds</title>
<updated>2021-05-18T09:09:59+00:00</updated>
<author>
<name>Mauro Carvalho Chehab</name>
<email>mchehab+huawei@kernel.org</email>
</author>
<published>2021-05-18T09:05:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=f5b3553b5019f22ac668651ea9cddb9fa675ac41'/>
<id>f5b3553b5019f22ac668651ea9cddb9fa675ac41</id>
<content type='text'>
When LANG is not set to English, the logic which checks the
number of CPUs fail, as the messages can be localized, and
the logic at:

    THREADS_PER_CORE=$(lscpu | grep "Thread(s) per core: " | tr -cd "[:digit:]")

will not get the number of threads per core.

This causes the script to not run properly, as it will produce
a warning:

	$ make coccicheck COCCI=$PWD/scripts/coccinelle/misc/add_namespace.cocci MODE=report drivers/media/
	./scripts/coccicheck: linha 93: [: número excessivo de argumentos

Fix it by forcing LANG=C when calling lscpu.

Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+huawei@kernel.org&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When LANG is not set to English, the logic which checks the
number of CPUs fail, as the messages can be localized, and
the logic at:

    THREADS_PER_CORE=$(lscpu | grep "Thread(s) per core: " | tr -cd "[:digit:]")

will not get the number of threads per core.

This causes the script to not run properly, as it will produce
a warning:

	$ make coccicheck COCCI=$PWD/scripts/coccinelle/misc/add_namespace.cocci MODE=report drivers/media/
	./scripts/coccicheck: linha 93: [: número excessivo de argumentos

Fix it by forcing LANG=C when calling lscpu.

Signed-off-by: Mauro Carvalho Chehab &lt;mchehab+huawei@kernel.org&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: Correct usage of make coccicheck</title>
<updated>2020-12-24T11:59:43+00:00</updated>
<author>
<name>Sumera Priyadarsini</name>
<email>sylphrenadin@gmail.com</email>
</author>
<published>2020-11-24T20:32:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=d8f6e5c6c83737cfdad46077e614885a3db9e809'/>
<id>d8f6e5c6c83737cfdad46077e614885a3db9e809</id>
<content type='text'>
The command "make coccicheck C=1 CHECK=scripts/coccicheck" results in the
error:
        ./scripts/coccicheck: line 65: -1: shift count out of range

This happens because every time the C variable is specified,
the shell arguments need to be "shifted" in order to take only
the last argument, which is the C file to test. These shell arguments
mostly comprise flags that have been set in the Makefile. However,
when coccicheck is specified in the make command as a rule, the
number of shell arguments is zero, thus passing the invalid value -1
to the shift command, resulting in an error.

Modify coccicheck to print correct usage of make coccicheck so as to
avoid the error.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The command "make coccicheck C=1 CHECK=scripts/coccicheck" results in the
error:
        ./scripts/coccicheck: line 65: -1: shift count out of range

This happens because every time the C variable is specified,
the shell arguments need to be "shifted" in order to take only
the last argument, which is the C file to test. These shell arguments
mostly comprise flags that have been set in the Makefile. However,
when coccicheck is specified in the make command as a rule, the
number of shell arguments is zero, thus passing the invalid value -1
to the shift command, resulting in an error.

Modify coccicheck to print correct usage of make coccicheck so as to
avoid the error.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kbuild: do not use scripts/ld-version.sh for checking spatch version</title>
<updated>2020-12-12T17:31:29+00:00</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-12-12T16:54:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=33114c4359592d5c8a3d840eee9ff40039caf26f'/>
<id>33114c4359592d5c8a3d840eee9ff40039caf26f</id>
<content type='text'>
scripts/ld-version.sh was, as its file name implies, originally intended
for the GNU ld version, but is (ab)used for the spatch version too.

Use 'sort -CV' for the version comparison, then coccicheck does not need
to use scripts/ld-version.sh. Fix nsdeps as well.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
scripts/ld-version.sh was, as its file name implies, originally intended
for the GNU ld version, but is (ab)used for the spatch version too.

Use 'sort -CV' for the version comparison, then coccicheck does not need
to use scripts/ld-version.sh. Fix nsdeps as well.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: Change default condition for parallelism</title>
<updated>2020-10-12T08:37:56+00:00</updated>
<author>
<name>Sumera Priyadarsini</name>
<email>sylphrenadin@gmail.com</email>
</author>
<published>2020-10-11T10:29:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=c5864560d935db879cafa21feca0156d91eba842'/>
<id>c5864560d935db879cafa21feca0156d91eba842</id>
<content type='text'>
Currently, Coccinelle uses at most one thread per core by default in
machines with more than 2 hyperthreads. However, for systems with only 4
hyperthreads, this does not improve performance.

Modify coccicheck to use all available threads in machines with
upto 4 hyperthreads.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, Coccinelle uses at most one thread per core by default in
machines with more than 2 hyperthreads. However, for systems with only 4
hyperthreads, this does not improve performance.

Modify coccicheck to use all available threads in machines with
upto 4 hyperthreads.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: Add quotes to improve portability</title>
<updated>2020-10-12T08:32:40+00:00</updated>
<author>
<name>Sumera Priyadarsini</name>
<email>sylphrenadin@gmail.com</email>
</author>
<published>2020-10-11T10:28:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=2f324dd8ab2e3d8b097f3eac6d380d1adbdbe6e6'/>
<id>2f324dd8ab2e3d8b097f3eac6d380d1adbdbe6e6</id>
<content type='text'>
While fetching the number of threads per core with lscpu,
the [:digit:] set is used for translation of digits from 0-9.
However, using [:digit:] instead of "[:digit:]" does not seem
to work uniformly for some shell types and configurations
(such as zsh).

Therefore, modify coccicheck to use double quotes around the
[:digit:] set for uniformity and better portability.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While fetching the number of threads per core with lscpu,
the [:digit:] set is used for translation of digits from 0-9.
However, using [:digit:] instead of "[:digit:]" does not seem
to work uniformly for some shell types and configurations
(such as zsh).

Therefore, modify coccicheck to use double quotes around the
[:digit:] set for uniformity and better portability.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: coccicheck: Change default value for parallelism</title>
<updated>2020-09-27T20:52:59+00:00</updated>
<author>
<name>Sumera Priyadarsini</name>
<email>sylphrenadin@gmail.com</email>
</author>
<published>2020-09-24T11:26:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=e16a7c47d56b4eeee82be662014c145bce2380e5'/>
<id>e16a7c47d56b4eeee82be662014c145bce2380e5</id>
<content type='text'>
By default, coccicheck utilizes all available threads to implement
parallelisation. However, when all available threads are used,
a decrease in performance is noted. The elapsed time is  minimum
when at most one thread per core is used.

For example, on benchmarking the semantic patch kfree.cocci for
usb/serial using hyperfine, the outputs obtained for J=5 and J=2
are 1.32 and 1.90 times faster than those for J=10 and J=9
respectively for two separate runs. For the larger drivers/staging
directory, minimium elapsed time is obtained for J=3 which is 1.86
times faster than that for J=12. The optimal J value does not
exceed 6 in any of the test runs. The benchmarks are run on a machine
with 6 cores, with 2 threads per core, i.e, 12 hyperthreads in all.

To improve performance, modify coccicheck to use at most only
one thread per core by default.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
By default, coccicheck utilizes all available threads to implement
parallelisation. However, when all available threads are used,
a decrease in performance is noted. The elapsed time is  minimum
when at most one thread per core is used.

For example, on benchmarking the semantic patch kfree.cocci for
usb/serial using hyperfine, the outputs obtained for J=5 and J=2
are 1.32 and 1.90 times faster than those for J=10 and J=9
respectively for two separate runs. For the larger drivers/staging
directory, minimium elapsed time is obtained for J=3 which is 1.86
times faster than that for J=12. The optimal J value does not
exceed 6 in any of the test runs. The benchmarks are run on a machine
with 6 cores, with 2 threads per core, i.e, 12 hyperthreads in all.

To improve performance, modify coccicheck to use at most only
one thread per core by default.

Signed-off-by: Sumera Priyadarsini &lt;sylphrenadin@gmail.com&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
</pre>
</div>
</content>
</entry>
</feed>
