Skip to contentSkip to conversation

selftests/damon: add damon to selftests root Makefile

PATCH RESEND In review Yuanchu Xie 4 participants 16 messages Apr 18, 2022 – May 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 selftests/damon: add damon to selftests root Makefile

Currently the damon selftests are not built with the rest of the selftests. We add damon to the list of targets.

Fixes b348eb7abd09 ("mm/damon: add user space selftests")
---
 tools/testing/selftests/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/Makefile +1 -0
index d08fe4cfe811..ffe453760a12 100644
@@ -9,6 +9,7 @@ TARGETS += clone3
 TARGETS += core
 TARGETS += cpufreq
 TARGETS += cpu-hotplug
+TARGETS += damon
 TARGETS += drivers/dma-buf
 TARGETS += efivarfs
 TARGETS += exec
Signature · 1 line
2.35.1.265.g69c8d7142f-goog
maintainer
#3 lore raw
Quoted 6 lines · Shuah Khan
Quoted 5 lines · David Rientjes
Quoted 3 lines · Yuanchu Xie

Currently the damon selftests are not built with the rest of the selftests. We add damon to the list of targets.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Fixes b348eb7abd09 ("mm/damon: add user space selftests")

Thank you. Applied to linux-kselftest next for 5.19-rc1.

The test builds with warnings. Would you like to fix these as well?

make
gcc huge_count_read_write.c -o linux_5.18/tools/testing/selftests/damon/huge_count_read_write
huge_count_read_write.c: In function ‘write_read_with_huge_count’:
huge_count_read_write.c:23:9: warning: ‘write’ reading 4294967295 bytes from a region of size 1 [-Wstringop-overread]

   23 |         write(filedesc, "", 0xfffffffful);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from huge_count_read_write.c:8:
/usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with attribute ‘access (read_only, 2, 3)’
  378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~
huge_count_read_write.c:25:15: warning: ‘read’ writing 4294967295 bytes into a region of size 25 overflows the destination [-Wstringop-overflow=]
   25 |         ret = read(filedesc, buf, 0xfffffffful);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

huge_count_read_write.c:14:14: note: destination object ‘buf’ of size 25
14 | char buf[25];
| ^~~
In file included from huge_count_read_write.c:8:
/usr/include/unistd.h:371:16: note: in a call to function ‘read’ declared with attribute ‘access (write_only, 2, 3)’
371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
| ^~~~

thanks,
-- Shuah

#4 lore raw

PATCH v2 1/2 selftests/damon: suppress compiler warnings for huge_count_read_write

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

---
 tools/testing/selftests/damon/Makefile | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/damon/Makefile +3 -0
index 0470c5f3e690..a300b4c5b373 100644
@@ -1,6 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for damon selftests
 
+CFLAGS += -Wno-stringop-overread
+CFLAGS += -Wno-stringop-overflow
+
 TEST_GEN_FILES += huge_count_read_write
 
 TEST_FILES = _chk_dependency.sh _debugfs_common.sh
Signature · 1 line
2.36.0.464.gb9c8b46e94-goog
#5 lore raw

PATCH v2 2/2 selftests/damon: add damon to selftests root Makefile

Currently the damon selftests are not built with the rest of the selftests. We add damon to the list of targets.

Fixes b348eb7abd09 ("mm/damon: add user space selftests")
---
 tools/testing/selftests/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/Makefile +1 -0
index 2319ec87f53d..bd2ac8b3bf1f 100644
@@ -9,6 +9,7 @@ TARGETS += clone3
 TARGETS += core
 TARGETS += cpufreq
 TARGETS += cpu-hotplug
+TARGETS += damon
 TARGETS += drivers/dma-buf
 TARGETS += efivarfs
 TARGETS += exec
Signature · 1 line
2.36.0.464.gb9c8b46e94-goog
maintainer Reviewed-by on v2 2/2
#6 lore raw
Quoted 5 lines · On Wed, 4 May 2022 00:03:58 +0000 Yuanchu Xie <[email protected]> wrote:

Currently the damon selftests are not built with the rest of the selftests. We add damon to the list of targets.

Fixes b348eb7abd09 ("mm/damon: add user space selftests")

Thanks,
SJ

Quoted 18 lines
---
 tools/testing/selftests/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/Makefile +1 -0
index 2319ec87f53d..bd2ac8b3bf1f 100644
@@ -9,6 +9,7 @@ TARGETS += clone3
 TARGETS += core
 TARGETS += cpufreq
 TARGETS += cpu-hotplug
+TARGETS += damon
 TARGETS += drivers/dma-buf
 TARGETS += efivarfs
 TARGETS += exec
Signature · 1 line
2.36.0.464.gb9c8b46e94-goog
maintainer Reviewed-by on v2 1/2
#8 lore raw

Re: [PATCH v2 1/2] selftests/damon: suppress compiler warnings for huge_count_read_write

In reply to Yuanchu Xie

Hi Yuanchu, thank you for this patch!

Quoted 7 lines · On Wed, 4 May 2022 00:03:57 +0000 Yuanchu Xie <[email protected]> wrote:

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

Thanks,
SJ

[...]

Quoted 21 lines
---
 tools/testing/selftests/damon/Makefile | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/damon/Makefile +3 -0
index 0470c5f3e690..a300b4c5b373 100644
@@ -1,6 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for damon selftests
 
+CFLAGS += -Wno-stringop-overread
+CFLAGS += -Wno-stringop-overflow
+
 TEST_GEN_FILES += huge_count_read_write
 
 TEST_FILES = _chk_dependency.sh _debugfs_common.sh
Signature · 1 line
2.36.0.464.gb9c8b46e94-goog
#9 lore raw

PATCH v3 1/1 selftests/damon: suppress compiler warnings for huge_count_read_write

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

---
 tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/damon/huge_count_read_write.c +2 -0
index ad7a6b4cf338..91bd80c75cd9 100644
@@ -2,6 +2,8 @@
 /*
  * Author: SeongJae Park <[email protected]>
  */
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"
 
 #include <fcntl.h>
 #include <stdlib.h>
Signature · 1 line
2.36.0.464.gb9c8b46e94-goog
#10 lore raw

Re: [PATCH v3] selftests/damon: suppress compiler warnings for huge_count_read_write

Hi SeongJae,

Instead of adding the exception to the Makefile, these two pragmas can be added to the offending c file instead. Although it is fairly minor and either one works but I think this is cleaner.

Thanks,
Yuanchu

maintainer
#11 lore raw

Re: [PATCH v3] selftests/damon: suppress compiler warnings for huge_count_read_write

In reply to Yuanchu Xie

Hi Yuanchu,

Quoted 8 lines · On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <[email protected]> wrote:

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

---

It would be a good practice to mention the changes from the previous version of this patch here[1].

[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

tools/testing/selftests/damon/huge_count_read_write.c line 6

Quoted 13 lines
 tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/damon/huge_count_read_write.c +2 -0
index ad7a6b4cf338..91bd80c75cd9 100644
@@ -2,6 +2,8 @@
 /*
  * Author: SeongJae Park <[email protected]>
  */
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"

I agree that this must be the cleaner way than v2. But, I get below warning after applying this:

    $ sudo make -C tools/testing/selftests/damon run_tests
    make: Entering directory '/home/sjpark/linux/tools/testing/selftests/damon'
    gcc     huge_count_read_write.c  -o /home/sjpark/linux/tools/testing/selftests/damon/huge_count_read_write
    huge_count_read_write.c:6:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
        6 | #pragma GCC diagnostic ignored "-Wstringop-overread"
          |                                ^~~~~~~~~~~~~~~~~~~~~

My gcc version is:

    $ gcc --version
    gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

Thanks,
SJ

Quoted 6 lines
tools/testing/selftests/damon/huge_count_read_write.c +0 -0
 #include <fcntl.h>
 #include <stdlib.h>
Signature · 1 line
2.36.0.464.gb9c8b46e94-goog
#12 lore raw

Re: [PATCH v3] selftests/damon: suppress compiler warnings for huge_count_read_write

Hi SeongJae,

Quoted 11 lines · SeongJae Park

Hi Yuanchu,

Quoted 6 lines · On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <[email protected]> wrote:

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

Quoted 8 lines
Quoted 2 lines

---

It would be a good practice to mention the changes from the previous version of this patch here[1].

[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

Thank you, I missed this when trying to figure out how to add additional comments for a revision.

Quoted 24 lines

tools/testing/selftests/damon/huge_count_read_write.c line 6

Quoted 13 lines
 tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/damon/huge_count_read_write.c +2 -0
index ad7a6b4cf338..91bd80c75cd9 100644
@@ -2,6 +2,8 @@
 /*
  * Author: SeongJae Park <[email protected]>
  */
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"

I agree that this must be the cleaner way than v2. But, I get below warning after applying this:

    $ sudo make -C tools/testing/selftests/damon run_tests
    make: Entering directory '/home/sjpark/linux/tools/testing/selftests/damon'
    gcc     huge_count_read_write.c  -o /home/sjpark/linux/tools/testing/selftests/damon/huge_count_read_write
    huge_count_read_write.c:6:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
        6 | #pragma GCC diagnostic ignored "-Wstringop-overread"
          |                                ^~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines

My gcc version is:

    $ gcc --version
    gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

I see, I'm running

    $ gcc --version
    gcc (Debian 11.2.0-16+build1) 11.2.0

I believe this is a new warning for gcc-11 [1], and somewhat unfortunate that it results in a warning for gcc-9.4. I'm not sure what the preference is here.
[1] https://gcc.gnu.org/onlinedocs/gcc-10.3.0/gcc/Warning-Options.html

Thanks,
Yuanchu

#13 lore raw

Re: [PATCH v3] selftests/damon: suppress compiler warnings for huge_count_read_write

SeongJae,

Do you have a preference on how this should be handled?

Thanks,
Yuanchu

Quoted 66 lines · Yuanchu Xie

Hi SeongJae,

Quoted 11 lines · SeongJae Park

Hi Yuanchu,

Quoted 6 lines · On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <[email protected]> wrote:

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

Quoted 8 lines
Quoted 2 lines

---

It would be a good practice to mention the changes from the previous version of this patch here[1].

[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

Thank you, I missed this when trying to figure out how to add additional comments for a revision.

Quoted 24 lines

tools/testing/selftests/damon/huge_count_read_write.c line 6

Quoted 13 lines
 tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/damon/huge_count_read_write.c +2 -0
index ad7a6b4cf338..91bd80c75cd9 100644
@@ -2,6 +2,8 @@
 /*
  * Author: SeongJae Park <[email protected]>
  */
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"

I agree that this must be the cleaner way than v2. But, I get below warning after applying this:

    $ sudo make -C tools/testing/selftests/damon run_tests
    make: Entering directory '/home/sjpark/linux/tools/testing/selftests/damon'
    gcc     huge_count_read_write.c  -o /home/sjpark/linux/tools/testing/selftests/damon/huge_count_read_write
    huge_count_read_write.c:6:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
        6 | #pragma GCC diagnostic ignored "-Wstringop-overread"
          |                                ^~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines

My gcc version is:

    $ gcc --version
    gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

I see, I'm running

    $ gcc --version
    gcc (Debian 11.2.0-16+build1) 11.2.0

I believe this is a new warning for gcc-11 [1], and somewhat unfortunate that it results in a warning for gcc-9.4. I'm not sure what the preference is here.
[1] https://gcc.gnu.org/onlinedocs/gcc-10.3.0/gcc/Warning-Options.html

Thanks,
Yuanchu

maintainer
#14 lore raw

Re: [PATCH v3] selftests/damon: suppress compiler warnings for huge_count_read_write

Hi Yuanchu,

Quoted 3 lines · On Mon, 16 May 2022 21:07:25 -0400 Yuanchu Xie <[email protected]> wrote:

SeongJae,

Do you have a preference on how this should be handled?

Sorry for late response. I was thinking you were asking Shuah's opinion. I have no strong opinion but the approach you made in v2 looks slightly better for me.

Thanks,
SJ

Quoted 72 lines

Thanks,
Yuanchu

Quoted 66 lines · Yuanchu Xie

Hi SeongJae,

Quoted 11 lines · SeongJae Park

Hi Yuanchu,

Quoted 6 lines · On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <[email protected]> wrote:

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

Quoted 8 lines
Quoted 2 lines

---

It would be a good practice to mention the changes from the previous version of this patch here[1].

[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

Thank you, I missed this when trying to figure out how to add additional comments for a revision.

Quoted 24 lines

tools/testing/selftests/damon/huge_count_read_write.c line 6

Quoted 13 lines
 tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/damon/huge_count_read_write.c +2 -0
index ad7a6b4cf338..91bd80c75cd9 100644
@@ -2,6 +2,8 @@
 /*
  * Author: SeongJae Park <[email protected]>
  */
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"

I agree that this must be the cleaner way than v2. But, I get below warning after applying this:

    $ sudo make -C tools/testing/selftests/damon run_tests
    make: Entering directory '/home/sjpark/linux/tools/testing/selftests/damon'
    gcc     huge_count_read_write.c  -o /home/sjpark/linux/tools/testing/selftests/damon/huge_count_read_write
    huge_count_read_write.c:6:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
        6 | #pragma GCC diagnostic ignored "-Wstringop-overread"
          |                                ^~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines

My gcc version is:

    $ gcc --version
    gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

I see, I'm running

    $ gcc --version
    gcc (Debian 11.2.0-16+build1) 11.2.0

I believe this is a new warning for gcc-11 [1], and somewhat unfortunate that it results in a warning for gcc-9.4. I'm not sure what the preference is here.
[1] https://gcc.gnu.org/onlinedocs/gcc-10.3.0/gcc/Warning-Options.html

Thanks,
Yuanchu

#15 lore raw

Re: [PATCH v3] selftests/damon: suppress compiler warnings for huge_count_read_write

In reply to SeongJae Park

Hi Shuah,

Quoted 43 lines · SeongJae Park

Hi Yuanchu,

Quoted 8 lines · On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <[email protected]> wrote:

The test case added in commit db7a347b26fe ("mm/damon/dbgfs:
use '__GFP_NOWARN' for user-specified size buffer allocation") intentionally writes and reads with a large count to cause allocation failure and check for kernel warnings. We suppress the compiler warnings for these calls as they work as intended.

---

It would be a good practice to mention the changes from the previous version of this patch here[1].

[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

tools/testing/selftests/damon/huge_count_read_write.c line 6

Quoted 13 lines
 tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/damon/huge_count_read_write.c +2 -0
index ad7a6b4cf338..91bd80c75cd9 100644
@@ -2,6 +2,8 @@
 /*
  * Author: SeongJae Park <[email protected]>
  */
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"

I agree that this must be the cleaner way than v2. But, I get below warning after applying this:

    $ sudo make -C tools/testing/selftests/damon run_tests
    make: Entering directory '/home/sjpark/linux/tools/testing/selftests/damon'
    gcc     huge_count_read_write.c  -o /home/sjpark/linux/tools/testing/selftests/damon/huge_count_read_write
    huge_count_read_write.c:6:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
        6 | #pragma GCC diagnostic ignored "-Wstringop-overread"
          |                                ^~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines

My gcc version is:

    $ gcc --version
    gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
    $ gcc --version
    gcc (Debian 11.2.0-16+build1) 11.2.0

I believe this is a new warning for gcc-11 [1], and somewhat unfortunate that it results in a warning for gcc-9.4. So a patch that would resolve the test warnings for gcc 11 would introduce a new warning for gcc 9, and vice versa. What's the preferred solution here?

[1] https://gcc.gnu.org/onlinedocs/gcc-10.3.0/gcc/Warning-Options.html

Thanks,
Yuanchu