diff mbox series

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

Message ID 20220504182908.1322874-1-yuanchu@google.com (mailing list archive)
State New
Headers show
Series [v3] selftests/damon: suppress compiler warnings for huge_count_read_write | expand

Commit Message

Yuanchu Xie May 4, 2022, 6:29 p.m. UTC
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.

Signed-off-by: Yuanchu Xie <yuanchu@google.com>
---
 tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

SeongJae Park May 4, 2022, 6:45 p.m. UTC | #1
Hi Yuanchu,

On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <yuanchu@google.com> 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.
> 
> Signed-off-by: Yuanchu Xie <yuanchu@google.com>
> ---

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 | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c
> index ad7a6b4cf338..91bd80c75cd9 100644
> --- a/tools/testing/selftests/damon/huge_count_read_write.c
> +++ b/tools/testing/selftests/damon/huge_count_read_write.c
> @@ -2,6 +2,8 @@
>  /*
>   * Author: SeongJae Park <sj@kernel.org>
>   */
> +#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

>  
>  #include <fcntl.h>
>  #include <stdlib.h>
> -- 
> 2.36.0.464.gb9c8b46e94-goog
>
Yuanchu Xie May 4, 2022, 10:12 p.m. UTC | #2
Hi SeongJae,

On Wed, May 4, 2022 at 11:45 AM SeongJae Park <sj@kernel.org> wrote:
>
> Hi Yuanchu,
>
> On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <yuanchu@google.com> 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.
> >
> > Signed-off-by: Yuanchu Xie <yuanchu@google.com>
> > ---
>
> 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.

> >  tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c
> > index ad7a6b4cf338..91bd80c75cd9 100644
> > --- a/tools/testing/selftests/damon/huge_count_read_write.c
> > +++ b/tools/testing/selftests/damon/huge_count_read_write.c
> > @@ -2,6 +2,8 @@
> >  /*
> >   * Author: SeongJae Park <sj@kernel.org>
> >   */
> > +#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
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
Yuanchu Xie May 17, 2022, 1:07 a.m. UTC | #3
SeongJae,

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

Thanks,
Yuanchu

On Wed, May 4, 2022 at 6:12 PM Yuanchu Xie <yuanchu@google.com> wrote:
>
> Hi SeongJae,
>
> On Wed, May 4, 2022 at 11:45 AM SeongJae Park <sj@kernel.org> wrote:
> >
> > Hi Yuanchu,
> >
> > On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <yuanchu@google.com> 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.
> > >
> > > Signed-off-by: Yuanchu Xie <yuanchu@google.com>
> > > ---
> >
> > 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.
>
> > >  tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c
> > > index ad7a6b4cf338..91bd80c75cd9 100644
> > > --- a/tools/testing/selftests/damon/huge_count_read_write.c
> > > +++ b/tools/testing/selftests/damon/huge_count_read_write.c
> > > @@ -2,6 +2,8 @@
> > >  /*
> > >   * Author: SeongJae Park <sj@kernel.org>
> > >   */
> > > +#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
> 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
SeongJae Park May 17, 2022, 4:04 p.m. UTC | #4
Hi Yuanchu,

On Mon, 16 May 2022 21:07:25 -0400 Yuanchu Xie <yuanchu@google.com> 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

> 
> Thanks,
> Yuanchu
> 
> On Wed, May 4, 2022 at 6:12 PM Yuanchu Xie <yuanchu@google.com> wrote:
> >
> > Hi SeongJae,
> >
> > On Wed, May 4, 2022 at 11:45 AM SeongJae Park <sj@kernel.org> wrote:
> > >
> > > Hi Yuanchu,
> > >
> > > On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <yuanchu@google.com> 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.
> > > >
> > > > Signed-off-by: Yuanchu Xie <yuanchu@google.com>
> > > > ---
> > >
> > > 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.
> >
> > > >  tools/testing/selftests/damon/huge_count_read_write.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c
> > > > index ad7a6b4cf338..91bd80c75cd9 100644
> > > > --- a/tools/testing/selftests/damon/huge_count_read_write.c
> > > > +++ b/tools/testing/selftests/damon/huge_count_read_write.c
> > > > @@ -2,6 +2,8 @@
> > > >  /*
> > > >   * Author: SeongJae Park <sj@kernel.org>
> > > >   */
> > > > +#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
> > 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
>
Yuanchu Xie May 25, 2022, 12:55 a.m. UTC | #5
Hi Shuah,

On Wed, May 4, 2022 at 11:45 AM SeongJae Park <sj@kernel.org> wrote:
>
> Hi Yuanchu,
>
> On Wed, 4 May 2022 18:29:08 +0000 Yuanchu Xie <yuanchu@google.com> 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.
> >
> > Signed-off-by: Yuanchu Xie <yuanchu@google.com>
> > ---
>
> 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 | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c
> > index ad7a6b4cf338..91bd80c75cd9 100644
> > --- a/tools/testing/selftests/damon/huge_count_read_write.c
> > +++ b/tools/testing/selftests/damon/huge_count_read_write.c
> > @@ -2,6 +2,8 @@
> >  /*
> >   * Author: SeongJae Park <sj@kernel.org>
> >   */
> > +#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

    $ 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
diff mbox series

Patch

diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c
index ad7a6b4cf338..91bd80c75cd9 100644
--- a/tools/testing/selftests/damon/huge_count_read_write.c
+++ b/tools/testing/selftests/damon/huge_count_read_write.c
@@ -2,6 +2,8 @@ 
 /*
  * Author: SeongJae Park <sj@kernel.org>
  */
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"
 
 #include <fcntl.h>
 #include <stdlib.h>