Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Jan 2016 14:40:39 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r293482 - in stable/10/sys: amd64/linux32 compat/linux kern sys
Message-ID:  <201601091440.u09Eedo1002571@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sat Jan  9 14:40:38 2016
New Revision: 293482
URL: https://svnweb.freebsd.org/changeset/base/293482

Log:
  MFC r283374:
  
  In preparation for switching linuxulator to the use the native 1:1
  threads refactor kern_sched_rr_get_interval() and sys_sched_rr_get_interval().
  Add a kern_sched_rr_get_interval() counterpart which takes a targettd
  parameter to allow specify target thread directly by callee (new Linuxulator).
  
  Linuxulator temporarily uses first thread in proc.
  
  Move linux_sched_rr_get_interval() to the MI part.

Modified:
  stable/10/sys/amd64/linux32/linux32_machdep.c
  stable/10/sys/compat/linux/linux_misc.c
  stable/10/sys/kern/p1003_1b.c
  stable/10/sys/sys/syscallsubr.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/linux32/linux32_machdep.c
==============================================================================
--- stable/10/sys/amd64/linux32/linux32_machdep.c	Sat Jan  9 14:38:29 2016	(r293481)
+++ stable/10/sys/amd64/linux32/linux32_machdep.c	Sat Jan  9 14:40:38 2016	(r293482)
@@ -924,22 +924,6 @@ linux_getrusage(struct thread *td, struc
 }
 
 int
-linux_sched_rr_get_interval(struct thread *td,
-    struct linux_sched_rr_get_interval_args *uap)
-{
-	struct timespec ts;
-	struct l_timespec ts32;
-	int error;
-
-	error = kern_sched_rr_get_interval(td, uap->pid, &ts);
-	if (error != 0)
-		return (error);
-	ts32.tv_sec = ts.tv_sec;
-	ts32.tv_nsec = ts.tv_nsec;
-	return (copyout(&ts32, uap->interval, sizeof(ts32)));
-}
-
-int
 linux_set_thread_area(struct thread *td,
     struct linux_set_thread_area_args *args)
 {

Modified: stable/10/sys/compat/linux/linux_misc.c
==============================================================================
--- stable/10/sys/compat/linux/linux_misc.c	Sat Jan  9 14:38:29 2016	(r293481)
+++ stable/10/sys/compat/linux/linux_misc.c	Sat Jan  9 14:40:38 2016	(r293482)
@@ -1926,3 +1926,33 @@ linux_sched_setaffinity(struct thread *t
 
 	return (sys_cpuset_setaffinity(td, &csa));
 }
+
+int
+linux_sched_rr_get_interval(struct thread *td,
+    struct linux_sched_rr_get_interval_args *uap)
+{
+	struct timespec ts;
+	struct l_timespec lts;
+	struct thread *tdt;
+	struct proc *p;
+	int error;
+
+	if (uap->pid == 0) {
+		tdt = td;
+		p = tdt->td_proc;
+		PROC_LOCK(p);
+	} else {
+		p = pfind(uap->pid);
+		if (p == NULL)
+			return (ESRCH);
+		tdt = FIRST_THREAD_IN_PROC(p);
+	}
+
+	error = kern_sched_rr_get_interval_td(td, tdt, &ts);
+	PROC_UNLOCK(p);
+	if (error != 0)
+		return (error);
+	lts.tv_sec = ts.tv_sec;
+	lts.tv_nsec = ts.tv_nsec;
+	return (copyout(&lts, uap->interval, sizeof(lts)));
+}

Modified: stable/10/sys/kern/p1003_1b.c
==============================================================================
--- stable/10/sys/kern/p1003_1b.c	Sat Jan  9 14:38:29 2016	(r293481)
+++ stable/10/sys/kern/p1003_1b.c	Sat Jan  9 14:40:38 2016	(r293482)
@@ -296,13 +296,26 @@ kern_sched_rr_get_interval(struct thread
 		targettd = FIRST_THREAD_IN_PROC(targetp);
 	}
 
-	e = p_cansee(td, targetp);
-	if (e == 0)
-		e = ksched_rr_get_interval(ksched, targettd, ts);
+	e = kern_sched_rr_get_interval_td(td, targettd, ts);
 	PROC_UNLOCK(targetp);
 	return (e);
 }
 
+int
+kern_sched_rr_get_interval_td(struct thread *td, struct thread *targettd,
+    struct timespec *ts)
+{
+	struct proc *p;
+	int error;
+
+	p = targettd->td_proc;
+	PROC_LOCK_ASSERT(p, MA_OWNED);
+
+	error = p_cansee(td, p);
+	if (error == 0)
+		error = ksched_rr_get_interval(ksched, targettd, ts);
+	return (error);
+}
 #endif
 
 static void

Modified: stable/10/sys/sys/syscallsubr.h
==============================================================================
--- stable/10/sys/sys/syscallsubr.h	Sat Jan  9 14:38:29 2016	(r293481)
+++ stable/10/sys/sys/syscallsubr.h	Sat Jan  9 14:40:38 2016	(r293482)
@@ -197,6 +197,8 @@ int	kern_rmdirat(struct thread *td, int 
 	    enum uio_seg pathseg);
 int	kern_sched_rr_get_interval(struct thread *td, pid_t pid,
 	    struct timespec *ts);
+int	kern_sched_rr_get_interval_td(struct thread *td, struct thread *targettd,
+	    struct timespec *ts);
 int	kern_semctl(struct thread *td, int semid, int semnum, int cmd,
 	    union semun *arg, register_t *rval);
 int	kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601091440.u09Eedo1002571>