diff mbox series

[RFC,v3,01/10] rcuwait: Split type definition to its own header

Message ID 20240711130004.2157737-2-vschneid@redhat.com (mailing list archive)
State New, archived
Headers show
Series sched/fair: Defer CFS throttle to user entry | expand

Commit Message

Valentin Schneider July 11, 2024, 12:59 p.m. UTC
A later commit will add a struct irq_work member to struct task_struct, which
would require <linux/sched.h> to include the definition of struct
irq_work.

Thanks to header dependency hell, incudling <linux/irq_work.h> in <linux/sched.h>
results in defining inline helpers using not-yet-defined fields (mm_struct,
task_struct, various task states...).

Break off the definition of struct rcuwait into its own header file.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
 include/linux/rcuwait.h       |  9 ++-------
 include/linux/rcuwait_types.h | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 7 deletions(-)
 create mode 100644 include/linux/rcuwait_types.h

Comments

Peter Zijlstra July 12, 2024, 3:15 p.m. UTC | #1
On Thu, Jul 11, 2024 at 02:59:55PM +0200, Valentin Schneider wrote:
> A later commit will add a struct irq_work member to struct task_struct, which
> would require <linux/sched.h> to include the definition of struct
> irq_work.
> 
> Thanks to header dependency hell, incudling <linux/irq_work.h> in <linux/sched.h>
> results in defining inline helpers using not-yet-defined fields (mm_struct,
> task_struct, various task states...).
> 
> Break off the definition of struct rcuwait into its own header file.
> 
> Signed-off-by: Valentin Schneider <vschneid@redhat.com>
> ---
>  include/linux/rcuwait.h       |  9 ++-------
>  include/linux/rcuwait_types.h | 16 ++++++++++++++++
>  2 files changed, 18 insertions(+), 7 deletions(-)
>  create mode 100644 include/linux/rcuwait_types.h
> 
> diff --git a/include/linux/rcuwait.h b/include/linux/rcuwait.h
> index 27343424225cf..1f1ca7d38cdf8 100644
> --- a/include/linux/rcuwait.h
> +++ b/include/linux/rcuwait.h
> @@ -5,17 +5,12 @@
>  #include <linux/rcupdate.h>
>  #include <linux/sched/signal.h>
>  
> +#include <linux/rcuwait_types.h>
> +
>  /*
>   * rcuwait provides a way of blocking and waking up a single
>   * task in an rcu-safe manner.
> - *
> - * The only time @task is non-nil is when a user is blocked (or
> - * checking if it needs to) on a condition, and reset as soon as we
> - * know that the condition has succeeded and are awoken.
>   */
> -struct rcuwait {
> -	struct task_struct __rcu *task;
> -};
>  
>  #define __RCUWAIT_INITIALIZER(name)		\
>  	{ .task = NULL, }
> diff --git a/include/linux/rcuwait_types.h b/include/linux/rcuwait_types.h
> new file mode 100644
> index 0000000000000..60a4385a2c368
> --- /dev/null
> +++ b/include/linux/rcuwait_types.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _LINUX_RCUWAIT_TYPES_H_
> +#define _LINUX_RCUWAIT_TYPES_H_
> +
> +#include <linux/sched.h>
> +
> +/*
> + * The only time @task is non-nil is when a user is blocked (or
> + * checking if it needs to) on a condition, and reset as soon as we
> + * know that the condition has succeeded and are awoken.
> + */
> +struct rcuwait {
> +	struct task_struct __rcu *task;
> +};
> +
> +#endif

Can't we simplu stick this in include/linux/types.h ?
Valentin Schneider July 15, 2024, 5:57 p.m. UTC | #2
On 12/07/24 17:15, Peter Zijlstra wrote:
> On Thu, Jul 11, 2024 at 02:59:55PM +0200, Valentin Schneider wrote:
>> diff --git a/include/linux/rcuwait_types.h b/include/linux/rcuwait_types.h
>> new file mode 100644
>> index 0000000000000..60a4385a2c368
>> --- /dev/null
>> +++ b/include/linux/rcuwait_types.h
>> @@ -0,0 +1,16 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#ifndef _LINUX_RCUWAIT_TYPES_H_
>> +#define _LINUX_RCUWAIT_TYPES_H_
>> +
>> +#include <linux/sched.h>
>> +
>> +/*
>> + * The only time @task is non-nil is when a user is blocked (or
>> + * checking if it needs to) on a condition, and reset as soon as we
>> + * know that the condition has succeeded and are awoken.
>> + */
>> +struct rcuwait {
>> +	struct task_struct __rcu *task;
>> +};
>> +
>> +#endif
>
> Can't we simplu stick this in include/linux/types.h ?

Huh, we can indeed. Silly me didn't realize that since all that struct
contains is a pointer, we don't need the embedded type definition for it to
be a complete type.
diff mbox series

Patch

diff --git a/include/linux/rcuwait.h b/include/linux/rcuwait.h
index 27343424225cf..1f1ca7d38cdf8 100644
--- a/include/linux/rcuwait.h
+++ b/include/linux/rcuwait.h
@@ -5,17 +5,12 @@ 
 #include <linux/rcupdate.h>
 #include <linux/sched/signal.h>
 
+#include <linux/rcuwait_types.h>
+
 /*
  * rcuwait provides a way of blocking and waking up a single
  * task in an rcu-safe manner.
- *
- * The only time @task is non-nil is when a user is blocked (or
- * checking if it needs to) on a condition, and reset as soon as we
- * know that the condition has succeeded and are awoken.
  */
-struct rcuwait {
-	struct task_struct __rcu *task;
-};
 
 #define __RCUWAIT_INITIALIZER(name)		\
 	{ .task = NULL, }
diff --git a/include/linux/rcuwait_types.h b/include/linux/rcuwait_types.h
new file mode 100644
index 0000000000000..60a4385a2c368
--- /dev/null
+++ b/include/linux/rcuwait_types.h
@@ -0,0 +1,16 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_RCUWAIT_TYPES_H_
+#define _LINUX_RCUWAIT_TYPES_H_
+
+#include <linux/sched.h>
+
+/*
+ * The only time @task is non-nil is when a user is blocked (or
+ * checking if it needs to) on a condition, and reset as soon as we
+ * know that the condition has succeeded and are awoken.
+ */
+struct rcuwait {
+	struct task_struct __rcu *task;
+};
+
+#endif