From owner-svn-src-projects@FreeBSD.ORG Sun Feb 7 00:07:38 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11656106568B; Sun, 7 Feb 2010 00:07:38 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F3BE38FC08; Sun, 7 Feb 2010 00:07:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1707b8i079291; Sun, 7 Feb 2010 00:07:37 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1707bds079284; Sun, 7 Feb 2010 00:07:37 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002070007.o1707bds079284@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 7 Feb 2010 00:07:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203581 - in projects/ppc64: gnu/usr.bin/gdb/arch/powerpc lib/libc/powerpc64/gen lib/libc/stdlib lib/libthr/arch/powerpc64/include rescue/rescue share/mk X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 00:07:38 -0000 Author: nwhitehorn Date: Sun Feb 7 00:07:37 2010 New Revision: 203581 URL: http://svn.freebsd.org/changeset/base/203581 Log: Correct some nits in the build process. With these changes, powerpc64 is fully self-hosting. Next up: figure out why NO_TLS is required by malloc and fix it, and then begin cleaning up this branch and tying up loose ends. Modified: projects/ppc64/gnu/usr.bin/gdb/arch/powerpc/config.h projects/ppc64/lib/libc/powerpc64/gen/_set_tp.c projects/ppc64/lib/libc/stdlib/malloc.c projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h projects/ppc64/rescue/rescue/Makefile projects/ppc64/share/mk/bsd.cpu.mk Modified: projects/ppc64/gnu/usr.bin/gdb/arch/powerpc/config.h ============================================================================== --- projects/ppc64/gnu/usr.bin/gdb/arch/powerpc/config.h Sat Feb 6 23:47:55 2010 (r203580) +++ projects/ppc64/gnu/usr.bin/gdb/arch/powerpc/config.h Sun Feb 7 00:07:37 2010 (r203581) @@ -446,7 +446,7 @@ #define DEFAULT_BFD_ARCH bfd_rs6000_arch /* Define to BFD's default target vector. */ -#define DEFAULT_BFD_VEC bfd_elf32_powerpc_vec +#define DEFAULT_BFD_VEC bfd_elf64_powerpc_vec /* Define to 1 if your system has the _etext variable. */ #define HAVE__ETEXT 1 Modified: projects/ppc64/lib/libc/powerpc64/gen/_set_tp.c ============================================================================== --- projects/ppc64/lib/libc/powerpc64/gen/_set_tp.c Sat Feb 6 23:47:55 2010 (r203580) +++ projects/ppc64/lib/libc/powerpc64/gen/_set_tp.c Sun Feb 7 00:07:37 2010 (r203581) @@ -31,5 +31,5 @@ _set_tp(void *tpval) { register void *tp __asm__("r13"); - __asm __volatile("mr %0,%1" : "=r"(tp) : "r"((char*)tpval + 0x7016)); + __asm __volatile("mr %0,%1" : "=r"(tp) : "r"((char*)tpval + 0x7010)); } Modified: projects/ppc64/lib/libc/stdlib/malloc.c ============================================================================== --- projects/ppc64/lib/libc/stdlib/malloc.c Sat Feb 6 23:47:55 2010 (r203580) +++ projects/ppc64/lib/libc/stdlib/malloc.c Sun Feb 7 00:07:37 2010 (r203581) @@ -253,6 +253,7 @@ __FBSDID("$FreeBSD$"); #ifdef __powerpc64__ # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 3 +# define NO_TLS #elif defined(__powerpc__) # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 2 Modified: projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h ============================================================================== --- projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h Sat Feb 6 23:47:55 2010 (r203580) +++ projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h Sun Feb 7 00:07:37 2010 (r203581) @@ -39,7 +39,7 @@ #define CPU_SPINWAIT #define DTV_OFFSET offsetof(struct tcb, tcb_dtv) -#define TP_OFFSET 0x8000 +#define TP_OFFSET 0x7010 /* * Variant I tcb. The structure layout is fixed, don't blindly Modified: projects/ppc64/rescue/rescue/Makefile ============================================================================== --- projects/ppc64/rescue/rescue/Makefile Sat Feb 6 23:47:55 2010 (r203580) +++ projects/ppc64/rescue/rescue/Makefile Sun Feb 7 00:07:37 2010 (r203581) @@ -47,7 +47,7 @@ CLEANFILES+= dhclient_FIXED # Define Makefile variable RESCUE CRUNCH_BUILDOPTS+= -DRESCUE # Define compile-time RESCUE symbol when compiling components -.if ${TARGET_ARCH} == powerpc64 +.if ${MACHINE_ARCH} == powerpc64 CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=\"-DRESCUE -mminimal-toc\" .else CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE Modified: projects/ppc64/share/mk/bsd.cpu.mk ============================================================================== --- projects/ppc64/share/mk/bsd.cpu.mk Sat Feb 6 23:47:55 2010 (r203580) +++ projects/ppc64/share/mk/bsd.cpu.mk Sun Feb 7 00:07:37 2010 (r203581) @@ -12,7 +12,7 @@ MACHINE_CPU = i486 MACHINE_CPU = amd64 sse2 sse . elif ${MACHINE_ARCH} == "ia64" MACHINE_CPU = itanium -. elif ${MACHINE_ARCH} == "powerpc" +. elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" MACHINE_CPU = aim . elif ${MACHINE_ARCH} == "sparc64" . elif ${MACHINE_ARCH} == "arm" @@ -121,6 +121,8 @@ _CPUCFLAGS = -Wa,-me500 -msoft-float . else _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64 . endif +. elif ${MACHINE_ARCH} == "powerpc64" +_CPUCFLAGS = -mcpu=${CPUTYPE} . elif ${MACHINE_ARCH} == "mips" . if ${CPUTYPE} == "mips32" _CPUCFLAGS = -march=mips32 From owner-svn-src-projects@FreeBSD.ORG Sun Feb 7 05:50:00 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4D151065672; Sun, 7 Feb 2010 05:50:00 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 788738FC19; Sun, 7 Feb 2010 05:50:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o175o0QR055962; Sun, 7 Feb 2010 05:50:00 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o175o0Qn055959; Sun, 7 Feb 2010 05:50:00 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002070550.o175o0Qn055959@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 7 Feb 2010 05:50:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203602 - in projects/ppc64: contrib/binutils/bfd lib/libc/stdlib X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 05:50:00 -0000 Author: nwhitehorn Date: Sun Feb 7 05:50:00 2010 New Revision: 203602 URL: http://svn.freebsd.org/changeset/base/203602 Log: Revert r202955, which was the wrong solution to a binutils bug when processing TLS relocations in shared objects, and replace it with the correct solution. This patch is inspired by version 1.217 of upstream binutils. This commit fixes the problems with malloc TLS on powerpc64. Modified: projects/ppc64/contrib/binutils/bfd/elf64-ppc.c projects/ppc64/lib/libc/stdlib/malloc.c Modified: projects/ppc64/contrib/binutils/bfd/elf64-ppc.c ============================================================================== --- projects/ppc64/contrib/binutils/bfd/elf64-ppc.c Sun Feb 7 05:16:38 2010 (r203601) +++ projects/ppc64/contrib/binutils/bfd/elf64-ppc.c Sun Feb 7 05:50:00 2010 (r203602) @@ -3268,15 +3268,13 @@ create_got_section (bfd *abfd, struct bf flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - got = bfd_get_section_by_name(abfd, ".got"); - if (!got) - got = bfd_make_section (abfd, ".got"); + got = bfd_make_section_anyway (abfd, ".got"); if (!got || !bfd_set_section_flags (abfd, got, flags) || !bfd_set_section_alignment (abfd, got, 3)) return FALSE; - relgot = bfd_make_section (abfd, ".rela.got"); + relgot = bfd_make_section_anyway (abfd, ".rela.got"); if (!relgot || ! bfd_set_section_flags (abfd, relgot, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, relgot, 3)) Modified: projects/ppc64/lib/libc/stdlib/malloc.c ============================================================================== --- projects/ppc64/lib/libc/stdlib/malloc.c Sun Feb 7 05:16:38 2010 (r203601) +++ projects/ppc64/lib/libc/stdlib/malloc.c Sun Feb 7 05:50:00 2010 (r203602) @@ -253,7 +253,6 @@ __FBSDID("$FreeBSD$"); #ifdef __powerpc64__ # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 3 -# define NO_TLS #elif defined(__powerpc__) # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 2 From owner-svn-src-projects@FreeBSD.ORG Sun Feb 7 19:34:08 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA6541065670; Sun, 7 Feb 2010 19:34:08 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B7D068FC2A; Sun, 7 Feb 2010 19:34:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o17JY8L4013785; Sun, 7 Feb 2010 19:34:08 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o17JY8XY013775; Sun, 7 Feb 2010 19:34:08 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002071934.o17JY8XY013775@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 7 Feb 2010 19:34:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203626 - in projects/ppc64/sys: conf modules modules/hwpmc modules/sound/driver modules/uart powerpc/aim powerpc/include powerpc/powerpc powerpc64/powerpc64 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 19:34:08 -0000 Author: nwhitehorn Date: Sun Feb 7 19:34:08 2010 New Revision: 203626 URL: http://svn.freebsd.org/changeset/base/203626 Log: Make KLDs work correctly on powerpc64. Added: projects/ppc64/sys/powerpc64/powerpc64/mem.c (contents, props changed) Modified: projects/ppc64/sys/conf/kmod.mk projects/ppc64/sys/modules/Makefile projects/ppc64/sys/modules/hwpmc/Makefile projects/ppc64/sys/modules/sound/driver/Makefile projects/ppc64/sys/modules/uart/Makefile projects/ppc64/sys/powerpc/aim/swtch64.S projects/ppc64/sys/powerpc/include/param.h projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c Modified: projects/ppc64/sys/conf/kmod.mk ============================================================================== --- projects/ppc64/sys/conf/kmod.mk Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/conf/kmod.mk Sun Feb 7 19:34:08 2010 (r203626) @@ -124,7 +124,7 @@ CFLAGS+= ${DEBUG_FLAGS} CFLAGS+= -fno-omit-frame-pointer .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" CFLAGS+= -mlongcall -fno-omit-frame-pointer .endif Modified: projects/ppc64/sys/modules/Makefile ============================================================================== --- projects/ppc64/sys/modules/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -308,7 +308,7 @@ SUBDIR= ${_3dfx} \ ${_zfs} \ zlib \ -.if ${MACHINE_ARCH} != "powerpc" +.if ${MACHINE_ARCH} != "powerpc" && ${MACHINE_ARCH} != "powerpc64" _syscons= syscons _vpo= vpo .endif @@ -597,7 +597,7 @@ _wi= wi _xe= xe .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" _an= an _bm= bm _cpufreq= cpufreq Modified: projects/ppc64/sys/modules/hwpmc/Makefile ============================================================================== --- projects/ppc64/sys/modules/hwpmc/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/hwpmc/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -28,7 +28,7 @@ SRCS+= device_if.h bus_if.h SRCS+= hwpmc_ia64.c .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" SRCS+= hwpmc_powerpc.c .endif Modified: projects/ppc64/sys/modules/sound/driver/Makefile ============================================================================== --- projects/ppc64/sys/modules/sound/driver/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/sound/driver/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -15,7 +15,7 @@ SUBDIR+= audiocs .endif .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" SUBDIR+= ai2s davbus .endif Modified: projects/ppc64/sys/modules/uart/Makefile ============================================================================== --- projects/ppc64/sys/modules/uart/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/uart/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -16,6 +16,8 @@ SRCS= uart_bus_acpi.c ${uart_bus_ebus} u uart_if.c uart_if.h uart_subr.c uart_tty.c .if ${MACHINE} == "sun4v" SRCS+= uart_cpu_sparc64.c +.elif ${MACHINE} == "powerpc64" +SRCS+= uart_cpu_powerpc.c .else SRCS+= uart_cpu_${MACHINE}.c .endif Modified: projects/ppc64/sys/powerpc/aim/swtch64.S ============================================================================== --- projects/ppc64/sys/powerpc/aim/swtch64.S Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/powerpc/aim/swtch64.S Sun Feb 7 19:34:08 2010 (r203626) @@ -126,6 +126,8 @@ ENTRY(cpu_switch) mr %r16,%r5 /* and the new lock */ mr %r17,%r6 /* and the PCB */ + stdu %r1,-48(%r1) + lwz %r7,PCB_FLAGS(%r17) /* Save FPU context if needed */ andi. %r7, %r7, PCB_FPU @@ -147,6 +149,8 @@ ENTRY(cpu_switch) bl .pmap_deactivate /* Deactivate the current pmap */ nop + addi %r1,%r1,48 + std %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */ cpu_switchin: @@ -165,6 +169,8 @@ blocked_loop: ld %r17,TD_PCB(%r15) /* Store new current PCB */ std %r17,PC_CURPCB(%r7) + stdu %r1,-48(%r1) + mr %r3,%r15 /* Get new thread ptr */ bl .pmap_activate /* Activate the new address space */ nop @@ -188,6 +194,7 @@ blocked_loop: /* thread to restore is in r3 */ .L4: + addi %r1,%r1,48 mr %r3,%r17 /* Recover PCB ptr */ ld %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs. */ ld %r13,PCB_CONTEXT+1*8(%r3) @@ -272,9 +279,11 @@ ENTRY(fork_trampoline) ld %r3,CF_FUNC(%r1) ld %r4,CF_ARG0(%r1) ld %r5,CF_ARG1(%r1) + + stdu %r1,-48(%r1) bl .fork_exit nop - addi %r1,%r1,CF_SIZE-FSP /* Allow 8 bytes in front of + addi %r1,%r1,48+CF_SIZE-FSP /* Allow 8 bytes in front of trapframe to simulate FRAME_SETUP does when allocating space for a frame pointer/saved LR */ Modified: projects/ppc64/sys/powerpc/include/param.h ============================================================================== --- projects/ppc64/sys/powerpc/include/param.h Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/powerpc/include/param.h Sun Feb 7 19:34:08 2010 (r203626) @@ -76,7 +76,7 @@ * This does not reflect the optimal alignment, just the possibility * (within reasonable limits). */ -#define ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof (t) - 1)) == 0) +#define ALIGNED_POINTER(p, t) ((((uintptr_t)(p)) & (sizeof (t) - 1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an Modified: projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c Sun Feb 7 19:34:08 2010 (r203626) @@ -125,7 +125,6 @@ elf_reloc_internal(linker_file_t lf, Elf int type, int local, elf_lookup_fn lookup) { Elf_Addr *where; - Elf_Half *hwhere; Elf_Addr addr; Elf_Addr addend; Elf_Word rtype, symidx; @@ -138,7 +137,6 @@ elf_reloc_internal(linker_file_t lf, Elf case ELF_RELOC_RELA: rela = (const Elf_Rela *)data; where = (Elf_Addr *) (relocbase + rela->r_offset); - hwhere = (Elf_Half *) (relocbase + rela->r_offset); addend = rela->r_addend; rtype = ELF_R_TYPE(rela->r_info); symidx = ELF_R_SYM(rela->r_info); @@ -152,7 +150,7 @@ elf_reloc_internal(linker_file_t lf, Elf case R_PPC_NONE: break; - case R_PPC_ADDR32: /* word32 S + A */ + case R_PPC64_ADDR64: /* doubleword64 S + A */ addr = lookup(lf, symidx, 1); if (addr == 0) return -1; @@ -160,43 +158,16 @@ elf_reloc_internal(linker_file_t lf, Elf *where = addr; break; - case R_PPC_ADDR16_LO: /* #lo(S) */ - addr = lookup(lf, symidx, 1); - if (addr == 0) - return -1; - /* - * addend values are sometimes relative to sections - * (i.e. .rodata) in rela, where in reality they - * are relative to relocbase. Detect this condition. - */ - if (addr > relocbase && addr <= (relocbase + addend)) - addr = relocbase + addend; - else - addr += addend; - *hwhere = addr & 0xffff; - break; + case R_PPC_RELATIVE: /* doubleword64 B + A */ + *where = elf_relocaddr(lf, relocbase + addend); + break; - case R_PPC_ADDR16_HA: /* #ha(S) */ + case R_PPC_JMP_SLOT: /* function descriptor copy */ addr = lookup(lf, symidx, 1); - if (addr == 0) - return -1; - /* - * addend values are sometimes relative to sections - * (i.e. .rodata) in rela, where in reality they - * are relative to relocbase. Detect this condition. - */ - if (addr > relocbase && addr <= (relocbase + addend)) - addr = relocbase + addend; - else - addr += addend; - *hwhere = ((addr >> 16) + ((addr & 0x8000) ? 1 : 0)) - & 0xffff; + memcpy(where, (Elf_Addr *)addr, 3*sizeof(Elf_Addr)); + __asm __volatile("dcbst 0,%0; sync" :: "r"(where) : "memory"); break; - case R_PPC_RELATIVE: /* word32 B + A */ - *where = elf_relocaddr(lf, relocbase + addend); - break; - default: printf("kldload: unexpected relocation type %d\n", (int) rtype); Added: projects/ppc64/sys/powerpc64/powerpc64/mem.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/ppc64/sys/powerpc64/powerpc64/mem.c Sun Feb 7 19:34:08 2010 (r203626) @@ -0,0 +1 @@ +link ../../powerpc/powerpc/mem.c \ No newline at end of file From owner-svn-src-projects@FreeBSD.ORG Sun Feb 7 23:49:28 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A40D106566C; Sun, 7 Feb 2010 23:49:27 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D90378FC08; Sun, 7 Feb 2010 23:49:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o17NnRRZ070729; Sun, 7 Feb 2010 23:49:27 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o17NnRSw070727; Sun, 7 Feb 2010 23:49:27 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002072349.o17NnRSw070727@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 7 Feb 2010 23:49:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203641 - projects/ppc64/lib/libc/gen X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 23:49:28 -0000 Author: nwhitehorn Date: Sun Feb 7 23:49:27 2010 New Revision: 203641 URL: http://svn.freebsd.org/changeset/base/203641 Log: Convert some #pragma weak to __weak_reference, which fixes dlopen(). This allows python to build and work. Modified: projects/ppc64/lib/libc/gen/dlfcn.c Modified: projects/ppc64/lib/libc/gen/dlfcn.c ============================================================================== --- projects/ppc64/lib/libc/gen/dlfcn.c Sun Feb 7 22:24:04 2010 (r203640) +++ projects/ppc64/lib/libc/gen/dlfcn.c Sun Feb 7 23:49:27 2010 (r203641) @@ -46,38 +46,44 @@ static const char sorry[] = "Service una * be weak symbols so that the dynamic linker can override them. */ -#pragma weak _rtld_error +void _rtld_error(const char *fmt, ...); +__weak_reference(_libc_rtld_error, _rtld_error); + void -_rtld_error(const char *fmt, ...) +_libc_rtld_error(const char *fmt, ...) { } -#pragma weak dladdr +__weak_reference(_libc_dladdr, dladdr); + int -dladdr(const void *addr, Dl_info *dlip) +_libc_dladdr(const void *addr, Dl_info *dlip) { _rtld_error(sorry); return 0; } -#pragma weak dlclose +__weak_reference(_libc_dlclose, dlclose); + int -dlclose(void *handle) +_libc_dlclose(void *handle) { _rtld_error(sorry); return -1; } -#pragma weak dlerror +__weak_reference(_libc_dlerror, dlerror); + const char * -dlerror(void) +_libc_dlerror(void) { return sorry; } -#pragma weak dllockinit +__weak_reference(_libc_dllockinit, dllockinit); + void -dllockinit(void *context, +_libc_dllockinit(void *context, void *(*lock_create)(void *context), void (*rlock_acquire)(void *lock), void (*wlock_acquire)(void *lock), @@ -89,71 +95,80 @@ dllockinit(void *context, context_destroy(context); } -#pragma weak dlopen +__weak_reference(_libc_dlopen, dlopen); + void * -dlopen(const char *name, int mode) +_libc_dlopen(const char *name, int mode) { _rtld_error(sorry); return NULL; } -#pragma weak dlsym +__weak_reference(_libc_dlsym, dlsym); + void * -dlsym(void * __restrict handle, const char * __restrict name) +_libc_dlsym(void * __restrict handle, const char * __restrict name) { _rtld_error(sorry); return NULL; } -#pragma weak dlfunc +__weak_reference(_libc_dlfunc, dlfunc); + dlfunc_t -dlfunc(void * __restrict handle, const char * __restrict name) +_libc_dlfunc(void * __restrict handle, const char * __restrict name) { _rtld_error(sorry); return NULL; } -#pragma weak dlvsym +__weak_reference(_libc_dlvsym, dlvsym); + void * -dlvsym(void * __restrict handle, const char * __restrict name, +_libc_dlvsym(void * __restrict handle, const char * __restrict name, const char * __restrict version) { _rtld_error(sorry); return NULL; } -#pragma weak dlinfo +__weak_reference(_libc_dlinfo, dlinfo); + int -dlinfo(void * __restrict handle, int request, void * __restrict p) +_libc_dlinfo(void * __restrict handle, int request, void * __restrict p) { _rtld_error(sorry); return 0; } -#pragma weak _rtld_thread_init +__weak_reference(_libc_rtld_thread_init, _rtld_thread_init); + void -_rtld_thread_init(void * li) +_libc_rtld_thread_init(void * li) { _rtld_error(sorry); } -#pragma weak dl_iterate_phdr +__weak_reference(_libc_dl_iterate_phdr, dl_iterate_phdr); + int -dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), +_libc_dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), void *data) { _rtld_error(sorry); return 0; } -#pragma weak _rtld_atfork_pre +__weak_reference(_libc_rtld_atfork_pre, _rtld_atfork_pre); + void -_rtld_atfork_pre(int *locks) +_libc_rtld_atfork_pre(int *locks) { } -#pragma weak _rtld_atfork_post +__weak_reference(_libc_rtld_atfork_post, _rtld_atfork_post); + void -_rtld_atfork_post(int *locks) +_libc_rtld_atfork_post(int *locks) { } From owner-svn-src-projects@FreeBSD.ORG Mon Feb 8 14:04:33 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 700F4106568D; Mon, 8 Feb 2010 14:04:33 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F38A8FC19; Mon, 8 Feb 2010 14:04:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o18E4XXc063413; Mon, 8 Feb 2010 14:04:33 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o18E4Xkh063380; Mon, 8 Feb 2010 14:04:33 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201002081404.o18E4Xkh063380@svn.freebsd.org> From: Lawrence Stewart Date: Mon, 8 Feb 2010 14:04:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203661 - in projects/tcp_cc_head/sys: modules/ertt netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2010 14:04:33 -0000 Author: lstewart Date: Mon Feb 8 14:04:32 2010 New Revision: 203661 URL: http://svn.freebsd.org/changeset/base/203661 Log: - Switch to using UMA for helper data block memory management. - Add concept of helpers belonging to one or more classes so that we can eventually group related helpers. - Lots of bug fixing and cleanup around the place. Added: projects/tcp_cc_head/sys/netinet/h_ertt.c - copied, changed from r203640, projects/tcp_cc_head/sys/netinet/ertt.c Deleted: projects/tcp_cc_head/sys/netinet/ertt.c Modified: projects/tcp_cc_head/sys/modules/ertt/Makefile projects/tcp_cc_head/sys/netinet/helper.c projects/tcp_cc_head/sys/netinet/helper.h projects/tcp_cc_head/sys/netinet/helper_module.h projects/tcp_cc_head/sys/netinet/hhooks.c Modified: projects/tcp_cc_head/sys/modules/ertt/Makefile ============================================================================== --- projects/tcp_cc_head/sys/modules/ertt/Makefile Mon Feb 8 10:02:01 2010 (r203660) +++ projects/tcp_cc_head/sys/modules/ertt/Makefile Mon Feb 8 14:04:32 2010 (r203661) @@ -3,8 +3,8 @@ .include .PATH: ${.CURDIR}/../../netinet -KMOD=hlpr_ertt -SRCS=ertt.c +KMOD=h_ertt +SRCS=h_ertt.c .include Copied and modified: projects/tcp_cc_head/sys/netinet/h_ertt.c (from r203640, projects/tcp_cc_head/sys/netinet/ertt.c) ============================================================================== --- projects/tcp_cc_head/sys/netinet/ertt.c Sun Feb 7 22:24:04 2010 (r203640, copy source) +++ projects/tcp_cc_head/sys/netinet/h_ertt.c Mon Feb 8 14:04:32 2010 (r203661) @@ -55,8 +55,8 @@ __FBSDID("$FreeBSD$"); void ertt_tcpest_hook(void *udata, void *ctx_data, void *dblock); int ertt_mod_init(void); int ertt_mod_destroy(void); -int ertt_block_init(void **block); -int ertt_block_destroy(void *block); +int ertt_uma_ctor(void *mem, int size, void *arg, int flags); +void ertt_uma_dtor(void *mem, int size, void *arg); struct ertt { int test; @@ -65,9 +65,8 @@ struct ertt { struct helper ertt_helper = { .mod_init = ertt_mod_init, .mod_destroy = ertt_mod_destroy, - .block_init = ertt_block_init, - .block_destroy = ertt_block_destroy, - .flags = HELPER_NEEDS_DBLOCK + .flags = HELPER_NEEDS_DBLOCK, + .class = HELPER_CLASS_TCP }; @@ -96,25 +95,19 @@ ertt_mod_destroy(void) } int -ertt_block_init(void **block) +ertt_uma_ctor(void *mem, int size, void *arg, int flags) { - *block = malloc(sizeof(struct ertt), M_HELPER, M_NOWAIT); + printf("Creating ertt block %p\n", mem); - ((struct ertt *)*block)->test = 5; - - printf("Malloced %ld bytes for ertt and set the value to %d\n", - sizeof(struct ertt), ((struct ertt *)*block)->test); + ((struct ertt *)mem)->test = 5; return (0); } -int -ertt_block_destroy(void *block) +void +ertt_uma_dtor(void *mem, int size, void *arg) { - KASSERT(block != NULL, ("Block is NULL!")); - free(block, M_HELPER); - - return (0); + printf("Destroying ertt block %p\n", mem); } -DECLARE_HELPER(ertt, &ertt_helper); +DECLARE_HELPER_UMA(ertt, &ertt_helper, sizeof(struct ertt), ertt_uma_ctor, ertt_uma_dtor); Modified: projects/tcp_cc_head/sys/netinet/helper.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/helper.c Mon Feb 8 10:02:01 2010 (r203660) +++ projects/tcp_cc_head/sys/netinet/helper.c Mon Feb 8 14:04:32 2010 (r203661) @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -78,16 +80,23 @@ init_helper_dblocks(struct helper_dblock if (*dblocks != NULL) { printf("Malloced ptr %p for %d data blocks\n", *dblocks, num_dblocks); STAILQ_FOREACH(h, &helpers, h_next) { - if (h->block_init != NULL) { + if (h->flags & HELPER_NEEDS_DBLOCK) { dblock = dblocks[i]; - h->block_init(&dblock->block); + dblock->block = uma_zalloc(h->zone, M_NOWAIT); + /* + if (dblock[i]->block == NULL) { + XXX: Free all previous dblocks. + error = ENOMEM + break; + } + */ dblock->id = h->id; printf("dblock[%d]: id=%d, block=%p\n", i, dblock->id, dblock->block); + i++; } - i++; } - *nblocks = num_dblocks; + *nblocks = i; } else error = ENOMEM; @@ -96,26 +105,26 @@ init_helper_dblocks(struct helper_dblock } int -destroy_helper_dblocks(struct helper_dblock *array_head, int nblocks) +destroy_helper_dblocks(struct helper_dblock *dblocks, int nblocks) { struct helper *h; HELPER_LIST_WLOCK(); for (nblocks--; nblocks >= 0; nblocks--) { - h = get_helper(array_head[nblocks].id); - if (h->block_destroy != NULL) - h->block_destroy(array_head[nblocks].block); + h = get_helper(dblocks[nblocks].id); + uma_zfree(h->zone, dblocks[nblocks].block); } HELPER_LIST_WUNLOCK(); + free(dblocks, M_HELPER); return (0); } int register_helper(struct helper *h) { - printf("Register helper 0x%p\n", h); + printf("Register helper %p\n", h); HELPER_LIST_WLOCK(); @@ -123,26 +132,27 @@ register_helper(struct helper *h) num_dblocks++; h->id = helper_id++; - STAILQ_INSERT_TAIL(&helpers, h, h_next); - HELPER_LIST_WUNLOCK(); - return (0); } int deregister_helper(struct helper *h) { - printf("Deregister helper 0x%p\n", h); + printf("Deregister helper %p\n", h); + + /* + HHOOK_WLOCK + Remove this helper's hooks + HHOOK_WUNLOCK + */ HELPER_LIST_WLOCK(); STAILQ_REMOVE(&helpers, h, helper, h_next); - num_dblocks--; + if (h->flags | HELPER_NEEDS_DBLOCK) + num_dblocks--; HELPER_LIST_WUNLOCK(); - - /* Block unload if there are still consumers to avoid mem leak*/ - return (0); } @@ -167,23 +177,38 @@ get_helper(int id) * Handles kld related events. Returns 0 on success, non-zero on failure. */ int -hlpr_modevent(module_t mod, int event_type, void *data) +helper_modevent(module_t mod, int event_type, void *data) { int error = 0; - struct helper *h = (struct helper *)data; + struct helper_modevent_data *hmd = (struct helper_modevent_data *)data; switch(event_type) { case MOD_LOAD: - if (h->mod_init != NULL) - error = h->mod_init(); + if (hmd->helper->flags & HELPER_NEEDS_DBLOCK) { + if (hmd->uma_zsize <= 0) { + printf("Use DECLARE_HELPER_UMA() instead!\n"); + error = EDOOFUS; + break; + } + hmd->helper->zone = uma_zcreate(hmd->name, + hmd->uma_zsize, hmd->umactor, hmd->umadtor, + NULL, NULL, 0, 0); + if (hmd->helper->zone == NULL) { + error = ENOMEM; + break; + } + } + if (hmd->helper->mod_init != NULL) + error = hmd->helper->mod_init(); if (!error) - error = register_helper(h); + error = register_helper(hmd->helper); break; case MOD_QUIESCE: - error = deregister_helper(h); - if (!error && h->mod_destroy != NULL) - h->mod_destroy(); + error = deregister_helper(hmd->helper); + uma_zdestroy(hmd->helper->zone); + if (!error && hmd->helper->mod_destroy != NULL) + hmd->helper->mod_destroy(); break; case MOD_SHUTDOWN: Modified: projects/tcp_cc_head/sys/netinet/helper.h ============================================================================== --- projects/tcp_cc_head/sys/netinet/helper.h Mon Feb 8 10:02:01 2010 (r203660) +++ projects/tcp_cc_head/sys/netinet/helper.h Mon Feb 8 14:04:32 2010 (r203661) @@ -48,10 +48,10 @@ struct helper { /* Cleanup global module state on kldunload. */ int (*mod_destroy) (void); - int (*block_init) (void **data); - int (*block_destroy) (void *data); - uint16_t flags; + uint32_t class; + + uma_zone_t zone; //STAILQ hooks; /* which hooks does this helper want to be called from */ unsigned int id; /* ID assigned by system to this hlpr's data in the @@ -64,6 +64,8 @@ struct helper { /* Helper flags */ #define HELPER_NEEDS_DBLOCK 0x0001 +/* Helper classes */ +#define HELPER_CLASS_TCP 0x00000001 int init_helper_dblocks(struct helper_dblock **dblocks, int *nblocks); int destroy_helper_dblocks(struct helper_dblock *array_head, int nblocks); Modified: projects/tcp_cc_head/sys/netinet/helper_module.h ============================================================================== --- projects/tcp_cc_head/sys/netinet/helper_module.h Mon Feb 8 10:02:01 2010 (r203660) +++ projects/tcp_cc_head/sys/netinet/helper_module.h Mon Feb 8 14:04:32 2010 (r203661) @@ -30,22 +30,50 @@ * $FreeBSD$ */ -#ifndef _NETINET_TCP_HELPER_MODULE_H_ -#define _NETINET_TCP_HELPER_MODULE_H_ +#ifndef _NETINET_HELPER_MODULE_H_ +#define _NETINET_HELPER_MODULE_H_ -#define DECLARE_HELPER(hlprname, hlpr_data) \ - static moduledata_t hlpr_##hlprname = { \ - #hlprname, \ - hlpr_modevent, \ - hlpr_data \ +struct helper_modevent_data { + char *name; + struct helper *helper; + int uma_zsize; + uma_ctor umactor; + uma_dtor umadtor; +}; + +#define DECLARE_HELPER(hname, hdata) \ + static struct helper_modevent_data hmd_##hname = { \ + .name = #hname, \ + .helper = hdata \ }; \ - DECLARE_MODULE(hlprname, hlpr_##hlprname, SI_SUB_PROTO_IFATTACHDOMAIN, \ + static moduledata_t h_##hname = { \ + .name = #hname, \ + .evhand = helper_modevent, \ + .priv = &hmd_##hname \ + }; \ + DECLARE_MODULE(hname, h_##hname, SI_SUB_PROTO_IFATTACHDOMAIN, \ + SI_ORDER_ANY) + +#define DECLARE_HELPER_UMA(hname, hdata, size, ctor, dtor) \ + static struct helper_modevent_data hmd_##hname = { \ + .name = #hname, \ + .helper = hdata, \ + .uma_zsize = size, \ + .umactor = ctor, \ + .umadtor = dtor \ + }; \ + static moduledata_t h_##hname = { \ + .name = #hname, \ + .evhand = helper_modevent, \ + .priv = &hmd_##hname \ + }; \ + DECLARE_MODULE(hname, h_##hname, SI_SUB_PROTO_IFATTACHDOMAIN, \ SI_ORDER_ANY) -int hlpr_modevent(module_t mod, int type, void *data); +int helper_modevent(module_t mod, int type, void *data); MALLOC_DECLARE(M_HELPER); MALLOC_DEFINE(M_HELPER, "helper data", "Blah"); -#endif +#endif /* _NETINET_HELPER_MODULE_H_ */ Modified: projects/tcp_cc_head/sys/netinet/hhooks.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/hhooks.c Mon Feb 8 10:02:01 2010 (r203660) +++ projects/tcp_cc_head/sys/netinet/hhooks.c Mon Feb 8 14:04:32 2010 (r203661) @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -227,8 +229,8 @@ run_hhooks(int hhook_type, int hhook_id, return; STAILQ_FOREACH(tmp, &hh->hh_hooks, h_next) { - printf("Running hook %p for helper %d\n", tmp, - tmp->h_helper->id); + //printf("Running hook %p for helper %d\n", tmp, + //tmp->h_helper->id); if (tmp->h_helper->flags & HELPER_NEEDS_DBLOCK) { if (n_dblocks == 0 || i >= n_dblocks From owner-svn-src-projects@FreeBSD.ORG Mon Feb 8 14:09:07 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B0351065672; Mon, 8 Feb 2010 14:09:07 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B0E58FC26; Mon, 8 Feb 2010 14:09:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o18E97GE064486; Mon, 8 Feb 2010 14:09:07 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o18E97Zt064484; Mon, 8 Feb 2010 14:09:07 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002081409.o18E97Zt064484@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 8 Feb 2010 14:09:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203663 - projects/ppc64/lib/libc/gen X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2010 14:09:07 -0000 Author: nwhitehorn Date: Mon Feb 8 14:09:07 2010 New Revision: 203663 URL: http://svn.freebsd.org/changeset/base/203663 Log: Revert r203641, which was not actually necessary. The real problem was a busted symlink, which installed the patched version of libc had the side effect of overwriting. Modified: projects/ppc64/lib/libc/gen/dlfcn.c Modified: projects/ppc64/lib/libc/gen/dlfcn.c ============================================================================== --- projects/ppc64/lib/libc/gen/dlfcn.c Mon Feb 8 14:08:52 2010 (r203662) +++ projects/ppc64/lib/libc/gen/dlfcn.c Mon Feb 8 14:09:07 2010 (r203663) @@ -46,44 +46,38 @@ static const char sorry[] = "Service una * be weak symbols so that the dynamic linker can override them. */ -void _rtld_error(const char *fmt, ...); -__weak_reference(_libc_rtld_error, _rtld_error); - +#pragma weak _rtld_error void -_libc_rtld_error(const char *fmt, ...) +_rtld_error(const char *fmt, ...) { } -__weak_reference(_libc_dladdr, dladdr); - +#pragma weak dladdr int -_libc_dladdr(const void *addr, Dl_info *dlip) +dladdr(const void *addr, Dl_info *dlip) { _rtld_error(sorry); return 0; } -__weak_reference(_libc_dlclose, dlclose); - +#pragma weak dlclose int -_libc_dlclose(void *handle) +dlclose(void *handle) { _rtld_error(sorry); return -1; } -__weak_reference(_libc_dlerror, dlerror); - +#pragma weak dlerror const char * -_libc_dlerror(void) +dlerror(void) { return sorry; } -__weak_reference(_libc_dllockinit, dllockinit); - +#pragma weak dllockinit void -_libc_dllockinit(void *context, +dllockinit(void *context, void *(*lock_create)(void *context), void (*rlock_acquire)(void *lock), void (*wlock_acquire)(void *lock), @@ -95,80 +89,71 @@ _libc_dllockinit(void *context, context_destroy(context); } -__weak_reference(_libc_dlopen, dlopen); - +#pragma weak dlopen void * -_libc_dlopen(const char *name, int mode) +dlopen(const char *name, int mode) { _rtld_error(sorry); return NULL; } -__weak_reference(_libc_dlsym, dlsym); - +#pragma weak dlsym void * -_libc_dlsym(void * __restrict handle, const char * __restrict name) +dlsym(void * __restrict handle, const char * __restrict name) { _rtld_error(sorry); return NULL; } -__weak_reference(_libc_dlfunc, dlfunc); - +#pragma weak dlfunc dlfunc_t -_libc_dlfunc(void * __restrict handle, const char * __restrict name) +dlfunc(void * __restrict handle, const char * __restrict name) { _rtld_error(sorry); return NULL; } -__weak_reference(_libc_dlvsym, dlvsym); - +#pragma weak dlvsym void * -_libc_dlvsym(void * __restrict handle, const char * __restrict name, +dlvsym(void * __restrict handle, const char * __restrict name, const char * __restrict version) { _rtld_error(sorry); return NULL; } -__weak_reference(_libc_dlinfo, dlinfo); - +#pragma weak dlinfo int -_libc_dlinfo(void * __restrict handle, int request, void * __restrict p) +dlinfo(void * __restrict handle, int request, void * __restrict p) { _rtld_error(sorry); return 0; } -__weak_reference(_libc_rtld_thread_init, _rtld_thread_init); - +#pragma weak _rtld_thread_init void -_libc_rtld_thread_init(void * li) +_rtld_thread_init(void * li) { _rtld_error(sorry); } -__weak_reference(_libc_dl_iterate_phdr, dl_iterate_phdr); - +#pragma weak dl_iterate_phdr int -_libc_dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), +dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), void *data) { _rtld_error(sorry); return 0; } -__weak_reference(_libc_rtld_atfork_pre, _rtld_atfork_pre); - +#pragma weak _rtld_atfork_pre void -_libc_rtld_atfork_pre(int *locks) +_rtld_atfork_pre(int *locks) { } -__weak_reference(_libc_rtld_atfork_post, _rtld_atfork_post); - +#pragma weak _rtld_atfork_post void -_libc_rtld_atfork_post(int *locks) +_rtld_atfork_post(int *locks) { } From owner-svn-src-projects@FreeBSD.ORG Mon Feb 8 15:39:49 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55C111065697; Mon, 8 Feb 2010 15:39:49 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4556C8FC13; Mon, 8 Feb 2010 15:39:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o18FdnPm084531; Mon, 8 Feb 2010 15:39:49 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o18FdnNi084527; Mon, 8 Feb 2010 15:39:49 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002081539.o18FdnNi084527@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 8 Feb 2010 15:39:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203664 - in projects/ppc64: contrib/gdb/gdb gnu/usr.bin/binutils/libbfd X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2010 15:39:49 -0000 Author: nwhitehorn Date: Mon Feb 8 15:39:48 2010 New Revision: 203664 URL: http://svn.freebsd.org/changeset/base/203664 Log: Add the rs6000 architecture to binutils and fiddle some target definitions in the GDB tdep. GDB can now successfully debug core files on ppc64, but cannot yet attach to running processes, with this error: warning: Unable to find dynamic linker breakpoint function. Next up is fixing this and making ld believe that our CRT files can handle multiple TOCs, required for linking some large executables like LLVM. Modified: projects/ppc64/contrib/gdb/gdb/ppcfbsd-tdep.c projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 Modified: projects/ppc64/contrib/gdb/gdb/ppcfbsd-tdep.c ============================================================================== --- projects/ppc64/contrib/gdb/gdb/ppcfbsd-tdep.c Mon Feb 8 14:09:07 2010 (r203663) +++ projects/ppc64/contrib/gdb/gdb/ppcfbsd-tdep.c Mon Feb 8 15:39:48 2010 (r203664) @@ -35,13 +35,13 @@ #include "gdb_assert.h" #include "solib-svr4.h" -#define REG_FIXREG_OFFSET(x) ((x) * 4) -#define REG_LR_OFFSET (32 * 4) -#define REG_CR_OFFSET (33 * 4) -#define REG_XER_OFFSET (34 * 4) -#define REG_CTR_OFFSET (35 * 4) -#define REG_PC_OFFSET (36 * 4) -#define SIZEOF_STRUCT_REG (37 * 4) +#define REG_FIXREG_OFFSET(x) ((x) * sizeof(register_t)) +#define REG_LR_OFFSET (32 * sizeof(register_t)) +#define REG_CR_OFFSET (33 * sizeof(register_t)) +#define REG_XER_OFFSET (34 * sizeof(register_t)) +#define REG_CTR_OFFSET (35 * sizeof(register_t)) +#define REG_PC_OFFSET (36 * sizeof(register_t)) +#define SIZEOF_STRUCT_REG (37 * sizeof(register_t)) #define FPREG_FPR_OFFSET(x) ((x) * 8) #define FPREG_FPSCR_OFFSET (32 * 8) @@ -274,8 +274,13 @@ ppcfbsd_init_abi (struct gdbarch_info in /* For NetBSD, this is an on again, off again thing. Some systems do use the broken struct convention, and some don't. */ set_gdbarch_return_value (gdbarch, ppcfbsd_return_value); +#ifdef __powerpc64__ + set_solib_svr4_fetch_link_map_offsets (gdbarch, + svr4_lp64_fetch_link_map_offsets); +#else set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); +#endif } void Modified: projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile ============================================================================== --- projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile Mon Feb 8 14:09:07 2010 (r203663) +++ projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile Mon Feb 8 15:39:48 2010 (r203664) @@ -26,7 +26,7 @@ SELARCH= &bfd_i386_arch .elif ${TARGET_ARCH} == "sparc64" SELARCH= &bfd_sparc_arch .elif ${TARGET_ARCH} == "powerpc64" -SELARCH= &bfd_powerpc_arch +SELARCH= &bfd_powerpc_arch,&bfd_rs6000_arch .else .for _a in ${ARCHS} .if ${SELARCH} == "" Modified: projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 ============================================================================== --- projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 Mon Feb 8 14:09:07 2010 (r203663) +++ projects/ppc64/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 Mon Feb 8 15:39:48 2010 (r203664) @@ -22,4 +22,6 @@ SRCS+= cpu-powerpc.c \ VECS+= ${DEFAULT_VECTOR} \ bfd_elf64_powerpcle_vec \ bfd_elf32_powerpc_vec \ - bfd_elf32_powerpcle_vec + bfd_elf32_powerpcle_vec \ + ppcboot_vec + From owner-svn-src-projects@FreeBSD.ORG Tue Feb 9 17:29:05 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71A06106568D; Tue, 9 Feb 2010 17:29:05 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5EEC68FC18; Tue, 9 Feb 2010 17:29:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o19HT5QL033223; Tue, 9 Feb 2010 17:29:05 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o19HT5C4033212; Tue, 9 Feb 2010 17:29:05 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002091729.o19HT5C4033212@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 9 Feb 2010 17:29:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203709 - in projects/ppc64: contrib/gcc/config/rs6000 gnu/usr.bin/cc gnu/usr.bin/gdb lib/csu/powerpc64 lib/libc/powerpc64/sys rescue/rescue usr.sbin/named X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2010 17:29:05 -0000 Author: nwhitehorn Date: Tue Feb 9 17:29:04 2010 New Revision: 203709 URL: http://svn.freebsd.org/changeset/base/203709 Log: Modify CRT generation such that the linker can automatically split up large executables into multiple TOC sections and modify libc to be able to handle this. This eliminates the need for the -mminimal-toc hacks in large programs like gcc and named. Discussed with: Alan Modra Modified: projects/ppc64/contrib/gcc/config/rs6000/freebsd.h projects/ppc64/gnu/usr.bin/cc/Makefile.tgt projects/ppc64/gnu/usr.bin/gdb/Makefile.inc projects/ppc64/lib/csu/powerpc64/crti.S projects/ppc64/lib/csu/powerpc64/crtn.S projects/ppc64/lib/libc/powerpc64/sys/brk.S projects/ppc64/lib/libc/powerpc64/sys/sbrk.S projects/ppc64/lib/libc/powerpc64/sys/setlogin.S projects/ppc64/rescue/rescue/Makefile projects/ppc64/usr.sbin/named/Makefile Modified: projects/ppc64/contrib/gcc/config/rs6000/freebsd.h ============================================================================== --- projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Tue Feb 9 17:29:04 2010 (r203709) @@ -151,3 +151,16 @@ /* Override rs6000.h definition. */ #undef ASM_APP_OFF #define ASM_APP_OFF "#NO_APP\n" + +/* _init and _fini functions are built from bits spread across many + object files, each potentially with a different TOC pointer. For + that reason, place a nop after the call so that the linker can + restore the TOC pointer if a TOC adjusting call stub is needed. */ +#ifdef __powerpc64__ +#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ + asm (SECTION_OP "\n" \ +" bl ." #FUNC "\n" \ +" nop\n" \ +" .previous"); +#endif + Modified: projects/ppc64/gnu/usr.bin/cc/Makefile.tgt ============================================================================== --- projects/ppc64/gnu/usr.bin/cc/Makefile.tgt Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/gnu/usr.bin/cc/Makefile.tgt Tue Feb 9 17:29:04 2010 (r203709) @@ -22,6 +22,3 @@ TARGET_CPU_DEFAULT= TARGET_CPU_ultraspar TARGET_CPU_DEFAULT= \"powerpc64\" .endif -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -mminimal-toc -.endif Modified: projects/ppc64/gnu/usr.bin/gdb/Makefile.inc ============================================================================== --- projects/ppc64/gnu/usr.bin/gdb/Makefile.inc Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/gnu/usr.bin/gdb/Makefile.inc Tue Feb 9 17:29:04 2010 (r203709) @@ -38,10 +38,6 @@ CFLAGS+= -I${CNTRB_GDB}/include CFLAGS+= -I${CNTRB_BU}/include CFLAGS+= -I${CNTRB_BU}/bfd -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -mminimal-toc -.endif - GENSRCS+= nm.h tm.h .if defined(GDB_CROSS_DEBUGGER) Modified: projects/ppc64/lib/csu/powerpc64/crti.S ============================================================================== --- projects/ppc64/lib/csu/powerpc64/crti.S Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/lib/csu/powerpc64/crti.S Tue Feb 9 17:29:04 2010 (r203709) @@ -38,10 +38,7 @@ _init: ._init: stdu 1,-48(1) mflr 0 - std 31,40(1) std 0,64(1) - mr 31,1 - .section .fini,"ax",@progbits .align 2 @@ -58,10 +55,7 @@ _fini: ._fini: stdu 1,-48(1) mflr 0 - std 31,40(1) std 0,64(1) - mr 31,1 - .section .rodata .ascii "$FreeBSD: projects/ppc64/lib/csu/powerpc/crti.S 96632 2002-05-15 04:19:49Z obrien $\0" Modified: projects/ppc64/lib/csu/powerpc64/crtn.S ============================================================================== --- projects/ppc64/lib/csu/powerpc64/crtn.S Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/lib/csu/powerpc64/crtn.S Tue Feb 9 17:29:04 2010 (r203709) @@ -24,20 +24,16 @@ */ .section .init,"ax",@progbits - ld 11,0(1) - ld 0,16(11) + ld %r1,0(%r1) + ld 0,16(%r1) mtlr 0 - ld 31,-8(11) - mr 1,11 blr .section .fini,"ax",@progbits - ld 11,0(1) - ld 0,16(11) + ld %r1,0(%r1) + ld 0,16(%r1) mtlr 0 - ld 31,-8(11) - mr 1,11 blr Modified: projects/ppc64/lib/libc/powerpc64/sys/brk.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/sys/brk.S Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/lib/libc/powerpc64/sys/brk.S Tue Feb 9 17:29:04 2010 (r203709) @@ -41,7 +41,8 @@ HIDENAME(minbrk): .text ENTRY(brk) - ld %r5,HIDENAME(minbrk)@got(%r2) + addis %r5,%r2,HIDENAME(minbrk)@toc@ha + ld %r5,HIDENAME(minbrk)@toc@l(%r5) ld %r6,0(%r5) cmpld %r6,%r3 /* if (minbrk <= r3) */ bgt 0f @@ -51,8 +52,12 @@ ENTRY(brk) li %r0,SYS_break sc /* assume, that r5 is kept */ bso 1f - ld %r7,HIDENAME(curbrk)@got(%r2) /* record new break */ + + /* record new break */ + addis %r7,%r2,HIDENAME(curbrk)@toc@ha + ld %r7,HIDENAME(curbrk)@toc@l(%r7) std %r6,0(%r7) + blr /* return 0 */ 1: Modified: projects/ppc64/lib/libc/powerpc64/sys/sbrk.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/sys/sbrk.S Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/lib/libc/powerpc64/sys/sbrk.S Tue Feb 9 17:29:04 2010 (r203709) @@ -39,7 +39,8 @@ HIDENAME(curbrk): .text ENTRY(sbrk) - ld %r5,HIDENAME(curbrk)@got(%r2) + addis %r5,%r2,HIDENAME(curbrk)@toc@ha + ld %r5,HIDENAME(curbrk)@toc@l(%r5) ld %r6,0(%r5) /* r6 = old break */ cmpdi %r3,0 /* sbrk(0) - return curbrk */ beq 1f Modified: projects/ppc64/lib/libc/powerpc64/sys/setlogin.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/sys/setlogin.S Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/lib/libc/powerpc64/sys/setlogin.S Tue Feb 9 17:29:04 2010 (r203709) @@ -33,7 +33,8 @@ __FBSDID("$FreeBSD$"); .globl CNAME(_logname_valid) /* in _getlogin() */ SYSCALL(setlogin) - ld %r4,CNAME(_logname_valid)@got(%r2) + addis %r4,%r2,CNAME(_logname_valid)@toc@ha + ld %r4,CNAME(_logname_valid)@toc@l(%r4) li %r5,%r0 std %r5,0(%r4) blr Modified: projects/ppc64/rescue/rescue/Makefile ============================================================================== --- projects/ppc64/rescue/rescue/Makefile Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/rescue/rescue/Makefile Tue Feb 9 17:29:04 2010 (r203709) @@ -47,11 +47,7 @@ CLEANFILES+= dhclient_FIXED # Define Makefile variable RESCUE CRUNCH_BUILDOPTS+= -DRESCUE # Define compile-time RESCUE symbol when compiling components -.if ${MACHINE_ARCH} == powerpc64 -CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=\"-DRESCUE -mminimal-toc\" -.else CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE -.endif # An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk # rather than incorporating rescue-specific logic into standard files. Modified: projects/ppc64/usr.sbin/named/Makefile ============================================================================== --- projects/ppc64/usr.sbin/named/Makefile Tue Feb 9 17:20:00 2010 (r203708) +++ projects/ppc64/usr.sbin/named/Makefile Tue Feb 9 17:29:04 2010 (r203709) @@ -48,10 +48,6 @@ CFLAGS+= -DCONFIGARGS="\"${CONFIGARGS}\" CFLAGS+= -I${SRCDIR}/unix/include -I${SRCDIR}/include -I${LIB_BIND_DIR} CFLAGS+= -I${BIND_DIR}/lib/isc/${ISC_ATOMIC_ARCH}/include -.if ${MACHINE_ARCH} == powerpc64 -CFLAGS+= -mminimal-toc -.endif - # Remove the date stamp to make it more obvious when real changes happen CFLAGS+= -U__DATE__ From owner-svn-src-projects@FreeBSD.ORG Tue Feb 9 18:34:43 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31ED21065670; Tue, 9 Feb 2010 18:34:43 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0843E8FC0A; Tue, 9 Feb 2010 18:34:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o19IYgAi047740; Tue, 9 Feb 2010 18:34:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o19IYguI047736; Tue, 9 Feb 2010 18:34:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002091834.o19IYguI047736@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 9 Feb 2010 18:34:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203712 - projects/ppc64/lib/libc/powerpc64/sys X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2010 18:34:43 -0000 Author: nwhitehorn Date: Tue Feb 9 18:34:42 2010 New Revision: 203712 URL: http://svn.freebsd.org/changeset/base/203712 Log: @toc has different semantics than @got Modified: projects/ppc64/lib/libc/powerpc64/sys/brk.S projects/ppc64/lib/libc/powerpc64/sys/sbrk.S projects/ppc64/lib/libc/powerpc64/sys/setlogin.S Modified: projects/ppc64/lib/libc/powerpc64/sys/brk.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/sys/brk.S Tue Feb 9 18:22:26 2010 (r203711) +++ projects/ppc64/lib/libc/powerpc64/sys/brk.S Tue Feb 9 18:34:42 2010 (r203712) @@ -41,9 +41,8 @@ HIDENAME(minbrk): .text ENTRY(brk) - addis %r5,%r2,HIDENAME(minbrk)@toc@ha - ld %r5,HIDENAME(minbrk)@toc@l(%r5) - ld %r6,0(%r5) + addis %r6,%r2,HIDENAME(minbrk)@toc@ha + ld %r6,HIDENAME(minbrk)@toc@l(%r6) cmpld %r6,%r3 /* if (minbrk <= r3) */ bgt 0f mr %r6,%r3 /* r6 = r3 */ @@ -55,8 +54,7 @@ ENTRY(brk) /* record new break */ addis %r7,%r2,HIDENAME(curbrk)@toc@ha - ld %r7,HIDENAME(curbrk)@toc@l(%r7) - std %r6,0(%r7) + std %r6,HIDENAME(curbrk)@toc@l(%r7) blr /* return 0 */ Modified: projects/ppc64/lib/libc/powerpc64/sys/sbrk.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/sys/sbrk.S Tue Feb 9 18:22:26 2010 (r203711) +++ projects/ppc64/lib/libc/powerpc64/sys/sbrk.S Tue Feb 9 18:34:42 2010 (r203712) @@ -40,7 +40,7 @@ HIDENAME(curbrk): .text ENTRY(sbrk) addis %r5,%r2,HIDENAME(curbrk)@toc@ha - ld %r5,HIDENAME(curbrk)@toc@l(%r5) + addi %r5,%r5,HIDENAME(curbrk)@toc@l ld %r6,0(%r5) /* r6 = old break */ cmpdi %r3,0 /* sbrk(0) - return curbrk */ beq 1f Modified: projects/ppc64/lib/libc/powerpc64/sys/setlogin.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/sys/setlogin.S Tue Feb 9 18:22:26 2010 (r203711) +++ projects/ppc64/lib/libc/powerpc64/sys/setlogin.S Tue Feb 9 18:34:42 2010 (r203712) @@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$"); SYSCALL(setlogin) addis %r4,%r2,CNAME(_logname_valid)@toc@ha - ld %r4,CNAME(_logname_valid)@toc@l(%r4) - li %r5,%r0 - std %r5,0(%r4) + li %r5,0 + stw %r5,CNAME(_logname_valid)@toc@l(%r4) blr From owner-svn-src-projects@FreeBSD.ORG Tue Feb 9 20:18:14 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85D821065672; Tue, 9 Feb 2010 20:18:14 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73D318FC17; Tue, 9 Feb 2010 20:18:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o19KIE8P070888; Tue, 9 Feb 2010 20:18:14 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o19KIE1T070885; Tue, 9 Feb 2010 20:18:14 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002092018.o19KIE1T070885@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 9 Feb 2010 20:18:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203720 - in projects/ppc64/sys: cddl/contrib/opensolaris/common/atomic/powerpc64 modules/opensolaris modules/zfs X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2010 20:18:14 -0000 Author: nwhitehorn Date: Tue Feb 9 20:18:14 2010 New Revision: 203720 URL: http://svn.freebsd.org/changeset/base/203720 Log: Provide 64-bit atomics for ZFS and OpenSolaris compat on PPC64. Added: projects/ppc64/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/ projects/ppc64/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S Modified: projects/ppc64/sys/modules/opensolaris/Makefile projects/ppc64/sys/modules/zfs/Makefile Added: projects/ppc64/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/ppc64/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S Tue Feb 9 20:18:14 2010 (r203720) @@ -0,0 +1,69 @@ +/*- + * Copyright (C) 2010 Nathan Whitehorn + * 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. + * + * 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 TOOLS GMBH 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. + */ + +#include + +ENTRY(atomic_add_64_nv) + 1: ldarx %r5,0,%r3 + add %r5,%r4,%r5 + stdcx. %r5,0,%r3 + bne- 1b + + mr %r3,%r5 + blr + +ENTRY(atomic_cas_64) + 1: ldarx %r6,0,%r3 + cmpld %r6,%r4 + bne 2f + stdcx. %r5,0,%r3 + bne- 1b + b 3f + + 2: stdcx. %r6,0,%r3 /* clear reservation */ + + 3: mr %r3,%r6 + blr + +ENTRY(atomic_or_8_nv) + rldicr %r6,%r3,61,2 /* r6 = r3 & ~4 */ + sub %r7,%r3,%r6 /* offset in r7 */ + sldi %r7,%r7,3 /* bits to shift in r7 */ + + rlwinm %r4,%r4,0,23,31 /* mask and rotate the argument */ + slw %r4,%r4,%r7 + + 1: lwarx %r5,0,%r6 + or %r5,%r4,%r5 + stwcx. %r5,0,%r3 + bne- 1b + + srw %r3,%r5,%r7 + rlwinm %r3,%r3,0,23,31 + blr + +ENTRY(membar_producer) + eieio + Modified: projects/ppc64/sys/modules/opensolaris/Makefile ============================================================================== --- projects/ppc64/sys/modules/opensolaris/Makefile Tue Feb 9 19:37:12 2010 (r203719) +++ projects/ppc64/sys/modules/opensolaris/Makefile Tue Feb 9 20:18:14 2010 (r203720) @@ -8,7 +8,7 @@ SRCS= opensolaris.c \ opensolaris_kmem.c \ opensolaris_misc.c -.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "sparc64" +.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} == "powerpc64" .PATH: ${.CURDIR}/../../cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH} SRCS+= opensolaris_atomic.S .else Modified: projects/ppc64/sys/modules/zfs/Makefile ============================================================================== --- projects/ppc64/sys/modules/zfs/Makefile Tue Feb 9 19:37:12 2010 (r203719) +++ projects/ppc64/sys/modules/zfs/Makefile Tue Feb 9 20:18:14 2010 (r203720) @@ -27,7 +27,7 @@ SRCS+= opensolaris_taskq.c SRCS+= opensolaris_vfs.c SRCS+= opensolaris_zone.c -.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "sparc64" +.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} == "powerpc64" .PATH: ${SUNW}/common/atomic/${MACHINE_ARCH} SRCS+= opensolaris_atomic.S .else From owner-svn-src-projects@FreeBSD.ORG Tue Feb 9 22:01:42 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8BCD1065672; Tue, 9 Feb 2010 22:01:42 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE1EA8FC12; Tue, 9 Feb 2010 22:01:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o19M1gUi094034; Tue, 9 Feb 2010 22:01:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o19M1giU094032; Tue, 9 Feb 2010 22:01:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002092201.o19M1giU094032@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 9 Feb 2010 22:01:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203725 - projects/ppc64/contrib/gcc/config/rs6000 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2010 22:01:43 -0000 Author: nwhitehorn Date: Tue Feb 9 22:01:42 2010 New Revision: 203725 URL: http://svn.freebsd.org/changeset/base/203725 Log: Some updates to our ABI definition, mostly related to exception handling. This makes C++ exceptions work properly. Modified: projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Modified: projects/ppc64/contrib/gcc/config/rs6000/freebsd.h ============================================================================== --- projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Tue Feb 9 21:31:53 2010 (r203724) +++ projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Tue Feb 9 22:01:42 2010 (r203725) @@ -23,7 +23,7 @@ #ifdef IN_LIBGCC2 #undef TARGET_64BIT -#ifdef __ppc64__ +#ifdef __powerpc64__ #define TARGET_64BIT 1 #else #define TARGET_64BIT 0 @@ -164,3 +164,43 @@ " .previous"); #endif +/* __throw will restore its own return address to be the same as the + return address of the function that the throw is being made to. + This is unfortunate, because we want to check the original + return address to see if we need to restore the TOC. + So we have to squirrel it away with this. */ +#define SETUP_FRAME_ADDRESSES() \ + do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0) + +/* Select a format to encode pointers in exception handling data. CODE + is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is + true if the symbol may be affected by dynamic relocations. */ +#undef ASM_PREFERRED_EH_DATA_FORMAT +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ + ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \ + ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \ + | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \ + : DW_EH_PE_absptr) + +#define MD_FROB_UPDATE_CONTEXT(CTX, FS) \ + if (TARGET_64BIT) { \ + if ((FS)->regs.reg[2].how == REG_UNSAVED) \ + { \ + unsigned int *insn \ + = (unsigned int *) \ + _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM); \ + if (*insn == 0xE8410028) \ + _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \ + } \ + } + +/* Indicate that jump tables go in the text section. */ +#undef JUMP_TABLES_IN_TEXT_SECTION +#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT + +/* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit + kernel. This is supported when running on a 64-bit kernel with + COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries + are compatible. */ +#define OS_MISSING_POWERPC64 !TARGET_64BIT + From owner-svn-src-projects@FreeBSD.ORG Tue Feb 9 22:41:00 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A300106566B; Tue, 9 Feb 2010 22:41:00 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8922A8FC08; Tue, 9 Feb 2010 22:41:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o19Mf0o0003080; Tue, 9 Feb 2010 22:41:00 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o19Mf0qw003078; Tue, 9 Feb 2010 22:41:00 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002092241.o19Mf0qw003078@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 9 Feb 2010 22:41:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203730 - projects/ppc64/contrib/gcc/config/rs6000 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2010 22:41:00 -0000 Author: nwhitehorn Date: Tue Feb 9 22:41:00 2010 New Revision: 203730 URL: http://svn.freebsd.org/changeset/base/203730 Log: We don't need executable jump tables for BSD, and having them makes ld crash in rare cases, so revert this part of the last change. Modified: projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Modified: projects/ppc64/contrib/gcc/config/rs6000/freebsd.h ============================================================================== --- projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Tue Feb 9 22:39:34 2010 (r203729) +++ projects/ppc64/contrib/gcc/config/rs6000/freebsd.h Tue Feb 9 22:41:00 2010 (r203730) @@ -194,10 +194,6 @@ } \ } -/* Indicate that jump tables go in the text section. */ -#undef JUMP_TABLES_IN_TEXT_SECTION -#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT - /* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit kernel. This is supported when running on a 64-bit kernel with COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries From owner-svn-src-projects@FreeBSD.ORG Wed Feb 10 15:12:37 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BD4F1065670; Wed, 10 Feb 2010 15:12:37 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EFE628FC17; Wed, 10 Feb 2010 15:12:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1AFCaOM024763; Wed, 10 Feb 2010 15:12:36 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1AFCapv024761; Wed, 10 Feb 2010 15:12:36 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002101512.o1AFCapv024761@svn.freebsd.org> From: Nathan Whitehorn Date: Wed, 10 Feb 2010 15:12:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203755 - projects/ppc64/sys/modules X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2010 15:12:37 -0000 Author: nwhitehorn Date: Wed Feb 10 15:12:36 2010 New Revision: 203755 URL: http://svn.freebsd.org/changeset/base/203755 Log: Add opensolaris and zfs modules to the build on powerpc64, and add tmpfs on both powerpc and powerpc64, since it works just fine. The tmpfs bit should be merged to HEAD soon. Committed from: a ppc64 system Modified: projects/ppc64/sys/modules/Makefile Modified: projects/ppc64/sys/modules/Makefile ============================================================================== --- projects/ppc64/sys/modules/Makefile Wed Feb 10 13:48:34 2010 (r203754) +++ projects/ppc64/sys/modules/Makefile Wed Feb 10 15:12:36 2010 (r203755) @@ -604,6 +604,16 @@ _cpufreq= cpufreq _nvram= powermac_nvram _smbfs= smbfs _sound= sound +_tmpfs= tmpfs +.endif + +.if ${MACHINE_ARCH} == "powerpc64" +.if ${MK_CDDL} != "no" || defined(ALL_MODULES) +_opensolaris= opensolaris +.endif +.if ${MK_ZFS} != "no" || defined(ALL_MODULES) +_zfs= zfs +.endif .endif .if ${MACHINE_ARCH} == "sparc64" From owner-svn-src-projects@FreeBSD.ORG Thu Feb 11 02:56:06 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C7811065672; Thu, 11 Feb 2010 02:56:06 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2C5F88FC19; Thu, 11 Feb 2010 02:56:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1B2u5G0046099; Thu, 11 Feb 2010 02:56:06 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1B2u5dK046093; Thu, 11 Feb 2010 02:56:05 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201002110256.o1B2u5dK046093@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 11 Feb 2010 02:56:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203766 - in projects/tcp_cc_head/sys: netinet vm X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2010 02:56:06 -0000 Author: lstewart Date: Thu Feb 11 02:56:05 2010 New Revision: 203766 URL: http://svn.freebsd.org/changeset/base/203766 Log: - Add public KPI functions to lookup a helper's ID based on its name and get a data block based on an ID. - Add a new skeleton UMA function to free all items currently allocated from a zone. Doesn't do anything yet but hope to figure out how to make it work at some point. - Lot's of other tweaks as well. Modified: projects/tcp_cc_head/sys/netinet/h_ertt.c projects/tcp_cc_head/sys/netinet/helper.c projects/tcp_cc_head/sys/netinet/helper.h projects/tcp_cc_head/sys/netinet/helper_module.h projects/tcp_cc_head/sys/vm/uma.h projects/tcp_cc_head/sys/vm/uma_core.c Modified: projects/tcp_cc_head/sys/netinet/h_ertt.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/h_ertt.c Wed Feb 10 20:35:20 2010 (r203765) +++ projects/tcp_cc_head/sys/netinet/h_ertt.c Thu Feb 11 02:56:05 2010 (r203766) @@ -74,9 +74,9 @@ void ertt_tcpest_hook(void *udata, void *ctx_data, void *dblock) { //struct ertt *e = (struct ertt *)(((struct tcpcb *)inp->inp_ppcb)->helper_data[0]); - struct ertt *e = (struct ertt *)dblock; - printf("In the hook with errt->test: %d, ctx_data: %p, curack = %u\n", - e->test, ctx_data, ((struct tcp_hhook_data *)ctx_data)->curack); + //struct ertt *e = (struct ertt *)dblock; + //printf("In the hook with errt->test: %d, ctx_data: %p, curack = %u\n", + //e->test, ctx_data, ((struct tcp_hhook_data *)ctx_data)->curack); } Modified: projects/tcp_cc_head/sys/netinet/helper.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/helper.c Wed Feb 10 20:35:20 2010 (r203765) +++ projects/tcp_cc_head/sys/netinet/helper.c Thu Feb 11 02:56:05 2010 (r203766) @@ -112,8 +112,8 @@ destroy_helper_dblocks(struct helper_dbl HELPER_LIST_WLOCK(); for (nblocks--; nblocks >= 0; nblocks--) { - h = get_helper(dblocks[nblocks].id); - uma_zfree(h->zone, dblocks[nblocks].block); + if ((h = get_helper(dblocks[nblocks].id)) != NULL) + uma_zfree(h->zone, dblocks[nblocks].block); } HELPER_LIST_WUNLOCK(); @@ -156,6 +156,33 @@ deregister_helper(struct helper *h) return (0); } +int +get_helper_id(char *hname) +{ + struct helper *h; + int id = -1; + + HELPER_LIST_RLOCK(); + STAILQ_FOREACH(h, &helpers, h_next) { + if (strncmp(h->name, hname, HELPER_NAME_MAXLEN) == 0) { + id = h->id; + break; + } + } + HELPER_LIST_RUNLOCK(); + return (id); +} + +void * +get_helper_dblock(struct helper_dblock *dblocks, int nblocks, int id) +{ + for (nblocks--; nblocks >= 0; nblocks--) { + if (dblocks[nblocks].id == id) + return (dblocks[nblocks].block); + } + return (NULL); +} + /* * Private KPI functions. */ @@ -198,6 +225,8 @@ helper_modevent(module_t mod, int event_ break; } } + strlcpy(hmd->helper->name, hmd->name, + HELPER_NAME_MAXLEN); if (hmd->helper->mod_init != NULL) error = hmd->helper->mod_init(); if (!error) @@ -206,6 +235,7 @@ helper_modevent(module_t mod, int event_ case MOD_QUIESCE: error = deregister_helper(hmd->helper); + uma_zfree_all(hmd->helper->zone); uma_zdestroy(hmd->helper->zone); if (!error && hmd->helper->mod_destroy != NULL) hmd->helper->mod_destroy(); Modified: projects/tcp_cc_head/sys/netinet/helper.h ============================================================================== --- projects/tcp_cc_head/sys/netinet/helper.h Wed Feb 10 20:35:20 2010 (r203765) +++ projects/tcp_cc_head/sys/netinet/helper.h Thu Feb 11 02:56:05 2010 (r203766) @@ -41,7 +41,9 @@ struct helper_dblock { void *block; }; +#define HELPER_NAME_MAXLEN 16 struct helper { + char name[HELPER_NAME_MAXLEN]; /* Init global module state on kldload. */ int (*mod_init) (void); @@ -68,11 +70,12 @@ struct helper { #define HELPER_CLASS_TCP 0x00000001 int init_helper_dblocks(struct helper_dblock **dblocks, int *nblocks); -int destroy_helper_dblocks(struct helper_dblock *array_head, int nblocks); +int destroy_helper_dblocks(struct helper_dblock *dblocks, int nblocks); int register_helper(struct helper *h); int deregister_helper(struct helper *h); -/*struct helper_dblock * get_helper_dblock(struct helper_dblock *array_head, int -id);*/ +int get_helper_id(char *hname); +void * get_helper_dblock(struct helper_dblock *dblocks, + int nblocks, int id); #define HELPER_LIST_WLOCK() rw_wlock(&helper_list_lock) #define HELPER_LIST_WUNLOCK() rw_wunlock(&helper_list_lock) Modified: projects/tcp_cc_head/sys/netinet/helper_module.h ============================================================================== --- projects/tcp_cc_head/sys/netinet/helper_module.h Wed Feb 10 20:35:20 2010 (r203765) +++ projects/tcp_cc_head/sys/netinet/helper_module.h Thu Feb 11 02:56:05 2010 (r203766) @@ -34,7 +34,7 @@ #define _NETINET_HELPER_MODULE_H_ struct helper_modevent_data { - char *name; + char name[HELPER_NAME_MAXLEN]; struct helper *helper; int uma_zsize; uma_ctor umactor; Modified: projects/tcp_cc_head/sys/vm/uma.h ============================================================================== --- projects/tcp_cc_head/sys/vm/uma.h Wed Feb 10 20:35:20 2010 (r203765) +++ projects/tcp_cc_head/sys/vm/uma.h Thu Feb 11 02:56:05 2010 (r203766) @@ -306,6 +306,14 @@ uma_zalloc(uma_zone_t zone, int flags) } /* + * Frees all items currently allocated back into the specified zone. + * + * Arguments: + * zone The zone free all currently allocated items from. + */ +void uma_zfree_all(uma_zone_t zone); + +/* * Frees an item back into the specified zone. * * Arguments: Modified: projects/tcp_cc_head/sys/vm/uma_core.c ============================================================================== --- projects/tcp_cc_head/sys/vm/uma_core.c Wed Feb 10 20:35:20 2010 (r203765) +++ projects/tcp_cc_head/sys/vm/uma_core.c Thu Feb 11 02:56:05 2010 (r203766) @@ -2315,6 +2315,9 @@ slab_alloc_item(uma_zone_t zone, uma_sla } item = slab->us_data + (keg->uk_rsize * freei); + //printf("slab_alloc_item() slab %p us_freecount: %d\n", slab, + //slab->us_freecount); + slab->us_freecount--; keg->uk_free--; #ifdef INVARIANTS @@ -2676,6 +2679,36 @@ zfree_internal: return; } +void +uma_zfree_all(uma_zone_t zone) +{ + uma_klink_t kl; + uma_slab_t slab; + + printf("zone->uz_count: %d\n", zone->uz_count); + + ZONE_LOCK(zone); + LIST_FOREACH(kl, &zone->uz_kegs, kl_link) { + printf("keg %s (%p) uk_free: %d\n", kl->kl_keg->uk_name, + kl->kl_keg, kl->kl_keg->uk_free); + + LIST_FOREACH(slab, &kl->kl_keg->uk_part_slab, us_link) { + printf("partially full slab %p us_freecount: %d, firstfree: %d\n", + slab, slab->us_freecount, slab->us_firstfree); + + } + LIST_FOREACH(slab, &kl->kl_keg->uk_full_slab, us_link) { + printf("full slab %p us_freecount: %d\n", + slab, slab->us_freecount); + } + LIST_FOREACH(slab, &kl->kl_keg->uk_free_slab, us_link) { + printf("free slab %p us_freecount: %d\n", + slab, slab->us_freecount); + } + } + ZONE_UNLOCK(zone); +} + /* * Frees an item to an INTERNAL zone or allocates a free bucket * From owner-svn-src-projects@FreeBSD.ORG Thu Feb 11 07:00:21 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DF911065670; Thu, 11 Feb 2010 07:00:21 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5BECE8FC08; Thu, 11 Feb 2010 07:00:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1B70Lvr099946; Thu, 11 Feb 2010 07:00:21 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1B70Lrw099941; Thu, 11 Feb 2010 07:00:21 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201002110700.o1B70Lrw099941@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 11 Feb 2010 07:00:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203771 - projects/tcp_cc_head/sys/netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2010 07:00:21 -0000 Author: lstewart Date: Thu Feb 11 07:00:21 2010 New Revision: 203771 URL: http://svn.freebsd.org/changeset/base/203771 Log: - Import David's integrated ertt helper. - Add a version number to helpers so they can be depended on in a sensible way. Added: projects/tcp_cc_head/sys/netinet/h_ertt.h (contents, props changed) Modified: projects/tcp_cc_head/sys/netinet/h_ertt.c projects/tcp_cc_head/sys/netinet/helper_module.h projects/tcp_cc_head/sys/netinet/tcp_var.h Modified: projects/tcp_cc_head/sys/netinet/h_ertt.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/h_ertt.c Thu Feb 11 06:42:08 2010 (r203770) +++ projects/tcp_cc_head/sys/netinet/h_ertt.c Thu Feb 11 07:00:21 2010 (r203771) @@ -43,25 +43,53 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include #include #include #include #include +#include #include -void ertt_tcpest_hook(void *udata, void *ctx_data, void *dblock); +#include + +static VNET_DEFINE(uma_zone_t, txseginfo_zone); +#define V_txseginfo_zone VNET(txseginfo_zone) + +#define DLYACK_SMOOTH 5 /* smoothing factor for delayed ack guess */ +#define MAX_TS_ERR 10 /* maximum number of time stamp errors allowed in a session */ + +void ertt_packet_measurement_hook(void *udata, void *ctx_data, void *dblock); +void ertt_add_tx_segment_info_hook(void *udata, void *ctx_data, void *dblock); int ertt_mod_init(void); int ertt_mod_destroy(void); int ertt_uma_ctor(void *mem, int size, void *arg, int flags); void ertt_uma_dtor(void *mem, int size, void *arg); -struct ertt { - int test; +/* Structure contains the information about the + sent segment, for comparison with the corresponding ack */ +struct txseginfo { + TAILQ_ENTRY(txseginfo) txsegi_lnk; + /* segment sequence number */ + tcp_seq seq; + long len; + /* time stamp indicating when the packet was sent */ + u_int32_t tx_ts; + /* Last received receiver ts (if the tcp option is used). */ + u_int32_t rx_ts; + /* flags for operation */ + u_int flags; }; +/* txseginfo flags */ +#define TXSI_TSO 0x01 /* TSO was used for this entry */ +#define TXSI_RTT_MEASURE_START 0x02 /* a rate measure starts here based on this txsi's rtt */ +#define TXSI_RX_MEASURE_END 0x04 /* measure the received rate until this txsi */ + struct helper ertt_helper = { .mod_init = ertt_mod_init, .mod_destroy = ertt_mod_destroy, @@ -69,37 +97,267 @@ struct helper ertt_helper = { .class = HELPER_CLASS_TCP }; +#define MULTI_ACK 1 + static void inline +marked_packet_rtt(struct txseginfo *txsi, struct ertt *e_t, struct tcpcb *tp, struct tcphdr *th, + u_int32_t *pmeasurenext, int multiack) +{ + /* if we can't measure this one properly due to delayed acking */ + /* adjust byte counters and flag to measure next txsi. */ + /* Note that since the marked packet's tx and rx bytes are measured */ + /* we need to subtract the tx, and not add the rx. */ + /* Then pretend the next txsi was marked */ + if (multiack && e_t->dlyack_rx && !*pmeasurenext) { + *pmeasurenext=txsi->tx_ts; + } else { + if (*pmeasurenext) + e_t->markedpkt_rtt = ticks - *pmeasurenext + 1; + else + e_t->markedpkt_rtt = ticks - txsi->tx_ts + 1; + e_t->bytes_tx_in_marked_rtt=e_t->bytes_tx_in_rtt; + e_t->marked_snd_cwnd=tp->snd_cwnd; + + /* set flags */ + e_t->flags &= ~ERTT_MEASUREMENT_IN_PROGRESS; /* Not measuring - indicates to add_tx_segment_info + a new measurment needs to be started */ + e_t->flags |= ERTT_NEW_MEASUREMENT; /* indicates to the CC that a new marked RTT measurement has been taken */ + if (tp->t_flags & TF_TSO) { + tp->t_flags &= ~TF_TSO; /* temporarily disable TSO to aid in a new measurment */ + e_t->flags |= ERTT_TSO_DISABLED; /* note that I've done it so I can renable it later */ + } + } +} -void -ertt_tcpest_hook(void *udata, void *ctx_data, void *dblock) + + +/* packet_measurements use state kept on each packet sent to more accurately and more + * securely measure the round trip time. The resulting measurement is used for + * congestion control algorithms which require a more accurate time. +*/ + void +ertt_packet_measurement_hook(void *udata, void *ctx_data, void *dblock) { //struct ertt *e = (struct ertt *)(((struct tcpcb *)inp->inp_ppcb)->helper_data[0]); - //struct ertt *e = (struct ertt *)dblock; - //printf("In the hook with errt->test: %d, ctx_data: %p, curack = %u\n", - //e->test, ctx_data, ((struct tcp_hhook_data *)ctx_data)->curack); + struct tcpcb *tp = ((struct tcp_hhook_data *)ctx_data)->tp; + struct tcphdr *th = ((struct tcp_hhook_data *)ctx_data)->th; + struct tcpopt *to = ((struct tcp_hhook_data *)ctx_data)->to; + int new_sacked_bytes = ((struct tcp_hhook_data *)ctx_data)->new_sacked_bytes; + struct ertt *e_t = (struct ertt *)dblock; + + printf("In the hook with e_t->rtt: %d, ctx_data: %p, curack = %u\n", + e_t->rtt, ctx_data, th->th_ack); + + struct txseginfo *txsi; + u_int32_t rts=0; + u_int32_t measurenext=0; + tcp_seq ack; + int multiack=0; + + + INP_WLOCK_ASSERT(tp->t_inpcb); + int acked = th->th_ack - tp->snd_una; + /* Packet has provided new acknowledgements */ + if (acked > 0 || new_sacked_bytes) { + if (acked == 0 && new_sacked_bytes) { + /* no delayed acks at the moment, + use packets being acknowledged with sack instead of th_ack*/ + ack = tp->sackhint.last_sack_ack; + } else + ack = th->th_ack; + + + txsi = TAILQ_FIRST(&e_t->txsegi_q); + while(txsi != NULL) { + rts = 0; + + + if (SEQ_GT(ack, txsi->seq+txsi->len)) { /* acking more than this txsi */ + if (txsi->flags & TXSI_RTT_MEASURE_START || measurenext) + marked_packet_rtt(txsi, e_t, tp, th, &measurenext, MULTI_ACK); + TAILQ_REMOVE(&e_t->txsegi_q, txsi, txsegi_lnk); + uma_zfree(V_txseginfo_zone, txsi); + txsi = TAILQ_FIRST(&e_t->txsegi_q); + continue; + } + + + /* Guess if delayed acks are being used by the receiver */ + if (!new_sacked_bytes) { + if (acked > tp->t_maxseg) { + e_t->dlyack_rx += (e_t->dlyack_rx < DLYACK_SMOOTH) ? 1 : 0; + multiack=1; + } else if (acked > txsi->len) { + multiack=1; + e_t->dlyack_rx += (e_t->dlyack_rx < DLYACK_SMOOTH) ? 1 : 0; + } else if (acked == tp->t_maxseg || acked == txsi->len) + e_t->dlyack_rx -= (e_t->dlyack_rx > 0) ? 1 : 0; + /* otherwise leave dlyack_rx the way it was */ + } + + /* Time stamps are only used to help identify packets */ + if (e_t->timestamp_errors < MAX_TS_ERR && + (to->to_flags & TOF_TS) != 0 && to->to_tsecr) { + /* Note: All packets sent with the offload will have the same time stamp. + If we are sending on a fast interface, and the t_maxseg is much + smaller than one tick, this will be fine. The time stamp would be + the same whether we were using tso or not. However, if the interface + is slow, this will cause problems with the calculations. If the interface + is slow, there is not reason to be using tso, and it should be turned off. */ + /* If there are too many time stamp errors, time stamps won't be trusted */ + rts = to->to_tsecr; + if (!e_t->dlyack_rx && TSTMP_LT(rts,txsi->tx_ts)) /*before this packet */ + /* When delayed acking is used, the reflected time stamp + is of the first packet, and thus may be before txsi->tx_ts*/ + break; + if (TSTMP_GT(rts,txsi->tx_ts)) { + /* if reflected time stamp is later than tx_tsi, then this txsi is old */ + if (txsi->flags & TXSI_RTT_MEASURE_START || measurenext) + marked_packet_rtt(txsi, e_t, tp, th, &measurenext, 0); + TAILQ_REMOVE(&e_t->txsegi_q, txsi, txsegi_lnk); + uma_zfree(V_txseginfo_zone, txsi); + txsi = TAILQ_FIRST(&e_t->txsegi_q); + continue; + } + if (rts == txsi->tx_ts && TSTMP_LT(to->to_tsval,txsi->rx_ts)) { + /* rx before sent!!! something wrong with rx timestamping + process without timestamps */ + e_t->timestamp_errors++; + } + } + + /* old txsi that may have had the same seq numbers (rtx) should have been + removed if time stamps are being used */ + if (SEQ_LEQ(ack,txsi->seq)) + break; /* before first packet in txsi */ + + /* only ack > txsi->seq and ack <= txsi->seq+txsi->len past this point */ + + + if (!e_t->dlyack_rx || multiack || new_sacked_bytes) { + e_t->rtt = ticks - txsi->tx_ts + 1; /* new measurement */ + if (e_t->rtt < e_t->minrtt || e_t->minrtt==0) + e_t->minrtt=e_t->rtt; + } + + if (txsi->flags & TXSI_RTT_MEASURE_START || measurenext) + marked_packet_rtt(txsi, e_t, tp, th, &measurenext, 0); + + if (txsi->flags & TXSI_TSO) { + txsi->len -= acked; + if (txsi->len > 0) { + /* this presumes ack for first bytes in txsi, + this may not be true but it shouldn't + cause problems for the timing */ + txsi->seq += acked; + txsi->flags &= ~TXSI_RTT_MEASURE_START; /* reset measure flag */ + break; /* still more data to be acked with this tso transmission */ + } + } + TAILQ_REMOVE(&e_t->txsegi_q, txsi, txsegi_lnk); + uma_zfree(V_txseginfo_zone, txsi); + break; + } /* end while */ + if (measurenext) /* need to do a tx rate measurement, won't be the best if I'm doing it here */ + marked_packet_rtt(txsi, e_t, tp, th, &measurenext, 0); + } } +/* add transmitted segment info to the list */ +void +ertt_add_tx_segment_info_hook(void *udata, void *ctx_data, void *dblock) +{ + struct tcpcb *tp = ((struct tcp_hhook_data *)ctx_data)->tp; + struct tcphdr *th = ((struct tcp_hhook_data *)ctx_data)->th; + struct tcpopt *to = ((struct tcp_hhook_data *)ctx_data)->to; + long len = ((struct tcp_hhook_data *)ctx_data)->len; + int tso = ((struct tcp_hhook_data *)ctx_data)->tso; + + + INP_WLOCK_ASSERT(tp->t_inpcb); + + + if(len > 0) { + struct txseginfo *txsi; + txsi = (struct txseginfo *) uma_zalloc(V_txseginfo_zone, M_NOWAIT); + if (txsi != NULL) { + struct ertt *e_t= (struct ertt *)dblock; + txsi->flags=0; /* needs to be initialised */ + txsi->seq = ntohl(th->th_seq); + txsi->len = len; + if (tso) + txsi->flags |= TXSI_TSO; + else + if (e_t->flags & ERTT_TSO_DISABLED) { + tp->t_flags |= TF_TSO; + e_t->flags &= ~ERTT_TSO_DISABLED; + } + if (e_t->flags & ERTT_MEASUREMENT_IN_PROGRESS) { + e_t->bytes_tx_in_rtt += len; + } else { + txsi->flags |= TXSI_RTT_MEASURE_START; + e_t->flags |= ERTT_MEASUREMENT_IN_PROGRESS; + e_t->bytes_tx_in_rtt = len; + } + if (((tp->t_flags & TF_NOOPT) == 0) && (to->to_flags & TOF_TS)) { + txsi->tx_ts = ntohl(to->to_tsval) - tp->ts_offset; + txsi->rx_ts = ntohl(to->to_tsecr); + } else { + txsi->tx_ts = ticks; + txsi->rx_ts = 0; /* no received time stamp */ + } + TAILQ_INSERT_TAIL(&e_t->txsegi_q, txsi, txsegi_lnk); + } + printf("** A %u %ld %d\n", ntohl(th->th_seq), len, tso); + } +} int ertt_mod_init(void) { - return register_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED, - &ertt_helper, &ertt_tcpest_hook, NULL, HHOOK_WAITOK); + int ret; + + V_txseginfo_zone = uma_zcreate("txseginfo", sizeof(struct txseginfo), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + + ret = register_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_IN, + &ertt_helper, &ertt_packet_measurement_hook, NULL, HHOOK_WAITOK); + if (ret) + return (ret); + + return register_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_OUT, + &ertt_helper, & ertt_add_tx_segment_info_hook, NULL, HHOOK_WAITOK); } int ertt_mod_destroy(void) { - return deregister_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED, - &ertt_tcpest_hook, NULL, 0); + int ret; + ret = deregister_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_IN, + &ertt_packet_measurement_hook, NULL, 0); + ret += deregister_hhook(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_OUT, + &ertt_add_tx_segment_info_hook, NULL, 0); + + uma_zdestroy(V_txseginfo_zone); + + return (ret); } int ertt_uma_ctor(void *mem, int size, void *arg, int flags) { - printf("Creating ertt block %p\n", mem); + struct ertt *e_t = (struct ertt *)mem; + + TAILQ_INIT(&e_t->txsegi_q); + e_t->timestamp_errors=0; + e_t->minrtt = 0; + e_t->maxrtt = 0; + e_t->rtt = 0; + e_t->flags=0; + e_t->dlyack_rx = 0; + e_t->bytes_tx_in_rtt = 0; + e_t->markedpkt_rtt = 0; - ((struct ertt *)mem)->test = 5; + printf("Creating ertt block %p\n", mem); return (0); } @@ -107,7 +365,17 @@ ertt_uma_ctor(void *mem, int size, void void ertt_uma_dtor(void *mem, int size, void *arg) { + struct ertt *e_t = (struct ertt *)mem; + struct txseginfo *txsi, *n_txsi; + + txsi = TAILQ_FIRST(&e_t->txsegi_q); + while (txsi != NULL) { + n_txsi = TAILQ_NEXT(txsi, txsegi_lnk); + uma_zfree(V_txseginfo_zone, txsi); + txsi = n_txsi; + } + printf("Destroying ertt block %p\n", mem); } -DECLARE_HELPER_UMA(ertt, &ertt_helper, sizeof(struct ertt), ertt_uma_ctor, ertt_uma_dtor); +DECLARE_HELPER_UMA(ertt, &ertt_helper, 1, sizeof(struct ertt), ertt_uma_ctor, ertt_uma_dtor); Added: projects/tcp_cc_head/sys/netinet/h_ertt.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/tcp_cc_head/sys/netinet/h_ertt.h Thu Feb 11 07:00:21 2010 (r203771) @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 2009-2010 + * Swinburne University of Technology, Melbourne, Australia + * Copyright (c) 2010 Lawrence Stewart + * All rights reserved. + * + * This software was developed at the Centre for Advanced Internet + * Architectures, Swinburne University, by David Hayes and Lawrence Stewart, + * made possible in part by a grant from the FreeBSD Foundation and + * Cisco University Research Program Fund at Community Foundation + * Silicon Valley. + * + * 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$ + */ + +#ifndef _NETINET_H_ERTT_ +#define _NETINET_H_ERTT_ + +/* Structure contains the information about the + sent segment, for comparison with the corresponding ack */ +struct txseginfo; + +/* Structure used as the ertt data block. */ +struct ertt { + /* information about transmitted segments to aid in + RTT calculation for delay/rate based CC */ + TAILQ_HEAD(txseginfo_head, txseginfo) txsegi_q; + int rtt; /* per packet measured round trip time */ + int maxrtt; /* maximum seen rtt */ + int minrtt; /* minimum seen rtt */ + int dlyack_rx; /* guess if the receiver is using delayed acknowledgements.*/ + int timestamp_errors; /* for keeping track of inconsistencies in packet timestamps */ + int markedpkt_rtt; /* rtt for a marked packet */ + long bytes_tx_in_rtt; /* bytes tx so far in marked rtt */ + long bytes_tx_in_marked_rtt;/* final version of above */ + u_long marked_snd_cwnd; /* cwnd for marked rtt */ + int flags; /* flags*/ +}; + +#define ERTT_NEW_MEASUREMENT 0x01 /* new measurement */ +#define ERTT_MEASUREMENT_IN_PROGRESS 0x02 /* measuring marked RTT */ +#define ERTT_TSO_DISABLED 0x04 /* indicates TSO has been temporarily disabled */ + +#endif /* _NETINET_H_ERTT_ */ Modified: projects/tcp_cc_head/sys/netinet/helper_module.h ============================================================================== --- projects/tcp_cc_head/sys/netinet/helper_module.h Thu Feb 11 06:42:08 2010 (r203770) +++ projects/tcp_cc_head/sys/netinet/helper_module.h Thu Feb 11 07:00:21 2010 (r203771) @@ -41,7 +41,7 @@ struct helper_modevent_data { uma_dtor umadtor; }; -#define DECLARE_HELPER(hname, hdata) \ +#define DECLARE_HELPER(hname, hdata, version) \ static struct helper_modevent_data hmd_##hname = { \ .name = #hname, \ .helper = hdata \ @@ -52,9 +52,10 @@ struct helper_modevent_data { .priv = &hmd_##hname \ }; \ DECLARE_MODULE(hname, h_##hname, SI_SUB_PROTO_IFATTACHDOMAIN, \ - SI_ORDER_ANY) + SI_ORDER_ANY); \ + MODULE_VERSION(hname, version); -#define DECLARE_HELPER_UMA(hname, hdata, size, ctor, dtor) \ +#define DECLARE_HELPER_UMA(hname, hdata, version, size, ctor, dtor) \ static struct helper_modevent_data hmd_##hname = { \ .name = #hname, \ .helper = hdata, \ @@ -68,7 +69,8 @@ struct helper_modevent_data { .priv = &hmd_##hname \ }; \ DECLARE_MODULE(hname, h_##hname, SI_SUB_PROTO_IFATTACHDOMAIN, \ - SI_ORDER_ANY) + SI_ORDER_ANY); \ + MODULE_VERSION(hname, version); int helper_modevent(module_t mod, int type, void *data); Modified: projects/tcp_cc_head/sys/netinet/tcp_var.h ============================================================================== --- projects/tcp_cc_head/sys/netinet/tcp_var.h Thu Feb 11 06:42:08 2010 (r203770) +++ projects/tcp_cc_head/sys/netinet/tcp_var.h Thu Feb 11 07:00:21 2010 (r203771) @@ -76,7 +76,7 @@ struct sackhole { struct sackhint { struct sackhole *nexthole; int sack_bytes_rexmit; - + tcp_seq last_sack_ack; /* Last sack block acked with current pkt - used for enhanced RTT calculations*/ int ispare; /* explicit pad for 64bit alignment */ uint64_t _pad[2]; /* 1 sacked_bytes, 1 TBD */ }; @@ -247,12 +247,19 @@ struct tcpcb { #define BYTES_ACKED(tp, th) (th->th_ack - tp->snd_una) /* - * TCP specific helper hook point identifiers + * TCP specific helper hook point identifiers. */ -#define HHOOK_TCP_ESTABLISHED 1 +#define HHOOK_TCP_ESTABLISHED_IN 1 +#define HHOOK_TCP_ESTABLISHED_OUT 2 struct tcp_hhook_data { - tcp_seq curack; + struct tcpcb *tp; + struct tcphdr *th; + struct tcpopt *to; + long len; + int tso; + tcp_seq curack; + int new_sacked_bytes; }; /* From owner-svn-src-projects@FreeBSD.ORG Thu Feb 11 15:03:56 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A06F8106566C; Thu, 11 Feb 2010 15:03:56 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8F06F8FC08; Thu, 11 Feb 2010 15:03:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1BF3uOv008000; Thu, 11 Feb 2010 15:03:56 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1BF3uUq007997; Thu, 11 Feb 2010 15:03:56 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201002111503.o1BF3uUq007997@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 11 Feb 2010 15:03:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203779 - projects/tcp_cc_head/sys/netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2010 15:03:56 -0000 Author: lstewart Date: Thu Feb 11 15:03:56 2010 New Revision: 203779 URL: http://svn.freebsd.org/changeset/base/203779 Log: Import David's integration work on the vegas and hd CC algorithms. Modified: projects/tcp_cc_head/sys/netinet/cc_hd.c projects/tcp_cc_head/sys/netinet/cc_vegas.c Modified: projects/tcp_cc_head/sys/netinet/cc_hd.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/cc_hd.c Thu Feb 11 14:45:00 2010 (r203778) +++ projects/tcp_cc_head/sys/netinet/cc_hd.c Thu Feb 11 15:03:56 2010 (r203779) @@ -1,11 +1,14 @@ /*- * Copyright (c) 2009-2010 * Swinburne University of Technology, Melbourne, Australia + * Copyright (c) 2010 Lawrence Stewart + * All rights reserved. * * This software was developed at the Centre for Advanced Internet * Architectures, Swinburne University, by David Hayes and Lawrence Stewart, - * made possible in part by a grant from the Cisco University Research Program - * Fund at Community Foundation Silicon Valley. + * made possible in part by grants from the FreeBSD Foundation and + * Cisco University Research Program Fund at Community Foundation + * Silicon Valley. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -43,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -56,64 +60,87 @@ __FBSDID("$FreeBSD$"); #include #include +#include i +#include #include #include #include #define CAST_PTR_INT(X) (*((int*)(X))) +int hd_mod_init(void); +void hd_pre_fr(struct tcpcb *tp, struct tcphdr *th); +void hd_post_fr(struct tcpcb *tp, struct tcphdr *th); +void hd_ack_received(struct tcpcb *tp, struct tcphdr *th); + struct cc_algo hd_cc_algo = { .name = "hd", .mod_init = hd_mod_init, - .pre_fr = hd_pre_fr, - .post_fr = hd_post_fr, + .ack_received = hd_ack_received + /* the rest behaves as newreno */ + /* XXXLAS: Need to explicitly initialise to newreno funcs in mod_init */ }; +static VNET_DEFINE(uint32_t, hd_qthresh); +static VNET_DEFINE(uint32_t, hd_qmin); +static VNET_DEFINE(uint32_t, hd_pmax); +static VNET_DEFINE(int, ertt_id); + +#define V_hd_qthresh VNET(hd_qthresh) +#define V_hd_qmin VNET(hd_qmin) +#define V_hd_pmax VNET(hd_pmax) +#define V_ertt_id VNET(ertt_id) + static int hd_qthresh_handler(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(TD_TO_VNET(req->td)); - int error, new; - - new = V_delaycc_queue_thresh; - error = sysctl_handle_int(oidp, &new, 0, req); - if (error == 0 && req->newptr) { - if (1000*new < hz) /* if less than kernel tick rate */ - error = EINVAL; - else - V_delaycc_queue_thresh = new*hz/1000; /* number of kernel ticks */ + if (req->newptr != NULL) { + if (CAST_PTR_INT(req->newptr) < 1 || CAST_PTR_INT(req->newptr) < V_hd_qmin) + return (EINVAL); } - return (error); + return sysctl_handle_int(oidp, arg1, arg2, req); + + /* INIT_VNET_INET(TD_TO_VNET(req->td)); */ + /* int error, new; */ + + /* new = V_hd_qthresh; */ + /* error = sysctl_handle_int(oidp, &new, 0, req); */ + /* if (error == 0 && req->newptr) { */ + /* if (new*hz < 1000) /\* if less than kernel tick rate *\/ */ + /* error = EINVAL; */ + /* else */ + /* V_hd_qthresh = new*hz/1000; /\* number of kernel ticks *\/ */ + /* } */ + /* return (error); */ } static int hd_qmin_handler(SYSCTL_HANDLER_ARGS) { - if(req-V>newptr != NULL) { - if(CAST_PTR_INT(req->newptr) < 1) + if (req->newptr != NULL) { + if (CAST_PTR_INT(req->newptr) > V_hd_qthresh) return (EINVAL); } - return sysctl_handle_int(oidp, arg1, arg2, req); -} + /* INIT_VNET_INET(TD_TO_VNET(req->td)); */ + /* int error, new; */ -static int -hd_pmax_handler(SYSCTL_HANDLER_ARGS) -{ - if(req->newptr != NULL) { - if(CAST_PTR_INT(req->newptr) == 0 || - CAST_PTR_INT(req->newptr) > 100) - return (EINVAL); - } - - return sysctl_handle_int(oidp, arg1, arg2, req); + /* new = V_hd_qmin; */ + /* error = sysctl_handle_int(oidp, &new, 0, req); */ + /* if (error == 0 && req->newptr) { */ + /* if (1000*new < hz) /\* if less than kernel tick rate *\/ */ + /* error = EINVAL; */ + /* else */ + /* V_hd_qmin = new*hz/1000; /\* number of kernel ticks *\/ */ + /* } */ + /* return (error); */ } static int -hd_wnd_backoff_handler(SYSCTL_HANDLER_ARGS) +hd_pmax_handler(SYSCTL_HANDLER_ARGS) { if(req->newptr != NULL) { if(CAST_PTR_INT(req->newptr) == 0 || @@ -124,120 +151,73 @@ hd_wnd_backoff_handler(SYSCTL_HANDLER_AR return sysctl_handle_int(oidp, arg1, arg2, req); } -/* Modifications to impliment the Hamilton delay based congestion control - algorithm -- David Hayes The key differences between delay_tcp_congestion_exp - and tcp_congestion_exp are: - - 1. instead of ssthresh being set to half cwnd, it is set to: - - delta * minrtt/rtt * cwnd. - - The basic back off factor is the ratio between the current measured rtt - and the lowest measured rtt. To ensure a good minrtt measurment, this - is modified by 0 < delta < 1 . Delta is the window_backoff_modifier/100. - (see D.Leith, R.Shorten, J.Heffner, L.Dunn, F.Baker - Delay-based AIMD Congestion Control, Proc. PFLDnet 2007) - - 2. snd_cwnd = snd_ssthresh. Since no packet has been lost - the normal fast recovery mechanism is not necessary. -*/ -/* invbeta*8 for interger arithmetic */ -static void inline -beta_tcp_congestion_exp(struct tcpcb *tp, int invbeta) -{ - u_int win; - if (invbeta < 8 || invbeta > 16) - invbeta=16; /* for safety, must reduce but not by more than 1/2 */ - - win = min(tp->snd_wnd, tp->snd_cwnd) * 8/ - invbeta / tp->t_maxseg; - if (win < 2) - win = 2; - tp->snd_ssthresh = win * tp->t_maxseg; - tp->snd_recover = tp->snd_max; - if (tp->t_flags & TF_ECN_PERMIT) - tp->t_flags |= TF_ECN_SND_CWR; - tp->snd_cwnd = tp->snd_ssthresh; - ENTER_DELAYRATERECOVERY(tp); -} /* Hamilto backoff function (see reference below) */ static int inline prob_backoff_func(int Qdly, int maxQdly) { - int p; - if (Qdly < V_delaycc_queue_thresh) - p = INT_MAX / 100 * V_delaycc_pmax - / (V_delaycc_queue_thresh - V_delaycc_queue_min) - * (Qdly - V_delaycc_queue_min); - else - if (Qdly > V_delaycc_queue_thresh) - p = INT_MAX / 100 * V_delaycc_pmax - / (maxQdly - V_delaycc_queue_thresh) - * (maxQdly - Qdly); - else - p = INT_MAX / 100 * V_delaycc_pmax; - return(p); + int p; + if (Qdly < V_hd_qthresh) + p = INT_MAX / 100 * V_hd_pmax + / (V_hd_qthresh - V_hd_qmin) + * (Qdly - V_hd_qmin); + else + if (Qdly > V_hd_qthresh) + p = INT_MAX / 100 * V_hd_pmax + / (maxQdly - V_hd_qthresh) + * (maxQdly - Qdly); + else + p = INT_MAX / 100 * V_hd_pmax; + return(p); } -/* half cwnd backoff - David Hayes */V +/* half cwnd backoff */ +/* XXXLAS: I don't think we need this. */ static void inline -tcp_congestion_exp(struct tcpcb *tp) +hd_congestion_exp(struct tcpcb *tp) { - u_int win, decr; - win = tp->snd_cwnd/tp->t_maxseg; - decr = win>>2; - win -= decr; - if (win < 2) - win = 2; - tp->snd_ssthresh = win * tp->t_maxseg; - tp->snd_recover = tp->snd_max; - if (tp->t_flags & TF_ECN_PERMIT) - tp->t_flags |= TF_ECN_SND_CWR; - tp->snd_cwnd = tp->snd_ssthresh; - ENTER_DELAYRATERECOVERY(tp); -} - -/* Hamilton delay based congestion control detection and response - David Hayes*/ -void -hamilton_delay_congestion(struct tcpcb *tp) + u_int win, decr; + win = min(tp->snd_wnd, tp->snd_cwnd) / tp->t_maxseg; + decr = win>>1; + win -= decr; + if (win < 2) + win = 2; + tp->snd_ssthresh = win * tp->t_maxseg; + tp->snd_recover = tp->snd_max; + if (tp->t_flags & TF_ECN_PERMIT) + tp->t_flags |= TF_ECN_SND_CWR; + tp->snd_cwnd = tp->snd_ssthresh; +} + +/* Hamilton delay based congestion control detection and response */ + void +hd_ack_received(struct tcpcb *tp, struct tcphdr *th) { - if (!IN_DELAYRATERECOVERY(tp) && !IN_FASTRECOVERY(tp)) { - struct enhanced_timing *e_t; - e_t = &tp->e_t; - - - if (e_t->rtt && e_t->minrtt && V_delaycc_window_backoff_modifier - && (V_delaycc_queue_thresh > 0)) { - int Qdly = e_t->rtt - e_t->minrtt; - if (mod_tests & HD_ProbBackoff && (Qdly > V_delaycc_queue_min)) { - /* based on algorithm developed at the Hamilton Institute, Ireland - See Lukasz Budzisz, Rade Stanojevic, Robert Shorton and Fred Baker, - "A stratagy for fair coexistence of loss and delay-based congestion - control algorithms", to be published IEEE Communication Letters 2009 */ - int p; - p = prob_backoff_func(Qdly, e_t->maxrtt - e_t->minrtt); - if (random() < p) { - tcp_congestion_exp(tp); /* halve cwnd */ - } - } else { - /* test for congestion using measured rtt as an indicator */ - if ((e_t->rtt - e_t->minrtt) > V_delaycc_queue_thresh) { - /* 8 factor to add precision */ - int invbeta = e_t->rtt *800 / e_t->minrtt / V_delaycc_window_backoff_modifier; - beta_tcp_congestion_exp(tp, invbeta); + + struct ertt *e_t = (struct ertt *)get_helper_dblock(tp->dblocks, + tp->n_dblocks, V_ertt_id); + + if (e_t->rtt && e_t->minrtt && (V_hd_qthresh > 0)) { + int Qdly = e_t->rtt - e_t->minrtt; + if (Qdly > V_hd_qmin) { + /* based on algorithm developed at the Hamilton Institute, Ireland + See Lukasz Budzisz, Rade Stanojevic, Robert Shorton and Fred Baker, + "A stratagy for fair coexistence of loss and delay-based congestion + control algorithms", to be published IEEE Communication Letters 2009 */ + int p; + p = prob_backoff_func(Qdly, e_t->maxrtt - e_t->minrtt); + if (random() < p) { + hd_congestion_exp(tp); /* halve cwnd */ + } + } } - } - } - } } int hd_mod_init(void) { - hd_cc_algo.ack_received = newreno_cc_algo.ack_received; + V_ertt_id = get_helper_id("ertt"); return (0); } @@ -245,24 +225,20 @@ SYSCTL_DECL(_net_inet_tcp_cc_hd); SYSCTL_NODE(_net_inet_tcp_cc, OID_AUTO, hd, CTLFLAG_RW, NULL, "Hamilton delay-based congestion control related settings"); -SYSCTL_OID(_net_inet_tcp_cc_hd, OID_AUTO, window_backoff_modifier, - CTLTYPE_UINT|CTLFLAG_RW, &hd_wnd_backoff_modifier, 0, - &hd_wnd_backoff_handler, "IU", - "percentage - When Hamilton delay based congestion control is used, this sets the percent modification to the multiplicative decrease factor"); - -SYSCTL_OID(_net_inet_tcp_cc_hd, OID_AUTO, queue_threshold - CTLTYPE_UINT|CTLFLAG_RW, &hd_qthresh, 0, +SYSCTL_OID(_net_inet_tcp_cc_hd, OID_AUTO, queue_threshold, + CTLTYPE_UINT|CTLFLAG_RW, &V_hd_qthresh, 20, &hd_qthresh_handler, "IU", - "Entered in milliseconds, but converted to kernel ticks - When Hamilton delay based congestion control is used, this sets the queueing congestion threshold"); + "Queueing congestion threshold in ticks"); -SYSCTL_OID(_net_inet_tcp_cc_hd, OID_AUTO, pmax - CTLTYPE_UINT|CTLFLAG_RW, &hd_pmax, 0, +SYSCTL_OID(_net_inet_tcp_cc_hd, OID_AUTO, pmax, + CTLTYPE_UINT|CTLFLAG_RW, &V_hd_pmax, 5, &hd_pmax_handler, "IU", - "percentage - When Hamilton delay based congestion control is used, this sets the minimum queueing delay for the probabilistic backoff function"); + "Per packet maximum backoff probability as a percentage"); -SYSCTL_OID(_net_inet_tcp_cc_hd, OID_AUTO, queue_min - CTLTYPE_UINT|CTLFLAG_RW, &hd_qmin, 0, +SYSCTL_OID(_net_inet_tcp_cc_hd, OID_AUTO, queue_min, + CTLTYPE_UINT|CTLFLAG_RW, &V_hd_qmin, 5, &hd_qmin_handler, "IU", - "Entered in milliseconds, but converted to kernel ticks - When Hamilton delay based congestion control is used, this sets the minimum queueing delay for the probabilistic backoff function"); + "Minimum queueing delay threshold in ticks"); DECLARE_CC_MODULE(hd, &hd_cc_algo); +MODULE_DEPEND(hd, ertt, 1, 1, 1); Modified: projects/tcp_cc_head/sys/netinet/cc_vegas.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/cc_vegas.c Thu Feb 11 14:45:00 2010 (r203778) +++ projects/tcp_cc_head/sys/netinet/cc_vegas.c Thu Feb 11 15:03:56 2010 (r203779) @@ -1,11 +1,14 @@ /*- * Copyright (c) 2009-2010 * Swinburne University of Technology, Melbourne, Australia + * Copyright (c) 2010 Lawrence Stewart + * All rights reserved. * * This software was developed at the Centre for Advanced Internet * Architectures, Swinburne University, by David Hayes and Lawrence Stewart, - * made possible in part by a grant from the Cisco University Research Program - * Fund at Community Foundation Silicon Valley. + * made possible in part by grants from the FreeBSD Foundation and + * Cisco University Research Program Fund at Community Foundation + * Silicon Valley. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -56,6 +59,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include #include @@ -63,26 +68,42 @@ __FBSDID("$FreeBSD$"); #define CAST_PTR_INT(X) (*((int*)(X))) int vegas_mod_init(void); -void vegas_pre_fr(struct tcpcb *tp, struct tcphdr *th); -void vegas_post_fr(struct tcpcb *tp, struct tcphdr *th); +int vegas_cb_init(struct tcpcb *tp); +void vegas_cb_destroy(struct tcpcb *tp); +void vegas_ack_received(struct tcpcb *tp, struct tcphdr *th); +void vegas_conn_init(struct tcpcb *tp); + +struct vegas { + int rtt_ctr; /*counts rtts for vegas slow start */ +}; + +MALLOC_DECLARE(M_VEGAS); +MALLOC_DEFINE(M_VEGAS, "vegas data", + "Per connection data required for the VEGAS congestion algorithm"); /* function pointers for various hooks into the TCP stack */ struct cc_algo vegas_cc_algo = { .name = "vegas", .mod_init = vegas_mod_init, - .pre_fr = vegas_pre_fr, - .post_fr = vegas_post_fr, + .ack_received = vegas_ack_received, + .cb_init = vegas_cb_init, + .cb_destroy = vegas_cb_destroy + /* newreno fastrecovery and timout mechanisms are used in this implementation */ }; -static uint32_t vegas_alpha = 1; -static uint32_t vegas_beta = 3; +static VNET_DEFINE(uint32_t, vegas_alpha); +static VNET_DEFINE(uint32_t, vegas_beta); +static VNET_DEFINE(int, ertt_id); +#define V_vegas_alpha VNET(vegas_alpha) +#define V_vegas_beta VNET(vegas_beta) +#define V_ertt_id VNET(ertt_id) static int vegas_alpha_handler(SYSCTL_HANDLER_ARGS) { if(req->newptr != NULL) { if(CAST_PTR_INT(req->newptr) < 1 || - CAST_PTR_INT(req->newptr) > vegas_beta) + CAST_PTR_INT(req->newptr) > V_vegas_beta) return (EINVAL); } @@ -94,7 +115,7 @@ vegas_beta_handler(SYSCTL_HANDLER_ARGS) { if(req->newptr != NULL) { if(CAST_PTR_INT(req->newptr) < 1 || - CAST_PTR_INT(req->newptr) <= vegas_alpha) + CAST_PTR_INT(req->newptr) < V_vegas_alpha) return (EINVAL); } @@ -102,38 +123,76 @@ vegas_beta_handler(SYSCTL_HANDLER_ARGS) } void -vegas_post_fr(struct tcpcb *tp, struct tcphdr *th) +vegas_ack_received(struct tcpcb *tp, struct tcphdr *th) { -/* struct enhanced_timing *e_t; - struct rateinfo *r_i; - e_t = &tp->e_t; - r_i = &e_t->r_i; - - if (!IN_FASTRECOVERY(tp) && (tp->e_t.flags & DRCC_NEW_MEASUREMENT)) { - - long diff = r_i->expected_tx_rate - r_i->actual_tx_rate; - if (diff < V_ratecc_vegas_alpha*tp->t_maxseg/e_t->minrtt) - tp->snd_cwnd = min(tp->snd_cwnd + tp->t_maxseg, TCP_MAXWIN<snd_scale); - else if (diff > V_ratecc_vegas_beta*tp->t_maxseg/e_t->minrtt) - tp->snd_cwnd = max(2*tp->t_maxseg,tp->snd_cwnd-tp->t_maxseg); - - e_t->flags &= ~DRCC_NEW_MEASUREMENT; + struct ertt *e_t = (struct ertt *) get_helper_dblock(tp->dblocks, + tp->n_dblocks, V_ertt_id); + struct vegas *vegas_data = CC_DATA(tp); + long expected_tx_rate, actual_tx_rate; + + if (!IN_FASTRECOVERY(tp) && (e_t->flags & ERTT_NEW_MEASUREMENT)) { + + expected_tx_rate = e_t->marked_snd_cwnd/e_t->minrtt; + actual_tx_rate = e_t->bytes_tx_in_marked_rtt/e_t->markedpkt_rtt; + + long ndiff = (expected_tx_rate - actual_tx_rate)*e_t->minrtt/tp->t_maxseg; + + + if (ndiff < V_vegas_alpha) + if (tp->snd_cwnd < tp->snd_ssthresh) { + vegas_data->rtt_ctr += 1; + if (vegas_data->rtt_ctr > 1) { + newreno_cc_algo.ack_received(tp, th); /* reno slow start every second RTT */ + vegas_data->rtt_ctr = 0; + } + } else { + tp->snd_cwnd = min(tp->snd_cwnd + tp->t_maxseg, TCP_MAXWIN<snd_scale); + } + else if (ndiff > V_vegas_beta) { + tp->snd_cwnd = max(2*tp->t_maxseg,tp->snd_cwnd-tp->t_maxseg); + if (tp->snd_cwnd < tp->snd_ssthresh) + tp->snd_ssthresh = tp->snd_cwnd; /* exit slow start */ + e_t->flags &= ~ERTT_NEW_MEASUREMENT; + } } -*/ } +/* Create struct to store VEGAS specific data */ +int +vegas_cb_init(struct tcpcb *tp) +{ + struct vegas *vegas_data; + + vegas_data = malloc(sizeof(struct vegas), M_VEGAS, M_NOWAIT); + + if (vegas_data == NULL) + return (ENOMEM); + + vegas_data->rtt_ctr = 1; + + CC_DATA(tp) = vegas_data; + + return (0); +} + +/* + * Free the struct used to store VEGAS specific data for the specified + * TCP control block. + */ void -vegas_pre_fr(struct tcpcb *tp, struct tcphdr *th) +vegas_cb_destroy(struct tcpcb *tp) { - //EXIT_RATE_AVOID(tp); - //EXIT_DELAYRATERECOVERY(tp); + if (CC_DATA(tp) != NULL) + free(CC_DATA(tp), M_VEGAS); } int vegas_mod_init(void) { - vegas_cc_algo.ack_received = newreno_cc_algo.ack_received; + V_vegas_alpha = 1; + V_vegas_beta = 3; + V_ertt_id = get_helper_id("ertt"); return (0); } @@ -142,13 +201,14 @@ SYSCTL_NODE(_net_inet_tcp_cc, OID_AUTO, "VEGAS related settings"); SYSCTL_OID(_net_inet_tcp_cc_vegas, OID_AUTO, vegas_alpha, - CTLTYPE_UINT|CTLFLAG_RW, &vegas_alpha, 0, + CTLTYPE_UINT|CTLFLAG_RW, &V_vegas_alpha, 0, &vegas_alpha_handler, "IU", "vegas alpha parameter - Entered in terms of number \"buffers\" (0 < alpha < beta)"); SYSCTL_OID(_net_inet_tcp_cc_vegas, OID_AUTO, vegas_beta, - CTLTYPE_UINT|CTLFLAG_RW, &vegas_beta, 0, + CTLTYPE_UINT|CTLFLAG_RW, &V_vegas_beta, 0, &vegas_beta_handler, "IU", "vegas beta parameter - Entered in terms of number \"buffers\" (0 < alpha < beta)"); DECLARE_CC_MODULE(vegas, &vegas_cc_algo); +MODULE_DEPEND(vegas, ertt, 1, 1, 1); From owner-svn-src-projects@FreeBSD.ORG Thu Feb 11 15:36:39 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D855106568B; Thu, 11 Feb 2010 15:36:39 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CA568FC18; Thu, 11 Feb 2010 15:36:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1BFadrE015209; Thu, 11 Feb 2010 15:36:39 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1BFadGx015204; Thu, 11 Feb 2010 15:36:39 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201002111536.o1BFadGx015204@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 11 Feb 2010 15:36:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203781 - projects/tcp_cc_head/sys/netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2010 15:36:39 -0000 Author: lstewart Date: Thu Feb 11 15:36:39 2010 New Revision: 203781 URL: http://svn.freebsd.org/changeset/base/203781 Log: - The ertt helper actually needs an input and output path hook point to work correctly, so update accordingly. - In order to do enhanced timing correctly, need to track the most recently SACKed sequence number, by adding a new member to sackhint. - Expand the context data passed to the helper hooks as required by the ertt helper. Modified: projects/tcp_cc_head/sys/netinet/tcp_input.c projects/tcp_cc_head/sys/netinet/tcp_output.c projects/tcp_cc_head/sys/netinet/tcp_sack.c projects/tcp_cc_head/sys/netinet/tcp_subr.c Modified: projects/tcp_cc_head/sys/netinet/tcp_input.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/tcp_input.c Thu Feb 11 15:34:54 2010 (r203780) +++ projects/tcp_cc_head/sys/netinet/tcp_input.c Thu Feb 11 15:36:39 2010 (r203781) @@ -2119,14 +2119,20 @@ tcp_do_segment(struct mbuf *m, struct tc TCPSTAT_INC(tcps_rcvacktoomuch); goto dropafterack; } + hhook_data.new_sacked_bytes = 0; if ((tp->t_flags & TF_SACK_PERMIT) && ((to.to_flags & TOF_SACK) || - !TAILQ_EMPTY(&tp->snd_holes))) + !TAILQ_EMPTY(&tp->snd_holes))) { tcp_sack_doack(tp, &to, th->th_ack); + /* XXXDH: should only be one if a productive SACK */ + hhook_data.new_sacked_bytes = 1; + } - hhook_data.curack = th->th_ack; - run_hhooks(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED, &hhook_data, - tp->dblocks, tp->n_dblocks); + hhook_data.tp = tp; + hhook_data.th = th; + hhook_data.to = &to; + run_hhooks(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_IN, &hhook_data, + tp->dblocks, tp->n_dblocks); if (SEQ_LEQ(th->th_ack, tp->snd_una)) { if (tlen == 0 && tiwin == tp->snd_wnd) { Modified: projects/tcp_cc_head/sys/netinet/tcp_output.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/tcp_output.c Thu Feb 11 15:34:54 2010 (r203780) +++ projects/tcp_cc_head/sys/netinet/tcp_output.c Thu Feb 11 15:36:39 2010 (r203781) @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -161,6 +162,7 @@ tcp_output(struct tcpcb *tp) struct sackhole *p; int tso = 0; struct tcpopt to; + struct tcp_hhook_data hhook_data; #if 0 int maxburst = TCP_MAXBURST; #endif @@ -1112,6 +1114,15 @@ timer: tp->snd_max = tp->snd_nxt + len; } + hhook_data.th = th; + hhook_data.tp = tp; + hhook_data.to = &to; + hhook_data.len = len; + hhook_data.tso = tso; + run_hhooks(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_OUT, &hhook_data, + tp->dblocks, tp->n_dblocks); + + #ifdef TCPDEBUG /* * Trace. Modified: projects/tcp_cc_head/sys/netinet/tcp_sack.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/tcp_sack.c Thu Feb 11 15:34:54 2010 (r203780) +++ projects/tcp_cc_head/sys/netinet/tcp_sack.c Thu Feb 11 15:36:39 2010 (r203781) @@ -426,6 +426,7 @@ tcp_sack_doack(struct tcpcb *tp, struct * are received. */ sblkp = &sack_blocks[num_sack_blks - 1]; /* Last SACK block */ + tp->sackhint.last_sack_ack = sblkp->end; if (SEQ_LT(tp->snd_fack, sblkp->start)) { /* * The highest SACK block is beyond fack. Append new SACK Modified: projects/tcp_cc_head/sys/netinet/tcp_subr.c ============================================================================== --- projects/tcp_cc_head/sys/netinet/tcp_subr.c Thu Feb 11 15:34:54 2010 (r203780) +++ projects/tcp_cc_head/sys/netinet/tcp_subr.c Thu Feb 11 15:36:39 2010 (r203781) @@ -378,7 +378,10 @@ tcp_init(void) V_tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH; - if (register_hhook_head(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED, + if (register_hhook_head(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_IN, + HHOOK_NOWAIT) != 0) + printf("%s: WARNING: unable to register helper hook\n", __func__); + if (register_hhook_head(HHOOK_TYPE_TCP, HHOOK_TCP_ESTABLISHED_OUT, HHOOK_NOWAIT) != 0) printf("%s: WARNING: unable to register helper hook\n", __func__); From owner-svn-src-projects@FreeBSD.ORG Fri Feb 12 19:36:38 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E040C1065692; Fri, 12 Feb 2010 19:36:37 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D03A28FC1B; Fri, 12 Feb 2010 19:36:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1CJabhj009763; Fri, 12 Feb 2010 19:36:37 GMT (envelope-from rodrigc@svn.freebsd.org) Received: (from rodrigc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1CJabJ8009756; Fri, 12 Feb 2010 19:36:37 GMT (envelope-from rodrigc@svn.freebsd.org) Message-Id: <201002121936.o1CJabJ8009756@svn.freebsd.org> From: Craig Rodrigues Date: Fri, 12 Feb 2010 19:36:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203803 - in projects/jbuild/usr.bin: jbuild make X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2010 19:36:38 -0000 Author: rodrigc Date: Fri Feb 12 19:36:37 2010 New Revision: 203803 URL: http://svn.freebsd.org/changeset/base/203803 Log: Do not hardcode "make:" in diagnostic messages. Define PROG_NAME, based on the value of PROG in the Makefile. Modified: projects/jbuild/usr.bin/jbuild/Buildfile projects/jbuild/usr.bin/jbuild/Makefile projects/jbuild/usr.bin/make/Makefile projects/jbuild/usr.bin/make/job.c projects/jbuild/usr.bin/make/main.c projects/jbuild/usr.bin/make/util.c Modified: projects/jbuild/usr.bin/jbuild/Buildfile ============================================================================== --- projects/jbuild/usr.bin/jbuild/Buildfile Fri Feb 12 18:52:24 2010 (r203802) +++ projects/jbuild/usr.bin/jbuild/Buildfile Fri Feb 12 19:36:37 2010 (r203803) @@ -32,6 +32,7 @@ NO_SHARED ?= YES CFLAGS += -I${.CURDIR} CFLAGS += -DMAKE_VERSION=\"5200408120\" +CFLAGS += -DPROG_NAME=\"${PROG}\" CFLAGS += -DDEFSHELLNAME=\"sh\" CFLAGS += -I${.CURDIR}/filemon Modified: projects/jbuild/usr.bin/jbuild/Makefile ============================================================================== --- projects/jbuild/usr.bin/jbuild/Makefile Fri Feb 12 18:52:24 2010 (r203802) +++ projects/jbuild/usr.bin/jbuild/Makefile Fri Feb 12 19:36:37 2010 (r203803) @@ -17,7 +17,7 @@ NO_MAN= IGNORE_PRAGMA= YES DEBUG_FLAGS+= -g -CFLAGS+= -DMAKE_VERSION=\"8000000000\" +CFLAGS+= -DMAKE_VERSION=\"8000000000\" -DPROG_NAME=\"${PROG}\" # We're building 'build', not 'make' so the behaviour is different in # some areas like defaulting to silent. Modified: projects/jbuild/usr.bin/make/Makefile ============================================================================== --- projects/jbuild/usr.bin/make/Makefile Fri Feb 12 18:52:24 2010 (r203802) +++ projects/jbuild/usr.bin/make/Makefile Fri Feb 12 19:36:37 2010 (r203803) @@ -11,7 +11,7 @@ SRCS= arch.c buf.c cond.c dir.c for.c ha WARNS?= 6 NO_SHARED?= YES -CFLAGS+=-DMAKE_VERSION=\"5200408120\" +CFLAGS+=-DMAKE_VERSION=\"5200408120\" -DPROG_NAME=\"${PROG}\" # There is no obvious performance improvement currently. # CFLAGS+=-DUSE_KQUEUE Modified: projects/jbuild/usr.bin/make/job.c ============================================================================== --- projects/jbuild/usr.bin/make/job.c Fri Feb 12 18:52:24 2010 (r203802) +++ projects/jbuild/usr.bin/make/job.c Fri Feb 12 19:36:37 2010 (r203803) @@ -1731,7 +1731,7 @@ Job_CheckCommands(GNode *gn, void (*abor * this node's parents so they never get examined. */ static const char msg[] = - "make: don't know how to make"; + PROG_NAME ": don't know how to make"; if (gn->type & OP_OPTIONAL) { fprintf(stdout, "%s %s(ignored)\n", Modified: projects/jbuild/usr.bin/make/main.c ============================================================================== --- projects/jbuild/usr.bin/make/main.c Fri Feb 12 18:52:24 2010 (r203802) +++ projects/jbuild/usr.bin/make/main.c Fri Feb 12 19:36:37 2010 (r203803) @@ -1502,13 +1502,13 @@ main(int argc, char **argv) Path_Expand(defsysmk, &sysIncPath, &sysMkPath); if (Lst_IsEmpty(&sysMkPath)) - Fatal("make: no system rules (%s).", PATH_DEFSYSMK); + Fatal(PROG_NAME ": no system rules (%s).", PATH_DEFSYSMK); LST_FOREACH(ln, &sysMkPath) { if (!ReadMakefile(Lst_Datum(ln))) break; } if (ln != NULL) - Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); + Fatal(PROG_NAME ": cannot open %s.", (char *)Lst_Datum(ln)); Lst_Destroy(&sysMkPath, free); } @@ -1520,7 +1520,7 @@ main(int argc, char **argv) break; } if (ln != NULL) - Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); + Fatal(PROG_NAME ": cannot open %s.", (char *)Lst_Datum(ln)); #ifdef JBUILD } else TryReadMakefile("Buildfile"); Modified: projects/jbuild/usr.bin/make/util.c ============================================================================== --- projects/jbuild/usr.bin/make/util.c Fri Feb 12 18:52:24 2010 (r203802) +++ projects/jbuild/usr.bin/make/util.c Fri Feb 12 19:36:37 2010 (r203803) @@ -181,7 +181,7 @@ Punt(const char *fmt, ...) va_list ap; va_start(ap, fmt); - fprintf(stderr, "make: "); + fprintf(stderr, PROG_NAME ": "); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); From owner-svn-src-projects@FreeBSD.ORG Fri Feb 12 20:27:36 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0AE20106568B; Fri, 12 Feb 2010 20:27:36 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EF00A8FC08; Fri, 12 Feb 2010 20:27:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1CKRZMw021022; Fri, 12 Feb 2010 20:27:35 GMT (envelope-from rodrigc@svn.freebsd.org) Received: (from rodrigc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1CKRZmu021020; Fri, 12 Feb 2010 20:27:35 GMT (envelope-from rodrigc@svn.freebsd.org) Message-Id: <201002122027.o1CKRZmu021020@svn.freebsd.org> From: Craig Rodrigues Date: Fri, 12 Feb 2010 20:27:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203805 - projects/jbuild/usr.bin/jbuild X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2010 20:27:36 -0000 Author: rodrigc Date: Fri Feb 12 20:27:35 2010 New Revision: 203805 URL: http://svn.freebsd.org/changeset/base/203805 Log: MFC 203098 to make.1 Submitted by: ru Modified: projects/jbuild/usr.bin/jbuild/jbuild.1 Modified: projects/jbuild/usr.bin/jbuild/jbuild.1 ============================================================================== --- projects/jbuild/usr.bin/jbuild/jbuild.1 Fri Feb 12 19:52:51 2010 (r203804) +++ projects/jbuild/usr.bin/jbuild/jbuild.1 Fri Feb 12 20:27:35 2010 (r203805) @@ -800,7 +800,7 @@ These directories will be searched for s .Nm after it has finished parsing all input Buildfiles. .El -.Ss Variable modifiers +.Ss Variable Modifiers Variable expansion may be modified to select or modify each word of the variable (where a .Dq word @@ -815,7 +815,7 @@ The colon may be escaped with a backslas .Pq Ql \e . .Bl -tag -width Cm .Sm off -.It Cm \&:C No / Ar pattern Xo +.It Cm :C No / Ar pattern Xo .No / Ar replacement .No / Op Cm 1g .Xc @@ -844,13 +844,13 @@ and are orthogonal; the former specifies whether multiple words are potentially affected, the latter whether multiple substitutions can potentially occur within each affected word. -.It Cm \&:E +.It Cm :E Replaces each word in the variable with its suffix. -.It Cm \&:H +.It Cm :H Replaces each word in the variable with everything but the last component. -.It Cm \&:L +.It Cm :L Converts variable to lower-case letters. -.It Cm \&:M Ns Ar pattern +.It Cm :M Ns Ar pattern Select only those words that match the rest of the modifier. The standard shell wildcard characters .Pf ( Ql * , @@ -861,21 +861,21 @@ may be used. The wildcard characters may be escaped with a backslash .Pq Ql \e . -.It Cm \&:N Ns Ar pattern +.It Cm :N Ns Ar pattern This is identical to -.Cm \&:M , +.Cm :M , but selects all words which do not match the rest of the modifier. -.It Cm \&:O +.It Cm :O Order every word in the variable alphabetically. -.It Cm \&:Q +.It Cm :Q Quotes every shell meta-character in the variable, so that it can be passed safely through recursive invocations of .Nm . -.It Cm \&:R +.It Cm :R Replaces each word in the variable with everything but its suffix. .Sm off -.It Cm \&:S No / Ar old_string Xo +.It Cm :S No / Ar old_string Xo .No / Ar new_string .No / Op Cm g .Xc @@ -939,11 +939,11 @@ is the substring of .Ar old_string to be replaced in .Ar new_string -.It Cm \&:T +.It Cm :T Replaces each word in the variable with its last component. -.It Cm \&:U +.It Cm :U Converts variable to upper-case letters. -.It Cm \&:u +.It Cm :u Remove adjacent duplicate words (like .Xr uniq 1 ) . .El From owner-svn-src-projects@FreeBSD.ORG Sat Feb 13 11:33:15 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2917A106568B; Sat, 13 Feb 2010 11:33:15 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 15C9A8FC08; Sat, 13 Feb 2010 11:33:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1DBXEPH007264; Sat, 13 Feb 2010 11:33:14 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1DBXEcW007262; Sat, 13 Feb 2010 11:33:14 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201002131133.o1DBXEcW007262@svn.freebsd.org> From: Peter Holm Date: Sat, 13 Feb 2010 11:33:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203821 - projects/stress2/misc X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Feb 2010 11:33:15 -0000 Author: pho Date: Sat Feb 13 11:33:14 2010 New Revision: 203821 URL: http://svn.freebsd.org/changeset/base/203821 Log: Scenario used to verify fix in r203818, where a missing clear of a bp pointer could cause a panic. Added: projects/stress2/misc/fragments.sh (contents, props changed) Added: projects/stress2/misc/fragments.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/stress2/misc/fragments.sh Sat Feb 13 11:33:14 2010 (r203821) @@ -0,0 +1,266 @@ +#!/bin/sh + +# +# Copyright (c) 2010 Peter Holm +# 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. +# +# 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$ +# + +# Scenario that causes "panic: brelse: free buffer onto another queue???" +# Idea for scenario by kib@. Fixed in r203818 + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg +here=`pwd` + +cd /tmp +sed '1,/^EOF/d' < $here/$0 > fragments.c +rm -f /tmp/fragments +cc -o fragments -Wall -Wextra -O2 -g fragments.c +rm -f fragments.c +cd $here + +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f ${mntpoint} +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart + +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs -U -m 0 md${mdstart}${part} > /dev/null 2>&1 +mount /dev/md${mdstart}${part} /mnt +chmod 777 /mnt + +cd /mnt +su ${testuser} -c "/tmp/fragments" +cd $here + +umount /mnt +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f ${mntpoint} +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart + +rm -f /tmp/fragments +exit +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOOPS 50000 +#define PARALLEL 8 + +static pid_t pid; +static char *buf; + +void +cleanup(int n) +{ + int i, j, start; + int nb = 0; + char file[128]; + struct statfs sbuf; + struct stat sb; + + if (n == -1) { + for (i = 0; i < LOOPS; i++) { + sprintf(file,"t%05d", i); + unlink(file); + } + return; + } + + start = arc4random() % n; + for (i = 0; i < LOOPS; i++) { + j = (start + i) % LOOPS; + sprintf(file,"t%05d", j); + if (stat(file, &sb) != 0) + continue; + + if (sb.st_size == 0) { + unlink(file); + continue; + } + if (truncate(file, 0) == 0) { + nb++; + continue; + } + if (nb > 10) + break; + } + + + for (i = 0; i < 10; i++) { + if (statfs(".", &sbuf) < 0) + err(1, "statfs(%s)", "."); + + if (sbuf.f_bfree > 8) + return; + } + + for (i = 0; i < LOOPS; i++) { + j = (start + i) % LOOPS; + sprintf(file,"t%05d", j); + if (unlink(file) == 0) { + return; + } + } +} + +void +fragments(void) +{ + int i, len; + char file[128]; + int fd; + + for (i = 0;; i++) { + sprintf(file,"d%d/f%05d.%05d", i/1000, pid, i); + + if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) { + if (errno != ENOSPC) + warn("open(%s)", file); + break; + } + + len = 2 * 1024; + if (write(fd, buf, len) != len) { + } + + close(fd); + } +} + +void +blocks(void) +{ + int i, len; + char file[128]; + int fd; + + for (i = 0;; i++) { + sprintf(file,"d%d/b%05d.%05d", i/1000, pid, i); + + if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) { + if (errno != ENOSPC) + warn("open(%s)", file); + break; + } + + len = 16 * 1024; + if (write(fd, buf, len) != len) { + } + + close(fd); + } +} + +void +setup(void) +{ + int i; + char file[128]; + + for (i = 0; i < 300; i++) { + sprintf(file,"d%d", i); + if (mkdir(file, 0700) == -1) + warn("mkdir(%s)", file); + } + + blocks(); + fragments(); + + for (i = 0;i < 8; i++) { + sprintf(file,"d%d/b%05d.%05d", i/1000, pid, i); + unlink(file); + unlink(file); + } + for (i = 0;i < 1; i++) { + sprintf(file,"d%d/f%05d.%05d", i/1000, pid, i); + unlink(file); + } + +} + +int +test(void) +{ + int i, len, n; + char file[128]; + int fd; + + for (i = 0; i < LOOPS; i++) { + sprintf(file,"t%05d", i); + + if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) { + continue; + } +// n = arc4random() % (12 + 1); + n = 0; + len = (arc4random() % (16 * 1024) + 1) + n * 16; + while (len > 0) { + if (write(fd, buf, len) == len) + break; + len = len / 2; + usleep(1000); + } + close(fd); + if (len == 0) { + cleanup(i); + } + } + + exit(0); + + return (0); +} + +int +main() +{ + int i, j, status; + + pid = getpid(); + if ((buf = malloc(12 * 16 * 1024)) == NULL) + err(1, "malloc()"); + + setup(); + for (j = 0; j < 50; j++) { + for (i = 0; i < PARALLEL; i++) { + if (fork() == 0) + test(); + } + for (i = 0; i < PARALLEL; i++) + wait(&status); + cleanup(-1); + } + return (0); +}