linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eugene Syromiatnikov <esyr@redhat.com>
To: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	"Joel Fernandes (Google)" <joel@joelfernandes.org>,
	Chris Hyser <chris.hyser@oracle.com>,
	Josh Don <joshdon@google.com>, Ingo Molnar <mingo@kernel.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Valentin Schneider <valentin.schneider@arm.com>,
	Mel Gorman <mgorman@suse.de>
Cc: linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	"Dmitry V. Levin" <ldv@strace.io>,
	linux-doc@vger.kernel.org, linux-api@vger.kernel.org,
	Jonathan Corbet <corbet@lwn.net>
Subject: [PATCH] uapi: expose enum pid_type
Date: Sat, 7 Aug 2021 03:01:23 +0200	[thread overview]
Message-ID: <20210807010123.GA5174@asgard.redhat.com> (raw)

Commit 7ac592aa35a684ff ("sched: prctl() core-scheduling interface")
made use of enum pid_type in prctl's arg4; this type and the associated
enumeration definitions are not exposed to userspace.  Try to fix that
by providing enum _kernel_pid_type and tying in-kernel enum pid_type
definitions to it.  Note that enum pid_type cannot be exposed as is,
since "enum pid_type" is already exists in various projects [1] (notably
gcc and strace), and "enum __pid_type" is defined by glibc and uclibc
for fcntl(F_SETOWN_EX) owner ID type.

[1] https://codesearch.debian.net/search?q=enum+pid_type

Complements: 7ac592aa35a684ff ("sched: prctl() core-scheduling interface")
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
 .../admin-guide/hw-vuln/core-scheduling.rst          |  7 ++++---
 include/linux/pid.h                                  | 12 +++++++-----
 include/uapi/linux/pid.h                             | 20 ++++++++++++++++++++
 include/uapi/linux/prctl.h                           |  1 +
 4 files changed, 32 insertions(+), 8 deletions(-)
 create mode 100644 include/uapi/linux/pid.h

diff --git a/Documentation/admin-guide/hw-vuln/core-scheduling.rst b/Documentation/admin-guide/hw-vuln/core-scheduling.rst
index 7b410ae..3eb2b7c 100644
--- a/Documentation/admin-guide/hw-vuln/core-scheduling.rst
+++ b/Documentation/admin-guide/hw-vuln/core-scheduling.rst
@@ -61,9 +61,10 @@ arg3:
     ``pid`` of the task for which the operation applies.
 
 arg4:
-    ``pid_type`` for which the operation applies. It is of type ``enum pid_type``.
-    For example, if arg4 is ``PIDTYPE_TGID``, then the operation of this command
-    will be performed for all tasks in the task group of ``pid``.
+    ``pid_type`` for which the operation applies. It is of type
+    ``enum __kernel_pid_type``.  For example, if arg4 is ``__PIDTYPE_TGID``,
+    then the operation of this command will be performed for all tasks
+    in the task group of ``pid``.
 
 arg5:
     userspace pointer to an unsigned long for storing the cookie returned by
diff --git a/include/linux/pid.h b/include/linux/pid.h
index fa10acb..f8ca4c9 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -5,14 +5,16 @@
 #include <linux/rculist.h>
 #include <linux/wait.h>
 #include <linux/refcount.h>
+#include <uapi/linux/pid.h>
 
 enum pid_type
 {
-	PIDTYPE_PID,
-	PIDTYPE_TGID,
-	PIDTYPE_PGID,
-	PIDTYPE_SID,
-	PIDTYPE_MAX,
+	PIDTYPE_PID = __PIDTYPE_PID,
+	PIDTYPE_TGID = __PIDTYPE_TGID,
+	PIDTYPE_PGID = __PIDTYPE_PGID,
+	PIDTYPE_SID = __PIDTYPE_SID,
+
+	PIDTYPE_MAX = __PIDTYPE_MAX
 };
 
 /*
diff --git a/include/uapi/linux/pid.h b/include/uapi/linux/pid.h
new file mode 100644
index 0000000..91d08e4
--- /dev/null
+++ b/include/uapi/linux/pid.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_LINUX_PID_H
+#define _UAPI_LINUX_PID_H
+
+/*
+ * Type of process-related ID.  So far, it is used only for prctl(PR_SCHED_CORE);
+ * not to be confused with type field of f_owner_ex structure argument
+ * of fcntl(F_SETOWN_EX).
+ */
+enum __kernel_pid_type
+{
+	__PIDTYPE_PID,
+	__PIDTYPE_TGID,
+	__PIDTYPE_PGID,
+	__PIDTYPE_SID,
+
+	__PIDTYPE_MAX /* Non-UAPI */
+};
+
+#endif /* _UAPI_LINUX_PID_H */
diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index 967d9c5..4e794aa 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -3,6 +3,7 @@
 #define _LINUX_PRCTL_H
 
 #include <linux/types.h>
+#include <linux/pid.h> /* enum __kernel_pid_type */
 
 /* Values to pass as first argument to prctl() */
 
-- 
2.1.4


             reply	other threads:[~2021-08-07  1:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-07  1:01 Eugene Syromiatnikov [this message]
2021-08-09  8:04 ` [PATCH] uapi: expose enum pid_type Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210807010123.GA5174@asgard.redhat.com \
    --to=esyr@redhat.com \
    --cc=chris.hyser@oracle.com \
    --cc=corbet@lwn.net \
    --cc=joel@joelfernandes.org \
    --cc=joshdon@google.com \
    --cc=ldv@strace.io \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).