Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jun 2012 12:58:46 +0000
From:      rudot@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r237890 - soc2012/rudot/sys/sys
Message-ID:  <20120618125846.90692106566B@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rudot
Date: Mon Jun 18 12:58:45 2012
New Revision: 237890
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=237890

Log:
  Adding some header files

Added:
  soc2012/rudot/sys/sys/rctl.h
  soc2012/rudot/sys/sys/sched.h

Added: soc2012/rudot/sys/sys/rctl.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/rudot/sys/sys/rctl.h	Mon Jun 18 12:58:45 2012	(r237890)
@@ -0,0 +1,169 @@
+/*-
+ * Copyright (c) 2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Edward Tomasz Napierala under sponsorship
+ * from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/sys/rctl.h,v 1.3 2011/05/03 07:32:58 trasz Exp $
+ */
+
+/*
+ * Resource Limits.
+ */
+
+#ifndef _RCTL_H_
+#define	_RCTL_H_
+
+#include <sys/cdefs.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/_task.h>
+
+struct proc;
+struct uidinfo;
+struct loginclass;
+struct prison_racct;
+struct ucred;
+struct rctl_rule_link;
+
+#ifdef _KERNEL
+
+/*
+ * Rules describe an action to be taken when conditions defined
+ * in the rule are met.  There is no global list of rules; instead,
+ * rules are linked to by the racct structures for all the subjects
+ * they apply to - for example, a rule of type "user" is linked to the
+ * appropriate struct uidinfo, and to all the processes of that user.
+ *
+ * 'rr_refcount' is equal to the number of rctl_rule_link structures
+ * pointing to the rule.
+ *
+ * This structure must never change after being added, via rctl_rule_link
+ * structures, to subjects.  In order to change a rule, add a new rule
+ * and remove the previous one.
+ */
+struct rctl_rule {
+	int		rr_subject_type;
+	union {
+		struct proc		*rs_proc;
+		struct uidinfo		*rs_uip;
+		struct loginclass	*rs_loginclass;
+		struct prison_racct	*rs_prison_racct;
+	} rr_subject;
+	int		rr_per;
+	int		rr_resource;
+	int		rr_action;
+	int64_t		rr_amount;
+	u_int		rr_refcount;
+	struct task	rr_task;
+};
+
+/*
+ * Allowed values for rr_subject_type and rr_per fields.
+ */
+#define	RCTL_SUBJECT_TYPE_UNDEFINED	-1
+#define	RCTL_SUBJECT_TYPE_PROCESS	0x0000
+#define	RCTL_SUBJECT_TYPE_USER		0x0001
+#define	RCTL_SUBJECT_TYPE_LOGINCLASS	0x0003
+#define	RCTL_SUBJECT_TYPE_JAIL		0x0004
+#define	RCTL_SUBJECT_TYPE_MAX		RCTL_SUBJECT_TYPE_JAIL
+
+/*
+ * Allowed values for rr_action field.
+ */
+#define	RCTL_ACTION_UNDEFINED		-1
+#define	RCTL_ACTION_SIGHUP		SIGHUP
+#define	RCTL_ACTION_SIGINT		SIGINT
+#define	RCTL_ACTION_SIGQUIT		SIGQUIT
+#define	RCTL_ACTION_SIGILL		SIGILL
+#define	RCTL_ACTION_SIGTRAP		SIGTRAP
+#define	RCTL_ACTION_SIGABRT		SIGABRT
+#define	RCTL_ACTION_SIGEMT		SIGEMT
+#define	RCTL_ACTION_SIGFPE		SIGFPE
+#define	RCTL_ACTION_SIGKILL		SIGKILL
+#define	RCTL_ACTION_SIGBUS		SIGBUS
+#define	RCTL_ACTION_SIGSEGV		SIGSEGV
+#define	RCTL_ACTION_SIGSYS		SIGSYS
+#define	RCTL_ACTION_SIGPIPE		SIGPIPE
+#define	RCTL_ACTION_SIGALRM		SIGALRM
+#define	RCTL_ACTION_SIGTERM		SIGTERM
+#define	RCTL_ACTION_SIGURG		SIGURG
+#define	RCTL_ACTION_SIGSTOP		SIGSTOP
+#define	RCTL_ACTION_SIGTSTP		SIGTSTP
+#define	RCTL_ACTION_SIGCHLD		SIGCHLD
+#define	RCTL_ACTION_SIGTTIN		SIGTTIN
+#define	RCTL_ACTION_SIGTTOU		SIGTTOU
+#define	RCTL_ACTION_SIGIO		SIGIO
+#define	RCTL_ACTION_SIGXCPU		SIGXCPU
+#define	RCTL_ACTION_SIGXFSZ		SIGXFSZ
+#define	RCTL_ACTION_SIGVTALRM		SIGVTALRM
+#define	RCTL_ACTION_SIGPROF		SIGPROF
+#define	RCTL_ACTION_SIGWINCH		SIGWINCH
+#define	RCTL_ACTION_SIGINFO		SIGINFO
+#define	RCTL_ACTION_SIGUSR1		SIGUSR1
+#define	RCTL_ACTION_SIGUSR2		SIGUSR2
+#define	RCTL_ACTION_SIGTHR		SIGTHR
+#define	RCTL_ACTION_SIGNAL_MAX		RCTL_ACTION_SIGTHR
+#define	RCTL_ACTION_DENY		(RCTL_ACTION_SIGNAL_MAX + 1)
+#define	RCTL_ACTION_LOG			(RCTL_ACTION_SIGNAL_MAX + 2)
+#define	RCTL_ACTION_DEVCTL		(RCTL_ACTION_SIGNAL_MAX + 3)
+#define	RCTL_ACTION_MAX			RCTL_ACTION_DEVCTL
+
+#define	RCTL_AMOUNT_UNDEFINED		-1
+
+struct rctl_rule *rctl_rule_alloc(int flags);
+struct rctl_rule *rctl_rule_duplicate(const struct rctl_rule *rule, int flags);
+void	rctl_rule_acquire(struct rctl_rule *rule);
+void	rctl_rule_release(struct rctl_rule *rule);
+int	rctl_rule_add(struct rctl_rule *rule);
+int	rctl_rule_remove(struct rctl_rule *filter);
+int	rctl_enforce(struct proc *p, int resource, uint64_t amount);
+uint64_t rctl_get_limit(struct proc *p, int resource);
+uint64_t rctl_get_available(struct proc *p, int resource);
+const char *rctl_resource_name(int resource);
+void	rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred);
+int	rctl_proc_fork(struct proc *parent, struct proc *child);
+void	rctl_racct_release(struct racct *racct);
+#else /* !_KERNEL */
+
+/*
+ * Syscall interface.
+ */
+__BEGIN_DECLS
+int	rctl_get_racct(const char *inbufp, size_t inbuflen, char *outbufp,
+	    size_t outbuflen);
+int	rctl_get_rules(const char *inbufp, size_t inbuflen, char *outbufp,
+	    size_t outbuflen);
+int	rctl_get_limits(const char *inbufp, size_t inbuflen, char *outbufp,
+	    size_t outbuflen);
+int	rctl_add_rule(const char *inbufp, size_t inbuflen, char *outbufp,
+	    size_t outbuflen);
+int	rctl_remove_rule(const char *inbufp, size_t inbuflen, char *outbufp,
+	    size_t outbuflen);
+__END_DECLS
+
+#endif /* !_KERNEL */
+
+#endif /* !_RCTL_H_ */

Added: soc2012/rudot/sys/sys/sched.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2012/rudot/sys/sys/sched.h	Mon Jun 18 12:58:45 2012	(r237890)
@@ -0,0 +1,240 @@
+/*-
+ * Copyright (c) 1996, 1997
+ *      HD Associates, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by HD Associates, Inc
+ *      and Jukka Antero Ukkonen.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 2002-2008, Jeffrey Roberson <jeff@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/sys/sched.h,v 1.46 2012/03/08 19:41:05 jhb Exp $
+ */
+
+#ifndef _SCHED_H_
+#define	_SCHED_H_
+
+#ifdef _KERNEL
+/*
+ * General scheduling info.
+ *
+ * sched_load:
+ *	Total runnable non-ithread threads in the system.
+ *
+ * sched_runnable:
+ *	Runnable threads for this processor.
+ */
+int	sched_load(void);
+int	sched_rr_interval(void);
+int	sched_runnable(void);
+
+/* 
+ * Proc related scheduling hooks.
+ */
+void	sched_exit(struct proc *p, struct thread *childtd);
+void	sched_fork(struct thread *td, struct thread *childtd);
+void	sched_fork_exit(struct thread *td);
+void	sched_class(struct thread *td, int class);
+void	sched_nice(struct proc *p, int nice);
+
+/*
+ * Threads are switched in and out, block on resources, have temporary
+ * priorities inherited from their procs, and use up cpu time.
+ */
+void	sched_exit_thread(struct thread *td, struct thread *child);
+void	sched_fork_thread(struct thread *td, struct thread *child);
+void	sched_lend_prio(struct thread *td, u_char prio);
+void	sched_lend_user_prio(struct thread *td, u_char pri);
+fixpt_t	sched_pctcpu(struct thread *td);
+fixpt_t	sched_pctcpu_delta(struct thread *td);
+void	sched_prio(struct thread *td, u_char prio);
+void	sched_sleep(struct thread *td, int prio);
+void	sched_switch(struct thread *td, struct thread *newtd, int flags);
+void	sched_throw(struct thread *td);
+void	sched_unlend_prio(struct thread *td, u_char prio);
+void	sched_user_prio(struct thread *td, u_char prio);
+void	sched_userret(struct thread *td);
+void	sched_wakeup(struct thread *td);
+void	sched_preempt(struct thread *td);
+
+/*
+ * Threads are moved on and off of run queues
+ */
+void	sched_add(struct thread *td, int flags);
+void	sched_clock(struct thread *td);
+void	sched_rem(struct thread *td);
+void	sched_tick(int cnt);
+void	sched_relinquish(struct thread *td);
+struct thread *sched_choose(void);
+void	sched_idletd(void *);
+
+/*
+ * Binding makes cpu affinity permanent while pinning is used to temporarily
+ * hold a thread on a particular CPU.
+ */
+void	sched_bind(struct thread *td, int cpu);
+static __inline void sched_pin(void);
+void	sched_unbind(struct thread *td);
+static __inline void sched_unpin(void);
+int	sched_is_bound(struct thread *td);
+void	sched_affinity(struct thread *td);
+
+/*
+ * These procedures tell the process data structure allocation code how
+ * many bytes to actually allocate.
+ */
+int	sched_sizeof_proc(void);
+int	sched_sizeof_thread(void);
+
+/*
+ * This routine provides a consistent thread name for use with KTR graphing
+ * functions.
+ */
+char	*sched_tdname(struct thread *td);
+#ifdef KTR
+void	sched_clear_tdname(struct thread *td);
+#endif
+
+static __inline void
+sched_pin(void)
+{
+	curthread->td_pinned++;
+}
+
+static __inline void
+sched_unpin(void)
+{
+	curthread->td_pinned--;
+}
+
+/* sched_add arguments (formerly setrunqueue) */
+#define	SRQ_BORING	0x0000		/* No special circumstances. */
+#define	SRQ_YIELDING	0x0001		/* We are yielding (from mi_switch). */
+#define	SRQ_OURSELF	0x0002		/* It is ourself (from mi_switch). */
+#define	SRQ_INTR	0x0004		/* It is probably urgent. */
+#define	SRQ_PREEMPTED	0x0008		/* has been preempted.. be kind */
+#define	SRQ_BORROWING	0x0010		/* Priority updated due to prio_lend */
+
+/* Scheduler stats. */
+#ifdef SCHED_STATS
+DPCPU_DECLARE(long, sched_switch_stats[SWT_COUNT]);
+
+#define	SCHED_STAT_DEFINE_VAR(name, ptr, descr)				\
+static void name ## _add_proc(void *dummy __unused)			\
+{									\
+									\
+	SYSCTL_ADD_PROC(NULL,						\
+	    SYSCTL_STATIC_CHILDREN(_kern_sched_stats), OID_AUTO,	\
+	    #name, CTLTYPE_LONG|CTLFLAG_RD|CTLFLAG_MPSAFE,		\
+	    ptr, 0, sysctl_dpcpu_long, "LU", descr);			\
+}									\
+SYSINIT(name, SI_SUB_RUN_SCHEDULER, SI_ORDER_MIDDLE, name ## _add_proc, NULL);
+
+#define	SCHED_STAT_DEFINE(name, descr)					\
+    DPCPU_DEFINE(unsigned long, name);					\
+    SCHED_STAT_DEFINE_VAR(name, &DPCPU_NAME(name), descr)
+/*
+ * Sched stats are always incremented in critical sections so no atomic
+ * is necesssary to increment them.
+ */
+#define SCHED_STAT_INC(var)     DPCPU_GET(var)++;
+#else
+#define	SCHED_STAT_DEFINE_VAR(name, descr, ptr)
+#define	SCHED_STAT_DEFINE(name, descr)
+#define SCHED_STAT_INC(var)			(void)0
+#endif
+
+/*
+ * Fixup scheduler state for proc0 and thread0
+ */
+void schedinit(void);
+#endif /* _KERNEL */
+
+/* POSIX 1003.1b Process Scheduling */
+
+/*
+ * POSIX scheduling policies
+ */
+#define SCHED_FIFO      1
+#define SCHED_OTHER     2
+#define SCHED_RR        3
+
+struct sched_param {
+        int     sched_priority;
+};
+
+/*
+ * POSIX scheduling declarations for userland.
+ */
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#ifndef _PID_T_DECLARED
+typedef __pid_t         pid_t;
+#define _PID_T_DECLARED
+#endif
+
+struct timespec;
+
+__BEGIN_DECLS
+int     sched_get_priority_max(int);
+int     sched_get_priority_min(int);
+int     sched_getparam(pid_t, struct sched_param *);
+int     sched_getscheduler(pid_t);
+int     sched_rr_get_interval(pid_t, struct timespec *);
+int     sched_setparam(pid_t, const struct sched_param *);
+int     sched_setscheduler(pid_t, int, const struct sched_param *);
+int     sched_yield(void);
+__END_DECLS
+
+#endif
+#endif /* !_SCHED_H_ */



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