diff mbox series

[v2,Linux-6.12.y,Linux-6.13.y,1/1] selftests/mm: build with -O2

Message ID 20250204214723.1991309-1-yifei.l.liu@oracle.com
State Superseded
Headers show
Series [v2,Linux-6.12.y,Linux-6.13.y,1/1] selftests/mm: build with -O2 | expand

Commit Message

Yifei Liu Feb. 4, 2025, 9:47 p.m. UTC
From: Kevin Brodsky <kevin.brodsky@arm.com>

[ Upstream commit 46036188ea1f5266df23a6149dea0df1c77cd1c7 ]

The mm kselftests are currently built with no optimisation (-O0).  It's
unclear why, and besides being obviously suboptimal, this also prevents
the pkeys tests from working as intended.  Let's build all the tests with
-O2.

[kevin.brodsky@arm.com: silence unused-result warnings]
  Link: https://lkml.kernel.org/r/20250107170110.2819685-1-kevin.brodsky@arm.com
Link: https://lkml.kernel.org/r/20241209095019.1732120-6-kevin.brodsky@arm.com
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Keith Lucas <keith.lucas@oracle.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 46036188ea1f5266df23a6149dea0df1c77cd1c7)
[Yifei: This commit also fix the failure of pkey_sighandler_tests_64,
which is also in linux-6.12.y and linux-6.13.y, thus backport this commit]
Signed-off-by: Yifei Liu <yifei.l.liu@oracle.com>
---
 tools/testing/selftests/mm/Makefile | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Greg KH Feb. 5, 2025, 12:14 p.m. UTC | #1
On Tue, Feb 04, 2025 at 01:47:23PM -0800, Yifei Liu wrote:
> From: Kevin Brodsky <kevin.brodsky@arm.com>
> 
> [ Upstream commit 46036188ea1f5266df23a6149dea0df1c77cd1c7 ]
> 
> The mm kselftests are currently built with no optimisation (-O0).  It's
> unclear why, and besides being obviously suboptimal, this also prevents
> the pkeys tests from working as intended.  Let's build all the tests with
> -O2.
> 
> [kevin.brodsky@arm.com: silence unused-result warnings]
>   Link: https://lkml.kernel.org/r/20250107170110.2819685-1-kevin.brodsky@arm.com
> Link: https://lkml.kernel.org/r/20241209095019.1732120-6-kevin.brodsky@arm.com
> Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
> Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Joey Gouly <joey.gouly@arm.com>
> Cc: Keith Lucas <keith.lucas@oracle.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit 46036188ea1f5266df23a6149dea0df1c77cd1c7)
> [Yifei: This commit also fix the failure of pkey_sighandler_tests_64,
> which is also in linux-6.12.y and linux-6.13.y, thus backport this commit]
> Signed-off-by: Yifei Liu <yifei.l.liu@oracle.com>
> ---
>  tools/testing/selftests/mm/Makefile | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
> index 02e1204971b0..c0138cb19705 100644
> --- a/tools/testing/selftests/mm/Makefile
> +++ b/tools/testing/selftests/mm/Makefile
> @@ -33,9 +33,16 @@ endif
>  # LDLIBS.
>  MAKEFLAGS += --no-builtin-rules
>  
> -CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
> +CFLAGS = -Wall -O2 -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
>  LDLIBS = -lrt -lpthread -lm
>  
> +# Some distributions (such as Ubuntu) configure GCC so that _FORTIFY_SOURCE is
> +# automatically enabled at -O1 or above. This triggers various unused-result
> +# warnings where functions such as read() or write() are called and their
> +# return value is not checked. Disable _FORTIFY_SOURCE to silence those
> +# warnings.
> +CFLAGS += -U_FORTIFY_SOURCE
> +
>  TEST_GEN_FILES = cow
>  TEST_GEN_FILES += compaction_test
>  TEST_GEN_FILES += gup_longterm

This does not apply to 6.13 :(
Yifei Liu Feb. 19, 2025, 2:13 a.m. UTC | #2
> On Feb 11, 2025, at 4:33 PM, Yifei Liu <yifei.l.liu@oracle.com> wrote:
> 
> 
> 
>> On Feb 10, 2025, at 10:24 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> 
>> A: https://urldefense.com/v3/__http://en.wikipedia.org/wiki/Top_post__;!!ACWV5N9M2RV99hQ!I6O0EcBYMun5zy7pK39ZG9aJYrbv3Uy7IaJYl-fKOXJfmImBbzfXDFfOWeYY2o1JutHPBoAoI_b7xJQyjQ5nnfgv$ 
>> Q: Were do I find info about this thing called top-posting?
>> A: Because it messes up the order in which people normally read text.
>> Q: Why is top-posting such a bad thing?
>> A: Top-posting.
>> Q: What is the most annoying thing in e-mail?
>> 
>> A: No.
>> Q: Should I include quotations after my reply?
>> 
> Hi Greg,
> Sorry for the top-posting. I will not do that any more. 
>> https://urldefense.com/v3/__http://daringfireball.net/2007/07/on_top__;!!ACWV5N9M2RV99hQ!I6O0EcBYMun5zy7pK39ZG9aJYrbv3Uy7IaJYl-fKOXJfmImBbzfXDFfOWeYY2o1JutHPBoAoI_b7xJQyjanSNOhz$
>> 
>> On Mon, Feb 10, 2025 at 06:43:49PM +0000, Yifei Liu wrote:
>>> Hi Greg, 
>>> Yes, looks we only need this for linux-6.12.y. Maybe we could use the v1 version which does not include the linux-6.13.y tag. Or I can send a v3 with the linux-6.12.y only.
>> 
>> As you know, we can't take patches for only older kernels and not newer
>> ones.  Please submit them for all relevant branches, AND test your
>> patches before you submit them so that they don't fail on our side, as
>> that just wastes our energy :(
> For this patch, I believe it failed to apply to linux-6.13 due to another same patch applied before it. Commit d9eb5a1e76f5 ("selftests/mm: build with -O2”) goes into linux-6.13 with tag v6.13.2, last week’s tag. I checked the queue-6.12 and do not see this patch yet for v6.12. I think we still need this for v6.12. About the patch, it fixes a build issue for selftest/mm, which is bacported to v6.12. Thus this patch should only be backported to v6.12.
> 
> I tested it on my device and it works fine and solved the failure of selftest.
> 
Hi Greg, 

I checked the v6.12.16 tag released last Friday. It does not contain this patch. It looks we will not see the same situation we have for v6.13 like I mentioned above and it’s safe to include this in v6.12. 

I could resend a v3 with all the linux-6.13.y tags removed if you want. 
Thank you
Yifei
> Thank you
> Yifei
>> 
>> thanks,
>> 
>> greg k-h
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index 02e1204971b0..c0138cb19705 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -33,9 +33,16 @@  endif
 # LDLIBS.
 MAKEFLAGS += --no-builtin-rules
 
-CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
+CFLAGS = -Wall -O2 -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
 LDLIBS = -lrt -lpthread -lm
 
+# Some distributions (such as Ubuntu) configure GCC so that _FORTIFY_SOURCE is
+# automatically enabled at -O1 or above. This triggers various unused-result
+# warnings where functions such as read() or write() are called and their
+# return value is not checked. Disable _FORTIFY_SOURCE to silence those
+# warnings.
+CFLAGS += -U_FORTIFY_SOURCE
+
 TEST_GEN_FILES = cow
 TEST_GEN_FILES += compaction_test
 TEST_GEN_FILES += gup_longterm