From owner-svn-soc-all@FreeBSD.ORG Sun Jun 19 09:38:07 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7AECE106566B for ; Sun, 19 Jun 2011 09:38:05 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 19 Jun 2011 09:38:05 +0000 Date: Sun, 19 Jun 2011 09:38:05 +0000 From: kibab@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110619093805.7AECE106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r223454 - soc2011/kibab/freebsd-src-head/sys/amd64/conf X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jun 2011 09:38:07 -0000 Author: kibab Date: Sun Jun 19 09:38:05 2011 New Revision: 223454 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=223454 Log: Custom kernel configuration for running in VirtualBox. Added: soc2011/kibab/freebsd-src-head/sys/amd64/conf/CAPSICUM Added: soc2011/kibab/freebsd-src-head/sys/amd64/conf/CAPSICUM ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2011/kibab/freebsd-src-head/sys/amd64/conf/CAPSICUM Sun Jun 19 09:38:05 2011 (r223454) @@ -0,0 +1,163 @@ +# +# GENERIC -- Generic kernel configuration file for FreeBSD/amd64 +# +# For more information on this file, please read the config(5) manual page, +# and/or the handbook section on Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD: soc2011/kibab/freebsd-src-head/sys/amd64/conf/GENERIC 223246 2011-06-14 20:30:49Z hselasky $ + +cpu HAMMER +ident CAPSICUM + +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols + +options SCHED_ULE # ULE scheduler +options PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options SCTP # Stream Control Transmission Protocol +options FFS # Berkeley Fast Filesystem +options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options UFS_GJOURNAL # Enable gjournal-based UFS journaling +options MD_ROOT # MD is a potential root device +options NFSCL # New Network Filesystem Client +options NFSD # New Network Filesystem Server +options NFSLOCKD # Network Lock Manager +options NFS_ROOT # NFS usable as /, requires NFSCLIENT +options MSDOSFS # MSDOS Filesystem +options CD9660 # ISO 9660 Filesystem +options PROCFS # Process filesystem (requires PSEUDOFS) +options PSEUDOFS # Pseudo-filesystem framework +options GEOM_PART_GPT # GUID Partition Tables. +options GEOM_LABEL # Provides labelization +options COMPAT_FREEBSD32 # Compatible with i386 binaries +options COMPAT_FREEBSD4 # Compatible with FreeBSD4 +options COMPAT_FREEBSD5 # Compatible with FreeBSD5 +options COMPAT_FREEBSD6 # Compatible with FreeBSD6 +options COMPAT_FREEBSD7 # Compatible with FreeBSD7 +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +options KTRACE # ktrace(1) support +options STACK # stack(9) support +options SYSVSHM # SYSV-style shared memory +options SYSVMSG # SYSV-style message queues +options SYSVSEM # SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. +options KBD_INSTALL_CDEV # install a CDEV entry in /dev +options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) +options AUDIT # Security event auditing +options MAC # TrustedBSD MAC Framework +options KDTRACE_FRAME # Ensure frames are compiled in +options KDTRACE_HOOKS # Kernel DTrace hooks +options INCLUDE_CONFIG_FILE # Include this file in kernel + +# Debugging for use in -current +options KDB # Enable kernel debugger support. +options DDB # Support DDB. +options GDB # Support remote GDB. +options DEADLKRES # Enable the deadlock resolver +options INVARIANTS # Enable calls of extra sanity checking +options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS +options WITNESS # Enable checks to detect deadlocks and cycles +options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed +options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones + +# Make an SMP-capable kernel by default +options SMP # Symmetric MultiProcessor Kernel + +# CPU frequency control +device cpufreq + +# Bus support. +device acpi +device pci + +# Floppy drives +device fdc + +# ATA controllers +device ahci # AHCI-compatible SATA controllers +device ata # Legacy ATA/SATA controllers +options ATA_CAM # Handle legacy controllers with CAM +options ATA_STATIC_ID # Static device numbering + +# SCSI Controllers +device ahc # AHA2940 and onboard AIC7xxx devices +options AHC_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~128k to driver. +device ahd # AHA39320/29320 and onboard AIC79xx devices +options AHD_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~215k to driver. +# ATA/SCSI peripherals +device scbus # SCSI bus (required for ATA/SCSI) +device ch # SCSI media changers +device da # Direct Access (disks) +device sa # Sequential Access (tape etc) +device cd # CD +device pass # Passthrough device (direct ATA/SCSI access) +device ses # SCSI Environmental Services (and SAF-TE) + +# atkbdc0 controls both the keyboard and the PS/2 mouse +device atkbdc # AT keyboard controller +device atkbd # AT keyboard +device psm # PS/2 mouse + +device kbdmux # keyboard multiplexer + +device vga # VGA video card driver + +device splash # Splash screen and screen saver support + +# syscons is the default console driver, resembling an SCO console +device sc +options SC_PIXEL_MODE # add support for the raster text mode + +device agp # support several AGP chipsets + +# Serial (COM) ports +device uart # Generic UART driver + +# PCI Ethernet NICs. +device em # Intel PRO/1000 Gigabit Ethernet Family + +# PCI Ethernet NICs that use the common MII bus controller code. +# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! +device miibus # MII bus support + +# Pseudo devices. +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device vlan # 802.1Q VLAN support +device tun # Packet tunnel. +device pty # BSD-style compatibility pseudo ttys +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device faith # IPv6-to-IPv4 relaying (translation) +device firmware # firmware assist module + +# The `bpf' device enables the Berkeley Packet Filter. +# Be aware of the administrative consequences of enabling this! +# Note that 'bpf' is required for DHCP. +device bpf # Berkeley packet filter + +# USB support +options USB_DEBUG # enable debug msgs +device uhci # UHCI PCI->USB interface +device ohci # OHCI PCI->USB interface +device ehci # EHCI PCI->USB interface (USB 2.0) +device usb From owner-svn-soc-all@FreeBSD.ORG Sat Jun 25 10:22:21 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 3F4A1106564A for ; Sat, 25 Jun 2011 10:22:19 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 25 Jun 2011 10:22:19 +0000 Date: Sat, 25 Jun 2011 10:22:19 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110625102219.3F4A1106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r223695 - soc2011/rudot/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2011 10:22:21 -0000 Author: rudot Date: Sat Jun 25 10:22:18 2011 New Revision: 223695 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=223695 Log: time slice remembered from previous run idle threads also chosen according to the virtual deadline Modified: soc2011/rudot/kern/sched_fbfs.c Modified: soc2011/rudot/kern/sched_fbfs.c ============================================================================== --- soc2011/rudot/kern/sched_fbfs.c Sat Jun 25 03:43:58 2011 (r223694) +++ soc2011/rudot/kern/sched_fbfs.c Sat Jun 25 10:22:18 2011 (r223695) @@ -68,22 +68,11 @@ dtrace_vtime_switch_func_t dtrace_vtime_switch_func; #endif -/* - * INVERSE_ESTCPU_WEIGHT is only suitable for statclock() frequencies in - * the range 100-256 Hz (approximately). - */ -#define ESTCPULIM(e) \ - min((e), INVERSE_ESTCPU_WEIGHT * (NICE_WEIGHT * (PRIO_MAX - PRIO_MIN) - \ - RQ_PPQ) + INVERSE_ESTCPU_WEIGHT - 1) -#ifdef SMP -#define INVERSE_ESTCPU_WEIGHT (8 * smp_cpus) -#else -#define INVERSE_ESTCPU_WEIGHT 8 /* 1 / (priorities per estcpu level). */ -#endif -#define NICE_WEIGHT 1 /* Priorities per nice level. */ - #define TS_NAME_LEN (MAXCOMLEN + sizeof(" td ") + sizeof(__XSTRING(UINT_MAX))) +static int realstathz; +static int sched_slice = 1; + /* * The schedulable entity that runs a context. * This is an extension to the thread structure and is tailored to @@ -95,6 +84,7 @@ int ts_slptime; /* (j) Seconds !RUNNING. */ int ts_flags; int ts_vdeadline; /* virtual deadline. */ + int ts_slice; /* Remaining slice in number of ticks */ struct runq *ts_runq; /* runq the thread is currently on */ #ifdef KTR char ts_name[TS_NAME_LEN]; @@ -118,17 +108,17 @@ struct mtx sched_lock; static int sched_tdcnt; /* Total runnable threads in the system. */ -static int sched_quantum; /* Roundrobin scheduling quantum in ticks. */ -#define SCHED_QUANTUM (hz / 10) /* Default sched quantum */ static void setup_runqs(void); static void sched_priority(struct thread *td, u_char prio); static void sched_setup(void *dummy); +static void sched_initticks(void *dummy); static struct thread *edf_choose(struct rqhead * rqh); static struct thread *runq_choose_bfs(struct runq * rq); SYSINIT(sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL); +SYSINIT(sched_initticks, SI_SUB_CLOCKS, SI_ORDER_THIRD, sched_initticks, NULL); /* * Global run queue. @@ -146,80 +136,14 @@ runq_init(&runq); } -static int -sysctl_kern_quantum(SYSCTL_HANDLER_ARGS) -{ - int error, new_val; - - new_val = sched_quantum * tick; - error = sysctl_handle_int(oidp, &new_val, 0, req); - if (error != 0 || req->newptr == NULL) - return (error); - if (new_val < tick) - return (EINVAL); - sched_quantum = new_val / tick; - hogticks = 2 * sched_quantum; - return (0); -} - SYSCTL_NODE(_kern, OID_AUTO, sched, CTLFLAG_RD, 0, "Scheduler"); SYSCTL_STRING(_kern_sched, OID_AUTO, name, CTLFLAG_RD, "4BSD", 0, "Scheduler name"); -SYSCTL_PROC(_kern_sched, OID_AUTO, quantum, CTLTYPE_INT | CTLFLAG_RW, - 0, sizeof sched_quantum, sysctl_kern_quantum, "I", - "Roundrobin scheduling quantum in microseconds"); - -#ifdef SMP -/* Enable forwarding of wakeups to all other cpus */ -SYSCTL_NODE(_kern_sched, OID_AUTO, ipiwakeup, CTLFLAG_RD, NULL, "Kernel SMP"); - -static int runq_fuzz = 1; -SYSCTL_INT(_kern_sched, OID_AUTO, runq_fuzz, CTLFLAG_RW, &runq_fuzz, 0, ""); - -static int forward_wakeup_enabled = 1; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, enabled, CTLFLAG_RW, - &forward_wakeup_enabled, 0, - "Forwarding of wakeup to idle CPUs"); - -static int forward_wakeups_requested = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, requested, CTLFLAG_RD, - &forward_wakeups_requested, 0, - "Requests for Forwarding of wakeup to idle CPUs"); - -static int forward_wakeups_delivered = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, delivered, CTLFLAG_RD, - &forward_wakeups_delivered, 0, - "Completed Forwarding of wakeup to idle CPUs"); - -static int forward_wakeup_use_mask = 1; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, usemask, CTLFLAG_RW, - &forward_wakeup_use_mask, 0, - "Use the mask of idle cpus"); - -static int forward_wakeup_use_loop = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, useloop, CTLFLAG_RW, - &forward_wakeup_use_loop, 0, - "Use a loop to find idle cpus"); - -static int forward_wakeup_use_single = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, onecpu, CTLFLAG_RW, - &forward_wakeup_use_single, 0, - "Only signal one idle cpu"); - -static int forward_wakeup_use_htt = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, htt2, CTLFLAG_RW, - &forward_wakeup_use_htt, 0, - "account for htt"); +SYSCTL_INT(_kern_sched, OID_AUTO, slice, CTLFLAG_RW, &sched_slice, 0, + "Slice size for timeshare threads"); -#endif -#if 0 -static int sched_followon = 0; -SYSCTL_INT(_kern_sched, OID_AUTO, followon, CTLFLAG_RW, - &sched_followon, 0, - "allow threads to share a quantum"); -#endif static __inline void sched_load_add(void) @@ -247,13 +171,11 @@ int maybe_preempt(struct thread *td) { -#ifdef PREEMPTION -#endif return (0); } /* I keep it here because the top command wants it. */ -static fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ +static fixpt_t ccpu = 0; SYSCTL_INT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, ""); /* ARGSUSED */ @@ -262,6 +184,9 @@ { int i; + realstathz = hz; + sched_slice = (realstathz/10); + prio_ratios[0] = 128; for (i = 1; i <= PRIO_MAX - PRIO_MIN; ++i) { prio_ratios[i] = prio_ratios[i - 1] * 11 / 10; @@ -269,14 +194,17 @@ setup_runqs(); - if (sched_quantum == 0) - sched_quantum = SCHED_QUANTUM; - hogticks = 2 * sched_quantum; - /* Account for thread0. */ sched_load_add(); } +static void +sched_initticks(void *dummy) +{ + realstathz = stathz ? stathz : hz; + sched_slice = (realstathz/10); /* ~100ms */ +} + /* External interfaces start here */ /* @@ -295,6 +223,7 @@ thread0.td_sched = &td_sched0; thread0.td_lock = &sched_lock; mtx_init(&sched_lock, "sched lock", NULL, MTX_SPIN | MTX_RECURSE); + td_sched0.ts_slice = sched_slice; } int @@ -306,25 +235,9 @@ int sched_rr_interval(void) { - if (sched_quantum == 0) - sched_quantum = SCHED_QUANTUM; - return (sched_quantum); + return (hz/(realstathz/sched_slice)); } -/* - * We adjust the priority of the current process. The priority of - * a process gets worse as it accumulates CPU time. The cpu usage - * estimator (td_estcpu) is increased here. resetpriority() will - * compute a different priority each time td_estcpu increases by - * INVERSE_ESTCPU_WEIGHT - * (until MAXPRI is reached). The cpu usage estimator ramps up - * quite quickly when the process is running (linearly), and decays - * away exponentially, at a rate which is proportionally slower when - * the system is busy. The basic principle is that the system will - * 90% forget that the process used a lot of CPU time in 5 * loadav - * seconds. This causes the system to favor processes which haven't - * run much recently, and to round-robin among other processes. - */ void sched_clock(struct thread *td) { @@ -334,26 +247,23 @@ ts = td->td_sched; ts->ts_cpticks++; - td->td_estcpu = ESTCPULIM(td->td_estcpu + 1); - /* - * Force a context switch if the current thread has used up a full - * quantum (default quantum is 100ms). - */ - if (!TD_IS_IDLETHREAD(td) && - ticks - PCPU_GET(switchticks) >= sched_quantum) { - td->td_flags |= TDF_NEEDRESCHED; - ts->ts_vdeadline = ticks + sched_quantum * - prio_ratios[td->td_proc->p_nice - PRIO_MIN] / 128; - - CTR4(KTR_SCHED, "timeslice fill: t: %d, i: %d, r: %d, d: %d", - ticks, td->td_proc->p_nice - PRIO_MIN, - prio_ratios[td->td_proc->p_nice - PRIO_MIN], - ts->ts_vdeadline - ); + if (--ts->ts_slice > 0) + return; + + ts->ts_vdeadline = ticks + sched_slice * + prio_ratios[td->td_proc->p_nice - PRIO_MIN] / 128; + ts->ts_slice = sched_slice; + td->td_flags |= TDF_NEEDRESCHED; + + CTR4(KTR_SCHED, "timeslice fill: t: %d, i: %d, r: %d, d: %d", + ticks, td->td_proc->p_nice - PRIO_MIN, + prio_ratios[td->td_proc->p_nice - PRIO_MIN], + ts->ts_vdeadline + ); - CTR1(KTR_SCHED, "queue number: %d", td->td_rqindex); - } + CTR1(KTR_SCHED, "queue number: %d", td->td_rqindex); + CTR1(KTR_SCHED, "thread: 0x%x", td); } /* @@ -377,7 +287,6 @@ KTR_STATE1(KTR_SCHED, "thread", sched_tdname(child), "exit", "prio:%d", child->td_priority); thread_lock(td); - td->td_estcpu = ESTCPULIM(td->td_estcpu + child->td_estcpu); thread_unlock(td); mtx_lock_spin(&sched_lock); if ((child->td_proc->p_flag & P_NOLOAD) == 0) @@ -396,12 +305,14 @@ { struct td_sched *ts; - childtd->td_estcpu = td->td_estcpu; childtd->td_lock = &sched_lock; childtd->td_cpuset = cpuset_ref(td->td_cpuset); ts = childtd->td_sched; bzero(ts, sizeof(*ts)); + td->td_sched->ts_slice /= 2; ts->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY); + ts->ts_vdeadline = td->td_sched->ts_vdeadline; + ts->ts_slice = td->td_sched->ts_slice; } void @@ -789,7 +700,7 @@ if (rqb->rqb_bits[i] == 0) continue; pri = RQB_FFS(rqb->rqb_bits[i]) + (i << RQB_L2BPW); - if (pri == RQ_TIMESHARE) { + if ((pri == RQ_TIMESHARE) || (pri == RQ_IDLE)) { td = edf_choose(&rq->rq_queues[pri]); return (td); }