linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
@ 2025-07-14 23:01 Paul E. McKenney
  2025-07-18 21:03 ` Shuah Khan
  0 siblings, 1 reply; 7+ messages in thread
From: Paul E. McKenney @ 2025-07-14 23:01 UTC (permalink / raw)
  To: Christian Brauner, Shuah Khan; +Cc: linux-kernel, linux-kselftest

The pidfd selftests run in userspace and include both userspace and kernel
header files.  On some distros (for example, CentOS), this results in
duplicate-symbol warnings in allmodconfig builds, while on other distros
(for example, Ubuntu) it does not.  (This happens in recent -next trees,
including next-20250714.)

Therefore, use #undef to get rid of the userspace definitions in favor
of the kernel definitions.

Other ways of handling this include splitting up the selftest code so
that the userspace definitions go into one translation unit and the
kernel definitions into another (which might or might not be feasible)
or to adjust compiler command-line options to suppress the warnings
(which might or might not be desirable).

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <linux-kselftest@vger.kernel.org>

---
 pidfd.h |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h
index efd74063126eb..6ff495398e872 100644
--- a/tools/testing/selftests/pidfd/pidfd.h
+++ b/tools/testing/selftests/pidfd/pidfd.h
@@ -16,6 +16,10 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#undef SCHED_NORMAL
+#undef SCHED_FLAG_KEEP_ALL
+#undef SCHED_FLAG_UTIL_CLAMP
+
 #include "../kselftest.h"
 #include "../clone3/clone3_selftests.h"
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH RFC] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
  2025-07-14 23:01 [PATCH RFC] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols Paul E. McKenney
@ 2025-07-18 21:03 ` Shuah Khan
  2025-07-18 23:56   ` Paul E. McKenney
  0 siblings, 1 reply; 7+ messages in thread
From: Shuah Khan @ 2025-07-18 21:03 UTC (permalink / raw)
  To: paulmck, Christian Brauner, Shuah Khan
  Cc: linux-kernel, linux-kselftest, Shuah Khan

On 7/14/25 17:01, Paul E. McKenney wrote:
> The pidfd selftests run in userspace and include both userspace and kernel
> header files.  On some distros (for example, CentOS), this results in
> duplicate-symbol warnings in allmodconfig builds, while on other distros
> (for example, Ubuntu) it does not.  (This happens in recent -next trees,
> including next-20250714.)
> 
> Therefore, use #undef to get rid of the userspace definitions in favor
> of the kernel definitions.
> 
> Other ways of handling this include splitting up the selftest code so
> that the userspace definitions go into one translation unit and the
> kernel definitions into another (which might or might not be feasible)
> or to adjust compiler command-line options to suppress the warnings
> (which might or might not be desirable).
> 
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: <linux-kselftest@vger.kernel.org>
> 
> ---
>   pidfd.h |    4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h
> index efd74063126eb..6ff495398e872 100644
> --- a/tools/testing/selftests/pidfd/pidfd.h
> +++ b/tools/testing/selftests/pidfd/pidfd.h
> @@ -16,6 +16,10 @@
>   #include <sys/types.h>
>   #include <sys/wait.h>
>   

Please add comments here about why we are adding this so there
won't be any confusion later.

> +#undef SCHED_NORMAL
> +#undef SCHED_FLAG_KEEP_ALL
> +#undef SCHED_FLAG_UTIL_CLAMP
> +
>   #include "../kselftest.h"
>   #include "../clone3/clone3_selftests.h"
>   

With that change:

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

I am assuming this will go through Christian's tree. If not I can
take it through mine.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH RFC] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
  2025-07-18 21:03 ` Shuah Khan
@ 2025-07-18 23:56   ` Paul E. McKenney
  2025-07-23 23:13     ` [PATCH v2] " Paul E. McKenney
  0 siblings, 1 reply; 7+ messages in thread
From: Paul E. McKenney @ 2025-07-18 23:56 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Christian Brauner, Shuah Khan, linux-kernel, linux-kselftest

On Fri, Jul 18, 2025 at 03:03:43PM -0600, Shuah Khan wrote:
> On 7/14/25 17:01, Paul E. McKenney wrote:
> > The pidfd selftests run in userspace and include both userspace and kernel
> > header files.  On some distros (for example, CentOS), this results in
> > duplicate-symbol warnings in allmodconfig builds, while on other distros
> > (for example, Ubuntu) it does not.  (This happens in recent -next trees,
> > including next-20250714.)
> > 
> > Therefore, use #undef to get rid of the userspace definitions in favor
> > of the kernel definitions.
> > 
> > Other ways of handling this include splitting up the selftest code so
> > that the userspace definitions go into one translation unit and the
> > kernel definitions into another (which might or might not be feasible)
> > or to adjust compiler command-line options to suppress the warnings
> > (which might or might not be desirable).
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> > Cc: Christian Brauner <brauner@kernel.org>
> > Cc: Shuah Khan <shuah@kernel.org>
> > Cc: <linux-kselftest@vger.kernel.org>
> > 
> > ---
> >   pidfd.h |    4 ++++
> >   1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h
> > index efd74063126eb..6ff495398e872 100644
> > --- a/tools/testing/selftests/pidfd/pidfd.h
> > +++ b/tools/testing/selftests/pidfd/pidfd.h
> > @@ -16,6 +16,10 @@
> >   #include <sys/types.h>
> >   #include <sys/wait.h>
> 
> Please add comments here about why we are adding this so there
> won't be any confusion later.

Good point, thank you!

Like this?

/*
 * Remove the userspace definitions of the following preprocessor symbols
 * to avoid duplicate-definition warnings from the subsequent in-kernel
 * definitions.
 */

> > +#undef SCHED_NORMAL
> > +#undef SCHED_FLAG_KEEP_ALL
> > +#undef SCHED_FLAG_UTIL_CLAMP
> > +
> >   #include "../kselftest.h"
> >   #include "../clone3/clone3_selftests.h"
> 
> With that change:
> 
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

Thank you!

> I am assuming this will go through Christian's tree. If not I can
> take it through mine.

I am of course good either way.  ;-)

							Thanx, Paul

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
  2025-07-18 23:56   ` Paul E. McKenney
@ 2025-07-23 23:13     ` Paul E. McKenney
  2025-07-24 18:26       ` Shuah Khan
  0 siblings, 1 reply; 7+ messages in thread
From: Paul E. McKenney @ 2025-07-23 23:13 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Christian Brauner, Shuah Khan, linux-kernel, linux-kselftest

The pidfd selftests run in userspace and include both userspace and kernel
header files.  On some distros (for example, CentOS), this results in
duplicate-symbol warnings in allmodconfig builds, while on other distros
(for example, Ubuntu) it does not.

Therefore, use #undef to get rid of the userspace definitions in favor
of the kernel definitions.

Other ways of handling this include splitting up the selftest code so
that the userspace definitions go into one translation unit and the
kernel definitions into another (which might or might not be feasible)
or to adjust compiler command-line options to suppress the warnings
(which might or might not be desirable).

[ paulmck: Apply Shuah Khan feedback. ]

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: <linux-kselftest@vger.kernel.org>

---
 pidfd.h |    9 +++++++++
 1 file changed, 9 insertions(+)

Changes since v1 (RFC):

o	Added comment explaining the purpose of the #undef calls per
	Shuah Khan feedback.

diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h
index efd74063126eb..254eaa6cc4dfa 100644
--- a/tools/testing/selftests/pidfd/pidfd.h
+++ b/tools/testing/selftests/pidfd/pidfd.h
@@ -16,6 +16,15 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+/*
+ * Remove the userspace definitions of the following preprocessor symbols
+ * to avoid duplicate-definition warnings from the subsequent in-kernel
+ * definitions.
+ */
+#undef SCHED_NORMAL
+#undef SCHED_FLAG_KEEP_ALL
+#undef SCHED_FLAG_UTIL_CLAMP
+
 #include "../kselftest.h"
 #include "../clone3/clone3_selftests.h"
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
  2025-07-23 23:13     ` [PATCH v2] " Paul E. McKenney
@ 2025-07-24 18:26       ` Shuah Khan
  2025-07-24 22:17         ` Shuah Khan
  0 siblings, 1 reply; 7+ messages in thread
From: Shuah Khan @ 2025-07-24 18:26 UTC (permalink / raw)
  To: paulmck
  Cc: Christian Brauner, Shuah Khan, linux-kernel, linux-kselftest,
	Shuah Khan

On 7/23/25 17:13, Paul E. McKenney wrote:
> The pidfd selftests run in userspace and include both userspace and kernel
> header files.  On some distros (for example, CentOS), this results in
> duplicate-symbol warnings in allmodconfig builds, while on other distros
> (for example, Ubuntu) it does not.
> 
> Therefore, use #undef to get rid of the userspace definitions in favor
> of the kernel definitions.
> 
> Other ways of handling this include splitting up the selftest code so
> that the userspace definitions go into one translation unit and the
> kernel definitions into another (which might or might not be feasible)
> or to adjust compiler command-line options to suppress the warnings
> (which might or might not be desirable).
> 
> [ paulmck: Apply Shuah Khan feedback. ]

Looks good to me.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
  2025-07-24 18:26       ` Shuah Khan
@ 2025-07-24 22:17         ` Shuah Khan
  2025-07-24 23:29           ` Paul E. McKenney
  0 siblings, 1 reply; 7+ messages in thread
From: Shuah Khan @ 2025-07-24 22:17 UTC (permalink / raw)
  To: paulmck
  Cc: Christian Brauner, Shuah Khan, linux-kernel, linux-kselftest,
	Shuah Khan

On 7/24/25 12:26, Shuah Khan wrote:
> On 7/23/25 17:13, Paul E. McKenney wrote:
>> The pidfd selftests run in userspace and include both userspace and kernel
>> header files.  On some distros (for example, CentOS), this results in
>> duplicate-symbol warnings in allmodconfig builds, while on other distros
>> (for example, Ubuntu) it does not.
>>
>> Therefore, use #undef to get rid of the userspace definitions in favor
>> of the kernel definitions.
>>
>> Other ways of handling this include splitting up the selftest code so
>> that the userspace definitions go into one translation unit and the
>> kernel definitions into another (which might or might not be feasible)
>> or to adjust compiler command-line options to suppress the warnings
>> (which might or might not be desirable).
>>
>> [ paulmck: Apply Shuah Khan feedback. ]
> 
> Looks good to me.
>

I picked this up for Linux 6.17-rc1.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols
  2025-07-24 22:17         ` Shuah Khan
@ 2025-07-24 23:29           ` Paul E. McKenney
  0 siblings, 0 replies; 7+ messages in thread
From: Paul E. McKenney @ 2025-07-24 23:29 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Christian Brauner, Shuah Khan, linux-kernel, linux-kselftest

On Thu, Jul 24, 2025 at 04:17:07PM -0600, Shuah Khan wrote:
> On 7/24/25 12:26, Shuah Khan wrote:
> > On 7/23/25 17:13, Paul E. McKenney wrote:
> > > The pidfd selftests run in userspace and include both userspace and kernel
> > > header files.  On some distros (for example, CentOS), this results in
> > > duplicate-symbol warnings in allmodconfig builds, while on other distros
> > > (for example, Ubuntu) it does not.
> > > 
> > > Therefore, use #undef to get rid of the userspace definitions in favor
> > > of the kernel definitions.
> > > 
> > > Other ways of handling this include splitting up the selftest code so
> > > that the userspace definitions go into one translation unit and the
> > > kernel definitions into another (which might or might not be feasible)
> > > or to adjust compiler command-line options to suppress the warnings
> > > (which might or might not be desirable).
> > > 
> > > [ paulmck: Apply Shuah Khan feedback. ]
> > 
> > Looks good to me.
> 
> I picked this up for Linux 6.17-rc1.

Thank you, Shuah!

							Thanx, Paul

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-24 23:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 23:01 [PATCH RFC] selftests/pidfd: Fix duplicate-symbol warnings for SCHED_ CPP symbols Paul E. McKenney
2025-07-18 21:03 ` Shuah Khan
2025-07-18 23:56   ` Paul E. McKenney
2025-07-23 23:13     ` [PATCH v2] " Paul E. McKenney
2025-07-24 18:26       ` Shuah Khan
2025-07-24 22:17         ` Shuah Khan
2025-07-24 23:29           ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).