svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86

2012-06-22 Thread Konstantin Belousov
Author: kib
Date: Fri Jun 22 07:06:40 2012
New Revision: 237433
URL: http://svn.freebsd.org/changeset/base/237433

Log:
  Implement mechanism to export some kernel timekeeping data to
  usermode, using shared page.  The structures and functions have vdso
  prefix, to indicate the intended location of the code in some future.
  
  The versioned per-algorithm data is exported in the format of struct
  vdso_timehands, which mostly repeats the content of in-kernel struct
  timehands. Usermode reading of the structure can be lockless.
  Compatibility export for 32bit processes on 64bit host is also
  provided. Kernel also provides usermode with indication about
  currently used timecounter, so that libc can fall back to syscall if
  configured timecounter is unknown to usermode code.
  
  The shared data updates are initiated both from the tc_windup(), where
  a fast task is queued to do the update, and from sysctl handlers which
  change timecounter. A manual override switch
  kern.timecounter.fast_gettime allows to turn off the mechanism.
  
  Only x86 architectures export the real algorithm data, and there, only
  for tsc timecounter. HPET counters page could be exported as well, but
  I prefer to not further glue the kernel and libc ABI there until
  proper vdso-based solution is developed.
  
  Minimal stubs neccessary for non-x86 architectures to still compile
  are provided.
  
  Discussed with:   bde
  Reviewed by:  jhb
  Tested by:flo
  MFC after:1 month

Added:
  head/sys/amd64/include/vdso.h   (contents, props changed)
  head/sys/arm/include/vdso.h   (contents, props changed)
  head/sys/i386/include/vdso.h   (contents, props changed)
  head/sys/ia64/include/vdso.h   (contents, props changed)
  head/sys/kern/subr_dummy_vdso_tc.c   (contents, props changed)
  head/sys/mips/include/vdso.h   (contents, props changed)
  head/sys/pc98/include/vdso.h   (contents, props changed)
  head/sys/powerpc/include/vdso.h   (contents, props changed)
  head/sys/sparc64/include/vdso.h   (contents, props changed)
  head/sys/sys/vdso.h   (contents, props changed)
  head/sys/x86/include/vdso.h   (contents, props changed)
Modified:
  head/sys/conf/files.arm
  head/sys/conf/files.ia64
  head/sys/conf/files.mips
  head/sys/conf/files.powerpc
  head/sys/conf/files.sparc64
  head/sys/kern/imgact_elf.c
  head/sys/kern/kern_exec.c
  head/sys/kern/kern_tc.c
  head/sys/sys/sysent.h
  head/sys/x86/x86/tsc.c

Added: head/sys/amd64/include/vdso.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/amd64/include/vdso.h   Fri Jun 22 07:06:40 2012
(r237433)
@@ -0,0 +1,6 @@
+/*-
+ * This file is in the public domain.
+ */
+/* $FreeBSD$ */
+
+#include 

Added: head/sys/arm/include/vdso.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/include/vdso.h Fri Jun 22 07:06:40 2012(r237433)
@@ -0,0 +1,34 @@
+/*-
+ * Copyright 2012 Konstantin Belousov .
+ * 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 THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ARM_VDSO_H
+#define_ARM_VDSO_H
+
+#defineVDSO_TIMEHANDS_MD   \
+   uint32_tth_res[8];
+
+#endif

Modified: head/sys/conf/files.arm
==
--- head/sys/conf/files.arm Fri Jun 22 06:44:22 2012(r237432)
+++ head/sys/conf/files.arm Fri Jun 22 07:06:40 2012(r237433)
@@ -79,6 +79,7 @@ libkern/umoddi3.c standard
 #libkern/arm/strcmp.S  standard
 #libkern/arm/strncmp.S standard
 #

svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys

2012-06-22 Thread Konstantin Belousov
Author: kib
Date: Fri Jun 22 07:13:30 2012
New Revision: 237434
URL: http://svn.freebsd.org/changeset/base/237434

Log:
  Use struct vdso_timehands data to implement fast gettimeofday(2) and
  clock_gettime(2) functions if supported. The speedup seen in
  microbenchmarks is in range 4x-7x depending on the hardware.
  
  Only amd64 and i386 architectures are supported. Libc uses rdtsc and
  kernel data to calculate current time, if enabled by kernel.
  
  Hopefully, this code is going to migrate into vdso in some future.
  
  Discussed with:   bde
  Reviewed by:  jhb
  Tested by:flo
  MFC after:1 month

Added:
  head/lib/libc/amd64/sys/__vdso_gettc.c   (contents, props changed)
  head/lib/libc/i386/sys/__vdso_gettc.c   (contents, props changed)
  head/lib/libc/sys/__vdso_gettimeofday.c   (contents, props changed)
  head/lib/libc/sys/clock_gettime.c   (contents, props changed)
  head/lib/libc/sys/gettimeofday.c   (contents, props changed)
Modified:
  head/lib/libc/amd64/sys/Makefile.inc
  head/lib/libc/gen/aux.c
  head/lib/libc/i386/sys/Makefile.inc
  head/lib/libc/include/libc_private.h
  head/lib/libc/sys/Makefile.inc

Modified: head/lib/libc/amd64/sys/Makefile.inc
==
--- head/lib/libc/amd64/sys/Makefile.incFri Jun 22 07:06:40 2012
(r237433)
+++ head/lib/libc/amd64/sys/Makefile.incFri Jun 22 07:13:30 2012
(r237434)
@@ -1,7 +1,8 @@
 #  from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp
 # $FreeBSD$
 
-SRCS+= amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c 
amd64_set_gsbase.c
+SRCS+= amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c \
+   amd64_set_gsbase.c __vdso_gettc.c
 
 MDASM= vfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \
reboot.S sbrk.S setlogin.S sigreturn.S

Added: head/lib/libc/amd64/sys/__vdso_gettc.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/amd64/sys/__vdso_gettc.c  Fri Jun 22 07:13:30 2012
(r237434)
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2012 Konstantin Belousov 
+ *
+ * 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.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+
+static u_int
+__vdso_gettc_low(const struct vdso_timehands *th)
+{
+   uint32_t rv;
+
+   __asm __volatile("rdtsc; shrd %%cl, %%edx, %0"
+   : "=a" (rv) : "c" (th->th_x86_shift) : "edx");
+   return (rv);
+}
+
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+   return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32());
+}

Modified: head/lib/libc/gen/aux.c
==
--- head/lib/libc/gen/aux.c Fri Jun 22 07:06:40 2012(r237433)
+++ head/lib/libc/gen/aux.c Fri Jun 22 07:13:30 2012(r237434)
@@ -66,6 +66,7 @@ __init_elf_aux_vector(void)
 static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
 static int pagesize, osreldate, canary_len, ncpus, pagesizes_len;
 static char *canary, *pagesizes;
+static void *timekeep;
 
 static void
 init_aux(void)
@@ -101,6 +102,10 @@ init_aux(void)
case AT_NCPUS:
ncpus = aux->a_un.a_val;
break;
+
+   case AT_TIMEKEEP:
+   timekeep = aux->a_un.a_ptr;
+   break;
}
}
 }
@@ -163,6 +168,16 @@ _elf_aux_info(int aux, void *buf, int bu
} else
res = EINVAL;
break;
+   case AT_TIMEKEEP:
+   if (buflen == size

svn commit: r237435 - in head/sys/i386: i386 include

2012-06-22 Thread Konstantin Belousov
Author: kib
Date: Fri Jun 22 07:16:29 2012
New Revision: 237435
URL: http://svn.freebsd.org/changeset/base/237435

Log:
  Enable shared page on i386, now it has a use for vdso_timehands.
  
  MFC after:1 month

Modified:
  head/sys/i386/i386/elf_machdep.c
  head/sys/i386/include/vmparam.h

Modified: head/sys/i386/i386/elf_machdep.c
==
--- head/sys/i386/i386/elf_machdep.cFri Jun 22 07:13:30 2012
(r237434)
+++ head/sys/i386/i386/elf_machdep.cFri Jun 22 07:16:29 2012
(r237435)
@@ -74,12 +74,15 @@ struct sysentvec elf32_freebsd_sysvec = 
.sv_setregs = exec_setregs,
.sv_fixlimit= NULL,
.sv_maxssiz = NULL,
-   .sv_flags   = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32,
+   .sv_flags   = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32 | SV_SHP,
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
+   .sv_shared_page_base = SHAREDPAGE,
+   .sv_shared_page_len = PAGE_SIZE,
.sv_schedtail   = NULL,
 };
+INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
 
 static Elf32_Brandinfo freebsd_brand_info = {
.brand  = ELFOSABI_FREEBSD,

Modified: head/sys/i386/include/vmparam.h
==
--- head/sys/i386/include/vmparam.h Fri Jun 22 07:13:30 2012
(r237434)
+++ head/sys/i386/include/vmparam.h Fri Jun 22 07:16:29 2012
(r237435)
@@ -165,7 +165,8 @@
 
 #define VM_MAXUSER_ADDRESS VADDR(PTDPTDI, 0)
 
-#define USRSTACK   VM_MAXUSER_ADDRESS
+#defineSHAREDPAGE  (VM_MAXUSER_ADDRESS - PAGE_SIZE)
+#defineUSRSTACKSHAREDPAGE
 
 #define VM_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI)
 #define VM_MIN_ADDRESS ((vm_offset_t)0)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys

2012-06-22 Thread Marius Strobl
On Fri, Jun 22, 2012 at 07:13:31AM +, Konstantin Belousov wrote:
> Author: kib
> Date: Fri Jun 22 07:13:30 2012
> New Revision: 237434
> URL: http://svn.freebsd.org/changeset/base/237434
> 
> Log:
>   Use struct vdso_timehands data to implement fast gettimeofday(2) and
>   clock_gettime(2) functions if supported. The speedup seen in
>   microbenchmarks is in range 4x-7x depending on the hardware.
>   
>   Only amd64 and i386 architectures are supported. Libc uses rdtsc and
>   kernel data to calculate current time, if enabled by kernel.

I don't know much about x86 CPUs but is my understanding correct
that TSCs are not synchronized in any way across CPUs, i.e.
reading it on different CPUs may result in time going backwards
etc., which is okay for this application though?

Marius

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys

2012-06-22 Thread Konstantin Belousov
On Fri, Jun 22, 2012 at 09:34:56AM +0200, Marius Strobl wrote:
> On Fri, Jun 22, 2012 at 07:13:31AM +, Konstantin Belousov wrote:
> > Author: kib
> > Date: Fri Jun 22 07:13:30 2012
> > New Revision: 237434
> > URL: http://svn.freebsd.org/changeset/base/237434
> > 
> > Log:
> >   Use struct vdso_timehands data to implement fast gettimeofday(2) and
> >   clock_gettime(2) functions if supported. The speedup seen in
> >   microbenchmarks is in range 4x-7x depending on the hardware.
> >   
> >   Only amd64 and i386 architectures are supported. Libc uses rdtsc and
> >   kernel data to calculate current time, if enabled by kernel.
> 
> I don't know much about x86 CPUs but is my understanding correct
> that TSCs are not synchronized in any way across CPUs, i.e.
> reading it on different CPUs may result in time going backwards
> etc., which is okay for this application though?

Generally speaking, tsc state among different CPU after boot is not
synchronized, you are right.

Kernel has somewhat doubtful test which verifies whether the after-boot
state of tsc looks good. If the test fails, TSC is not enabled by
default as timecounter, and then usermode follows kernel policy and
falls back to slow syscall. So we err on the safe side.
I tested this on Core i7 2xxx, where the test (usually) passes.

The test we currently have fails for me at least on single-package
Nehalems, where the counter should be located on uncore part. This
indicates some brokeness in the code, but I did not investigated the
cause.

The code can be developed which adjusts tsc msrs to be in sync. Or, rtdscp
instruction can be used, which allow to handle counter skew in usermode
in race-free manner.

While you are there. do you have comments about sparc64 TICK counter ?
On SMP, the counter of BSP is used by IPI. Is it unavoidable ?


pgpbUQaD5boRd.pgp
Description: PGP signature


svn commit: r237436 - in head/sys/dev/cxgbe: . common firmware tom

2012-06-22 Thread Navdeep Parhar
Author: np
Date: Fri Jun 22 07:51:15 2012
New Revision: 237436
URL: http://svn.freebsd.org/changeset/base/237436

Log:
  cxgbe(4): update to firmware interface 1.5.2.0; updates to shared code.

Modified:
  head/sys/dev/cxgbe/common/common.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/common/t4_msg.h
  head/sys/dev/cxgbe/firmware/t4fw_cfg.txt
  head/sys/dev/cxgbe/firmware/t4fw_cfg_uwire.txt
  head/sys/dev/cxgbe/firmware/t4fw_interface.h
  head/sys/dev/cxgbe/osdep.h
  head/sys/dev/cxgbe/t4_sge.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c

Modified: head/sys/dev/cxgbe/common/common.h
==
--- head/sys/dev/cxgbe/common/common.h  Fri Jun 22 07:16:29 2012
(r237435)
+++ head/sys/dev/cxgbe/common/common.h  Fri Jun 22 07:51:15 2012
(r237436)
@@ -38,6 +38,8 @@ enum {
SERNUM_LEN = 24,/* Serial # length */
EC_LEN = 16,/* E/C length */
ID_LEN = 16,/* ID length */
+   PN_LEN = 16,/* Part Number length */
+   MACADDR_LEN= 12,/* MAC Address length */
 };
 
 enum { MEM_EDC0, MEM_EDC1, MEM_MC };
@@ -62,8 +64,8 @@ enum {
 };
 
 #define FW_VERSION_MAJOR 1
-#define FW_VERSION_MINOR 4
-#define FW_VERSION_MICRO 16
+#define FW_VERSION_MINOR 5
+#define FW_VERSION_MICRO 2
 
 struct port_stats {
u64 tx_octets;/* total # of octets in good frames */
@@ -219,6 +221,8 @@ struct vpd_params {
u8 ec[EC_LEN + 1];
u8 sn[SERNUM_LEN + 1];
u8 id[ID_LEN + 1];
+   u8 pn[PN_LEN + 1];
+   u8 na[MACADDR_LEN + 1];
 };
 
 struct pci_params {
@@ -356,6 +360,8 @@ void t4_write_indirect(struct adapter *a
   unsigned int data_reg, const u32 *vals,
   unsigned int nregs, unsigned int start_idx);
 
+u32 t4_hw_pci_read_cfg4(adapter_t *adapter, int reg);
+
 struct fw_filter_wr;
 
 void t4_intr_enable(struct adapter *adapter);
@@ -374,7 +380,7 @@ int t4_seeprom_wp(struct adapter *adapte
 int t4_read_flash(struct adapter *adapter, unsigned int addr, unsigned int 
nwords,
  u32 *data, int byte_oriented);
 int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
-int t4_load_boot(struct adapter *adap, const u8 *boot_data,
+int t4_load_boot(struct adapter *adap, u8 *boot_data,
  unsigned int boot_addr, unsigned int size);
 unsigned int t4_flash_cfg_addr(struct adapter *adapter);
 int t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int 
size);
@@ -431,6 +437,9 @@ int t4_mem_read(struct adapter *adap, in
__be32 *data);
 
 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
+void t4_get_port_stats_offset(struct adapter *adap, int idx,
+   struct port_stats *stats,
+   struct port_stats *offset);
 void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
 void t4_clr_port_stats(struct adapter *adap, int idx);
 
@@ -472,6 +481,10 @@ int t4_fw_hello(struct adapter *adap, un
enum dev_master master, enum dev_state *state);
 int t4_fw_bye(struct adapter *adap, unsigned int mbox);
 int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
+int t4_fw_halt(struct adapter *adap, unsigned int mbox, int force);
+int t4_fw_restart(struct adapter *adap, unsigned int mbox, int reset);
+int t4_fw_upgrade(struct adapter *adap, unsigned int mbox,
+ const u8 *fw_data, unsigned int size, int force);
 int t4_fw_initialize(struct adapter *adap, unsigned int mbox);
 int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
unsigned int vf, unsigned int nparams, const u32 *params,
@@ -484,6 +497,10 @@ int t4_cfg_pfvf(struct adapter *adap, un
unsigned int rxqi, unsigned int rxq, unsigned int tc,
unsigned int vi, unsigned int cmask, unsigned int pmask,
unsigned int exactf, unsigned int rcaps, unsigned int wxcaps);
+int t4_alloc_vi_func(struct adapter *adap, unsigned int mbox,
+unsigned int port, unsigned int pf, unsigned int vf,
+unsigned int nmac, u8 *mac, unsigned int *rss_size,
+unsigned int portfunc, unsigned int idstype);
 int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
unsigned int *rss_size);
@@ -524,5 +541,10 @@ int t4_sge_ctxt_rd(struct adapter *adap,
   enum ctxt_type ctype, u32 *data);
 int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, enum ctxt_type 
ctype,
  u32 *data);
+int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox);
 int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
+int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, u32 addr, 
u32 val);
+int t4_config_schedu

Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86

2012-06-22 Thread Alexander Motin

On 06/22/12 10:06, Konstantin Belousov wrote:

Author: kib
Date: Fri Jun 22 07:06:40 2012
New Revision: 237433
URL: http://svn.freebsd.org/changeset/base/237433

Log:
   Implement mechanism to export some kernel timekeeping data to
   usermode, using shared page.  The structures and functions have vdso
   prefix, to indicate the intended location of the code in some future.

   The versioned per-algorithm data is exported in the format of struct
   vdso_timehands, which mostly repeats the content of in-kernel struct
   timehands. Usermode reading of the structure can be lockless.
   Compatibility export for 32bit processes on 64bit host is also
   provided. Kernel also provides usermode with indication about
   currently used timecounter, so that libc can fall back to syscall if
   configured timecounter is unknown to usermode code.

   The shared data updates are initiated both from the tc_windup(), where
   a fast task is queued to do the update, and from sysctl handlers which
   change timecounter. A manual override switch
   kern.timecounter.fast_gettime allows to turn off the mechanism.

   Only x86 architectures export the real algorithm data, and there, only
   for tsc timecounter. HPET counters page could be exported as well, but
   I prefer to not further glue the kernel and libc ABI there until
   proper vdso-based solution is developed.

   Minimal stubs neccessary for non-x86 architectures to still compile
   are provided.

   Discussed with:  bde
   Reviewed by: jhb
   Tested by:   flo
   MFC after:   1 month




@@ -1360,6 +1367,7 @@ tc_windup(void)
  #endif

timehands = th;
+   taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task);
  }

  /* Report or change the active timecounter hardware. */


This taskqueue_enqueue_fast() will schedule extra thread to run each 
time hardclock() fires. One thread may be not a big problem, but 
together with callout swi and possible other threads woken up there it 
will wake up several other CPU cores from sleep just to put them back in 
few microseconds. Now davide@ and me are trying to fix that by avoiding 
callout SWI use for simple tasks. Please, let's not create another 
problem same time.


--
Alexander Motin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys

2012-06-22 Thread David Chisnall
On 22 Jun 2012, at 08:34, Marius Strobl wrote:

> I don't know much about x86 CPUs but is my understanding correct
> that TSCs are not synchronized in any way across CPUs, i.e.
> reading it on different CPUs may result in time going backwards
> etc., which is okay for this application though?

As long as the initial value is set on every context switch, it only matters 
that the TSC is monotonic and increments at an approximately constant rate.  It 
is also possible to set the TSC value, but that's less useful in this context.

The one thing to be careful about is the fact that certain power saving states 
will affect the speed at which the TSC increments, and so it is important to 
update the ticks-per-second value whenever a core goes into a low power state.

This is more or less the same approach used by Xen, so most of the issues have 
been ironed out: Oracle complained to CPU vendors about a few corner cases and, 
because Oracle customers tend to buy a lot of expensive Xeon and Opteron chips, 
they were fixed quite promptly.  

David

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86

2012-06-22 Thread Konstantin Belousov
On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote:
> On 06/22/12 10:06, Konstantin Belousov wrote:
> >Author: kib
> >Date: Fri Jun 22 07:06:40 2012
> >New Revision: 237433
> >URL: http://svn.freebsd.org/changeset/base/237433
> >
> >Log:
> >   Implement mechanism to export some kernel timekeeping data to
> >   usermode, using shared page.  The structures and functions have vdso
> >   prefix, to indicate the intended location of the code in some future.
> >
> >   The versioned per-algorithm data is exported in the format of struct
> >   vdso_timehands, which mostly repeats the content of in-kernel struct
> >   timehands. Usermode reading of the structure can be lockless.
> >   Compatibility export for 32bit processes on 64bit host is also
> >   provided. Kernel also provides usermode with indication about
> >   currently used timecounter, so that libc can fall back to syscall if
> >   configured timecounter is unknown to usermode code.
> >
> >   The shared data updates are initiated both from the tc_windup(), where
> >   a fast task is queued to do the update, and from sysctl handlers which
> >   change timecounter. A manual override switch
> >   kern.timecounter.fast_gettime allows to turn off the mechanism.
> >
> >   Only x86 architectures export the real algorithm data, and there, only
> >   for tsc timecounter. HPET counters page could be exported as well, but
> >   I prefer to not further glue the kernel and libc ABI there until
> >   proper vdso-based solution is developed.
> >
> >   Minimal stubs neccessary for non-x86 architectures to still compile
> >   are provided.
> >
> >   Discussed with:   bde
> >   Reviewed by:  jhb
> >   Tested by:flo
> >   MFC after:1 month
> 
> 
> >@@ -1360,6 +1367,7 @@ tc_windup(void)
> >  #endif
> >
> > timehands = th;
> >+taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task);
> >  }
> >
> >  /* Report or change the active timecounter hardware. */
> 
> This taskqueue_enqueue_fast() will schedule extra thread to run each 
> time hardclock() fires. One thread may be not a big problem, but 
> together with callout swi and possible other threads woken up there it 
> will wake up several other CPU cores from sleep just to put them back in 
> few microseconds. Now davide@ and me are trying to fix that by avoiding 
> callout SWI use for simple tasks. Please, let's not create another 
> problem same time.

The patch was public for quite a time. If you have some comments about
it, it would be much more productive to let me know about them before
the commit, not after.

Anyway, what is your proposal for 'let's not create another problem
same time' part of the message ? It was discussed, as a possibility,
to have permanent mapping for the shared page in the KVA and to perform
lock-less update of the struct vdso_timehands directly from hardclock
handler. My opinion was that amount of work added by tc_windup
eventhandler is not trivial, so it is better to be postponed to
less critical context. It also slightly more safe to not perform
lockless update for vdso_timehands, since otherwise module load which
register exec handler could cause transient gettimeofday() failure
in usermode.

This might boil down to the fact that tc_windup function is called
too often, in fact. Also, packing execution of tc_windup eventhandler
together with the clock swi is fine from my POV.


pgptCurkX7G0T.pgp
Description: PGP signature


svn commit: r237439 - head/sys/dev/cxgbe

2012-06-22 Thread Navdeep Parhar
Author: np
Date: Fri Jun 22 08:37:33 2012
New Revision: 237439
URL: http://svn.freebsd.org/changeset/base/237439

Log:
  Do not read registers with read side effects while performing a register
  dump for cxgbetool.

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cFri Jun 22 07:53:51 2012
(r237438)
+++ head/sys/dev/cxgbe/t4_main.cFri Jun 22 08:37:33 2012
(r237439)
@@ -2705,7 +2705,9 @@ t4_get_regs(struct adapter *sc, struct t
0xdfc0, 0xdfe0,
0xe000, 0xea7c,
0xf000, 0x11190,
-   0x19040, 0x19124,
+   0x19040, 0x1906c,
+   0x19078, 0x19080,
+   0x1908c, 0x19124,
0x19150, 0x191b0,
0x191d0, 0x191e8,
0x19238, 0x1924c,
@@ -2718,49 +2720,49 @@ t4_get_regs(struct adapter *sc, struct t
0x1a190, 0x1a1c4,
0x1a1fc, 0x1a1fc,
0x1e040, 0x1e04c,
-   0x1e240, 0x1e28c,
+   0x1e284, 0x1e28c,
0x1e2c0, 0x1e2c0,
0x1e2e0, 0x1e2e0,
0x1e300, 0x1e384,
0x1e3c0, 0x1e3c8,
0x1e440, 0x1e44c,
-   0x1e640, 0x1e68c,
+   0x1e684, 0x1e68c,
0x1e6c0, 0x1e6c0,
0x1e6e0, 0x1e6e0,
0x1e700, 0x1e784,
0x1e7c0, 0x1e7c8,
0x1e840, 0x1e84c,
-   0x1ea40, 0x1ea8c,
+   0x1ea84, 0x1ea8c,
0x1eac0, 0x1eac0,
0x1eae0, 0x1eae0,
0x1eb00, 0x1eb84,
0x1ebc0, 0x1ebc8,
0x1ec40, 0x1ec4c,
-   0x1ee40, 0x1ee8c,
+   0x1ee84, 0x1ee8c,
0x1eec0, 0x1eec0,
0x1eee0, 0x1eee0,
0x1ef00, 0x1ef84,
0x1efc0, 0x1efc8,
0x1f040, 0x1f04c,
-   0x1f240, 0x1f28c,
+   0x1f284, 0x1f28c,
0x1f2c0, 0x1f2c0,
0x1f2e0, 0x1f2e0,
0x1f300, 0x1f384,
0x1f3c0, 0x1f3c8,
0x1f440, 0x1f44c,
-   0x1f640, 0x1f68c,
+   0x1f684, 0x1f68c,
0x1f6c0, 0x1f6c0,
0x1f6e0, 0x1f6e0,
0x1f700, 0x1f784,
0x1f7c0, 0x1f7c8,
0x1f840, 0x1f84c,
-   0x1fa40, 0x1fa8c,
+   0x1fa84, 0x1fa8c,
0x1fac0, 0x1fac0,
0x1fae0, 0x1fae0,
0x1fb00, 0x1fb84,
0x1fbc0, 0x1fbc8,
0x1fc40, 0x1fc4c,
-   0x1fe40, 0x1fe8c,
+   0x1fe84, 0x1fe8c,
0x1fec0, 0x1fec0,
0x1fee0, 0x1fee0,
0x1ff00, 0x1ff84,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86

2012-06-22 Thread Alexander Motin

On 22.06.2012 11:25, Konstantin Belousov wrote:

On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote:

On 06/22/12 10:06, Konstantin Belousov wrote:

Author: kib
Date: Fri Jun 22 07:06:40 2012
New Revision: 237433
URL: http://svn.freebsd.org/changeset/base/237433

Log:
   Implement mechanism to export some kernel timekeeping data to
   usermode, using shared page.  The structures and functions have vdso
   prefix, to indicate the intended location of the code in some future.

   The versioned per-algorithm data is exported in the format of struct
   vdso_timehands, which mostly repeats the content of in-kernel struct
   timehands. Usermode reading of the structure can be lockless.
   Compatibility export for 32bit processes on 64bit host is also
   provided. Kernel also provides usermode with indication about
   currently used timecounter, so that libc can fall back to syscall if
   configured timecounter is unknown to usermode code.

   The shared data updates are initiated both from the tc_windup(), where
   a fast task is queued to do the update, and from sysctl handlers which
   change timecounter. A manual override switch
   kern.timecounter.fast_gettime allows to turn off the mechanism.

   Only x86 architectures export the real algorithm data, and there, only
   for tsc timecounter. HPET counters page could be exported as well, but
   I prefer to not further glue the kernel and libc ABI there until
   proper vdso-based solution is developed.

   Minimal stubs neccessary for non-x86 architectures to still compile
   are provided.

   Discussed with:  bde
   Reviewed by: jhb
   Tested by:   flo
   MFC after:   1 month




@@ -1360,6 +1367,7 @@ tc_windup(void)
  #endif

timehands = th;
+   taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task);
  }

  /* Report or change the active timecounter hardware. */


This taskqueue_enqueue_fast() will schedule extra thread to run each
time hardclock() fires. One thread may be not a big problem, but
together with callout swi and possible other threads woken up there it
will wake up several other CPU cores from sleep just to put them back in
few microseconds. Now davide@ and me are trying to fix that by avoiding
callout SWI use for simple tasks. Please, let's not create another
problem same time.


The patch was public for quite a time. If you have some comments about
it, it would be much more productive to let me know about them before
the commit, not after.


I'm sorry, I haven't seen it. My mad.


Anyway, what is your proposal for 'let's not create another problem
same time' part of the message ? It was discussed, as a possibility,
to have permanent mapping for the shared page in the KVA and to perform
lock-less update of the struct vdso_timehands directly from hardclock
handler. My opinion was that amount of work added by tc_windup
eventhandler is not trivial, so it is better to be postponed to
less critical context. It also slightly more safe to not perform
lockless update for vdso_timehands, since otherwise module load which
register exec handler could cause transient gettimeofday() failure
in usermode.

This might boil down to the fact that tc_windup function is called
too often, in fact. Also, packing execution of tc_windup eventhandler
together with the clock swi is fine from my POV.


I have nothing against using shared pages. On UP system I would probably 
have not so much against several threads. But on SMP system it will 
cause at least one, but in many cases two extra CPUs to be woken up. 
There are two or more threads to run on hardclock(): this taskqueue, 
callout swi and some thread(s) woken from callouts. Scheduler has no 
idea how heavy they are. So it will try to move each of them to separate 
idle CPU. Does the amount of work done in event handlers worth extra 
Watts consumed by rapidly waking CPUs? As quite rare person running 
FreeBSD on laptop, I am not sure. I am not sure even that on 
desktop/server this won't kill all benefit of fast clocks by limiting 
TurboBoost.


--
Alexander Motin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237412 - in head: sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/components/dis

2012-06-22 Thread Konstantin Belousov
On Fri, Jun 22, 2012 at 12:40:45AM +, Jung-uk Kim wrote:
> Author: jkim
> Date: Fri Jun 22 00:40:44 2012
> New Revision: 237412
> URL: http://svn.freebsd.org/changeset/base/237412
> 
> Log:
>   Merge ACPICA 20120620.

I think it is caused by import, malloc is called while spinlock is held:

ACPI: Executed 1 blocks of module-level executable AML code
acpi0: Power Button (fixed)
panic: blockable sleep lock (sleep mutex) 16 @ 
/usr/home/kostik/work/build/bsd/DEV/src/sys/vm/uma_core.c:2040
cpuid = 0
KDB: stack backtrace:
db_trace_self_wrapper() at 0x80279d0a = db_trace_self_wrapper+0x2a
panic() at 0x80325a28 = panic+0x1d8
witness_checkorder() at 0x80377938 = witness_checkorder+0x1d8
_mtx_lock_flags() at 0x80313777 = _mtx_lock_flags+0x87
uma_zalloc_arg() at 0x804db97a = uma_zalloc_arg+0x2ea
malloc() at 0x8030f7cd = malloc+0xbd
AcpiUtAllocate() at 0x802704f1 = AcpiUtAllocate+0x31
AcpiUtAllocateZeroed() at 0x80270559 = AcpiUtAllocateZeroed+0x19
AcpiSetupGpeForWake() at 0x8025becc = AcpiSetupGpeForWake+0xfc
acpi_probe_child() at 0x802848e9 = acpi_probe_child+0x2b9
AcpiNsWalkNamespace() at 0x802686ef = AcpiNsWalkNamespace+0x15f
AcpiWalkNamespace() at 0x80268c0f = AcpiWalkNamespace+0xbf
acpi_attach() at 0x80283e43 = acpi_attach+0x993
device_attach() at 0x8035ab62 = device_attach+0x72
bus_generic_attach() at 0x8035bd3a = bus_generic_attach+0x1a
nexus_acpi_attach() at 0x804fbd89 = nexus_acpi_attach+0x69
device_attach() at 0x8035ab62 = device_attach+0x72
bus_generic_new_pass() at 0x8035bf46 = bus_generic_new_pass+0xd6
bus_set_pass() at 0x803597ba = bus_set_pass+0x7a
configure() at 0x804fd51a = configure+0xa
mi_startup() at 0x802d5c17 = mi_startup+0x77
btext() at 0x802531cc = btext+0x2c
KDB: enter: panic
[ thread pid 0 tid 10 ]
Stopped at  0x8035fffb = kdb_enter+0x3b:movq
$0,0x1027d62(%rip)
db> show alllocks
Process 0 (kernel) thread 0x80837cc0 (10)
exclusive sleep mutex Giant (Giant) r = 0 (0x8133a900) locked @ 
/usr/home/kostik/work/build/bsd/DEV/src/sys/kern/kern_module.c:116
exclusive spin mutex ACPI lock (0xfe000321da80) (ACPI lock 
(0xfe000321da80)) r = 0 (0xfe000321da80) locked @ 
/usr/home/kostik/work/build/bsd/DEV/src/sys/dev/acpica/Osd/OsdSynch.c:535



pgp6HExkXhokZ.pgp
Description: PGP signature


Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86

2012-06-22 Thread Konstantin Belousov
On Fri, Jun 22, 2012 at 11:54:28AM +0300, Alexander Motin wrote:
> On 22.06.2012 11:25, Konstantin Belousov wrote:
> >On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote:
> >>On 06/22/12 10:06, Konstantin Belousov wrote:
> >>>Author: kib
> >>>Date: Fri Jun 22 07:06:40 2012
> >>>New Revision: 237433
> >>>URL: http://svn.freebsd.org/changeset/base/237433
> >>>
> >>>Log:
> >>>   Implement mechanism to export some kernel timekeeping data to
> >>>   usermode, using shared page.  The structures and functions have vdso
> >>>   prefix, to indicate the intended location of the code in some future.
> >>>
> >>>   The versioned per-algorithm data is exported in the format of struct
> >>>   vdso_timehands, which mostly repeats the content of in-kernel struct
> >>>   timehands. Usermode reading of the structure can be lockless.
> >>>   Compatibility export for 32bit processes on 64bit host is also
> >>>   provided. Kernel also provides usermode with indication about
> >>>   currently used timecounter, so that libc can fall back to syscall if
> >>>   configured timecounter is unknown to usermode code.
> >>>
> >>>   The shared data updates are initiated both from the tc_windup(), where
> >>>   a fast task is queued to do the update, and from sysctl handlers which
> >>>   change timecounter. A manual override switch
> >>>   kern.timecounter.fast_gettime allows to turn off the mechanism.
> >>>
> >>>   Only x86 architectures export the real algorithm data, and there, only
> >>>   for tsc timecounter. HPET counters page could be exported as well, but
> >>>   I prefer to not further glue the kernel and libc ABI there until
> >>>   proper vdso-based solution is developed.
> >>>
> >>>   Minimal stubs neccessary for non-x86 architectures to still compile
> >>>   are provided.
> >>>
> >>>   Discussed with: bde
> >>>   Reviewed by:jhb
> >>>   Tested by:  flo
> >>>   MFC after:  1 month
> >>
> >>
> >>>@@ -1360,6 +1367,7 @@ tc_windup(void)
> >>>  #endif
> >>>
> >>>   timehands = th;
> >>>+  taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task);
> >>>  }
> >>>
> >>>  /* Report or change the active timecounter hardware. */
> >>
> >>This taskqueue_enqueue_fast() will schedule extra thread to run each
> >>time hardclock() fires. One thread may be not a big problem, but
> >>together with callout swi and possible other threads woken up there it
> >>will wake up several other CPU cores from sleep just to put them back in
> >>few microseconds. Now davide@ and me are trying to fix that by avoiding
> >>callout SWI use for simple tasks. Please, let's not create another
> >>problem same time.
> >
> >The patch was public for quite a time. If you have some comments about
> >it, it would be much more productive to let me know about them before
> >the commit, not after.
> 
> I'm sorry, I haven't seen it. My mad.
> 
> >Anyway, what is your proposal for 'let's not create another problem
> >same time' part of the message ? It was discussed, as a possibility,
> >to have permanent mapping for the shared page in the KVA and to perform
> >lock-less update of the struct vdso_timehands directly from hardclock
> >handler. My opinion was that amount of work added by tc_windup
> >eventhandler is not trivial, so it is better to be postponed to
> >less critical context. It also slightly more safe to not perform
> >lockless update for vdso_timehands, since otherwise module load which
> >register exec handler could cause transient gettimeofday() failure
> >in usermode.
> >
> >This might boil down to the fact that tc_windup function is called
> >too often, in fact. Also, packing execution of tc_windup eventhandler
> >together with the clock swi is fine from my POV.
> 
> I have nothing against using shared pages. On UP system I would probably 
> have not so much against several threads. But on SMP system it will 
> cause at least one, but in many cases two extra CPUs to be woken up. 
> There are two or more threads to run on hardclock(): this taskqueue, 
> callout swi and some thread(s) woken from callouts. Scheduler has no 
> idea how heavy they are. So it will try to move each of them to separate 
> idle CPU. Does the amount of work done in event handlers worth extra 
> Watts consumed by rapidly waking CPUs? As quite rare person running 
> FreeBSD on laptop, I am not sure. I am not sure even that on 
> desktop/server this won't kill all benefit of fast clocks by limiting 
> TurboBoost.

Patch below would probably work, but I cannot test it right now on real
hardware due to ACPI issue. It worked for me in qemu.

commit 4f2ffd93b36d20eae61495776fc6b0855745fd7f
Author: Konstantin Belousov 
Date:   Fri Jun 22 13:19:22 2012 +0300

Use persistent kernel mapping of the shared page, and update the
vdso_timehands from hardclock, instead of scheduling task.

diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 80502e3..9365223 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1517,42 +1517,13 @@ exec_unregis

Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86

2012-06-22 Thread Konstantin Belousov
On Fri, Jun 22, 2012 at 01:23:42PM +0300, Konstantin Belousov wrote:
> On Fri, Jun 22, 2012 at 11:54:28AM +0300, Alexander Motin wrote:
> > On 22.06.2012 11:25, Konstantin Belousov wrote:
> > >On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote:
> > >>On 06/22/12 10:06, Konstantin Belousov wrote:
> > >>>Author: kib
> > >>>Date: Fri Jun 22 07:06:40 2012
> > >>>New Revision: 237433
> > >>>URL: http://svn.freebsd.org/changeset/base/237433
> > >>>
> > >>>Log:
> > >>>   Implement mechanism to export some kernel timekeeping data to
> > >>>   usermode, using shared page.  The structures and functions have vdso
> > >>>   prefix, to indicate the intended location of the code in some future.
> > >>>
> > >>>   The versioned per-algorithm data is exported in the format of struct
> > >>>   vdso_timehands, which mostly repeats the content of in-kernel struct
> > >>>   timehands. Usermode reading of the structure can be lockless.
> > >>>   Compatibility export for 32bit processes on 64bit host is also
> > >>>   provided. Kernel also provides usermode with indication about
> > >>>   currently used timecounter, so that libc can fall back to syscall if
> > >>>   configured timecounter is unknown to usermode code.
> > >>>
> > >>>   The shared data updates are initiated both from the tc_windup(), where
> > >>>   a fast task is queued to do the update, and from sysctl handlers which
> > >>>   change timecounter. A manual override switch
> > >>>   kern.timecounter.fast_gettime allows to turn off the mechanism.
> > >>>
> > >>>   Only x86 architectures export the real algorithm data, and there, only
> > >>>   for tsc timecounter. HPET counters page could be exported as well, but
> > >>>   I prefer to not further glue the kernel and libc ABI there until
> > >>>   proper vdso-based solution is developed.
> > >>>
> > >>>   Minimal stubs neccessary for non-x86 architectures to still compile
> > >>>   are provided.
> > >>>
> > >>>   Discussed with:   bde
> > >>>   Reviewed by:  jhb
> > >>>   Tested by:flo
> > >>>   MFC after:1 month
> > >>
> > >>
> > >>>@@ -1360,6 +1367,7 @@ tc_windup(void)
> > >>>  #endif
> > >>>
> > >>> timehands = th;
> > >>>+
> > >>>taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task);
> > >>>  }
> > >>>
> > >>>  /* Report or change the active timecounter hardware. */
> > >>
> > >>This taskqueue_enqueue_fast() will schedule extra thread to run each
> > >>time hardclock() fires. One thread may be not a big problem, but
> > >>together with callout swi and possible other threads woken up there it
> > >>will wake up several other CPU cores from sleep just to put them back in
> > >>few microseconds. Now davide@ and me are trying to fix that by avoiding
> > >>callout SWI use for simple tasks. Please, let's not create another
> > >>problem same time.
> > >
> > >The patch was public for quite a time. If you have some comments about
> > >it, it would be much more productive to let me know about them before
> > >the commit, not after.
> > 
> > I'm sorry, I haven't seen it. My mad.
> > 
> > >Anyway, what is your proposal for 'let's not create another problem
> > >same time' part of the message ? It was discussed, as a possibility,
> > >to have permanent mapping for the shared page in the KVA and to perform
> > >lock-less update of the struct vdso_timehands directly from hardclock
> > >handler. My opinion was that amount of work added by tc_windup
> > >eventhandler is not trivial, so it is better to be postponed to
> > >less critical context. It also slightly more safe to not perform
> > >lockless update for vdso_timehands, since otherwise module load which
> > >register exec handler could cause transient gettimeofday() failure
> > >in usermode.
> > >
> > >This might boil down to the fact that tc_windup function is called
> > >too often, in fact. Also, packing execution of tc_windup eventhandler
> > >together with the clock swi is fine from my POV.
> > 
> > I have nothing against using shared pages. On UP system I would probably 
> > have not so much against several threads. But on SMP system it will 
> > cause at least one, but in many cases two extra CPUs to be woken up. 
> > There are two or more threads to run on hardclock(): this taskqueue, 
> > callout swi and some thread(s) woken from callouts. Scheduler has no 
> > idea how heavy they are. So it will try to move each of them to separate 
> > idle CPU. Does the amount of work done in event handlers worth extra 
> > Watts consumed by rapidly waking CPUs? As quite rare person running 
> > FreeBSD on laptop, I am not sure. I am not sure even that on 
> > desktop/server this won't kill all benefit of fast clocks by limiting 
> > TurboBoost.
> 
> Patch below would probably work, but I cannot test it right now on real
> hardware due to ACPI issue. It worked for me in qemu.
> 
> commit 4f2ffd93b36d20eae61495776fc6b0855745fd7f
> Author: Konstantin Belousov 
> Date:   Fri Jun 22 13:19:22 2012 +0300
> 
> Use persistent kern

Re: svn commit: r237433 - in head/sys: amd64/include arm/include conf i386/include ia64/include kern mips/include pc98/include powerpc/include sparc64/include sys x86/include x86/x86

2012-06-22 Thread Alexander Motin

On 06/22/12 13:46, Konstantin Belousov wrote:

On Fri, Jun 22, 2012 at 01:23:42PM +0300, Konstantin Belousov wrote:

On Fri, Jun 22, 2012 at 11:54:28AM +0300, Alexander Motin wrote:

On 22.06.2012 11:25, Konstantin Belousov wrote:

On Fri, Jun 22, 2012 at 11:08:50AM +0300, Alexander Motin wrote:

On 06/22/12 10:06, Konstantin Belousov wrote:

Author: kib
Date: Fri Jun 22 07:06:40 2012
New Revision: 237433
URL: http://svn.freebsd.org/changeset/base/237433

Log:
   Implement mechanism to export some kernel timekeeping data to
   usermode, using shared page.  The structures and functions have vdso
   prefix, to indicate the intended location of the code in some future.

   The versioned per-algorithm data is exported in the format of struct
   vdso_timehands, which mostly repeats the content of in-kernel struct
   timehands. Usermode reading of the structure can be lockless.
   Compatibility export for 32bit processes on 64bit host is also
   provided. Kernel also provides usermode with indication about
   currently used timecounter, so that libc can fall back to syscall if
   configured timecounter is unknown to usermode code.

   The shared data updates are initiated both from the tc_windup(), where
   a fast task is queued to do the update, and from sysctl handlers which
   change timecounter. A manual override switch
   kern.timecounter.fast_gettime allows to turn off the mechanism.

   Only x86 architectures export the real algorithm data, and there, only
   for tsc timecounter. HPET counters page could be exported as well, but
   I prefer to not further glue the kernel and libc ABI there until
   proper vdso-based solution is developed.

   Minimal stubs neccessary for non-x86 architectures to still compile
   are provided.

   Discussed with:  bde
   Reviewed by: jhb
   Tested by:   flo
   MFC after:   1 month




@@ -1360,6 +1367,7 @@ tc_windup(void)
  #endif

timehands = th;
+   taskqueue_enqueue_fast(taskqueue_fast,&tc_windup_push_vdso_task);
  }

  /* Report or change the active timecounter hardware. */


This taskqueue_enqueue_fast() will schedule extra thread to run each
time hardclock() fires. One thread may be not a big problem, but
together with callout swi and possible other threads woken up there it
will wake up several other CPU cores from sleep just to put them back in
few microseconds. Now davide@ and me are trying to fix that by avoiding
callout SWI use for simple tasks. Please, let's not create another
problem same time.


The patch was public for quite a time. If you have some comments about
it, it would be much more productive to let me know about them before
the commit, not after.


I'm sorry, I haven't seen it. My mad.


Anyway, what is your proposal for 'let's not create another problem
same time' part of the message ? It was discussed, as a possibility,
to have permanent mapping for the shared page in the KVA and to perform
lock-less update of the struct vdso_timehands directly from hardclock
handler. My opinion was that amount of work added by tc_windup
eventhandler is not trivial, so it is better to be postponed to
less critical context. It also slightly more safe to not perform
lockless update for vdso_timehands, since otherwise module load which
register exec handler could cause transient gettimeofday() failure
in usermode.

This might boil down to the fact that tc_windup function is called
too often, in fact. Also, packing execution of tc_windup eventhandler
together with the clock swi is fine from my POV.


I have nothing against using shared pages. On UP system I would probably
have not so much against several threads. But on SMP system it will
cause at least one, but in many cases two extra CPUs to be woken up.
There are two or more threads to run on hardclock(): this taskqueue,
callout swi and some thread(s) woken from callouts. Scheduler has no
idea how heavy they are. So it will try to move each of them to separate
idle CPU. Does the amount of work done in event handlers worth extra
Watts consumed by rapidly waking CPUs? As quite rare person running
FreeBSD on laptop, I am not sure. I am not sure even that on
desktop/server this won't kill all benefit of fast clocks by limiting
TurboBoost.


Patch below would probably work, but I cannot test it right now on real
hardware due to ACPI issue. It worked for me in qemu.

commit 4f2ffd93b36d20eae61495776fc6b0855745fd7f
Author: Konstantin Belousov 
Date:   Fri Jun 22 13:19:22 2012 +0300

 Use persistent kernel mapping of the shared page, and update the
 vdso_timehands from hardclock, instead of scheduling task.


Slightly improved version. Since tc_fill_vdso_timehands is now
called from hardclock context, thee is no need to spin waiting for
valid current generation of timehands.


I can't evaluate how much "hackish" this is from memory management side, 
but I'm glad there is some viable solution.


Thank you!

--
Alexander Motin
___
svn-src-head@freebsd.org m

Re: svn commit: r237434 - in head/lib/libc: amd64/sys gen i386/sys include sys

2012-06-22 Thread John Baldwin
On Friday, June 22, 2012 3:34:56 am Marius Strobl wrote:
> On Fri, Jun 22, 2012 at 07:13:31AM +, Konstantin Belousov wrote:
> > Author: kib
> > Date: Fri Jun 22 07:13:30 2012
> > New Revision: 237434
> > URL: http://svn.freebsd.org/changeset/base/237434
> > 
> > Log:
> >   Use struct vdso_timehands data to implement fast gettimeofday(2) and
> >   clock_gettime(2) functions if supported. The speedup seen in
> >   microbenchmarks is in range 4x-7x depending on the hardware.
> >   
> >   Only amd64 and i386 architectures are supported. Libc uses rdtsc and
> >   kernel data to calculate current time, if enabled by kernel.
> 
> I don't know much about x86 CPUs but is my understanding correct
> that TSCs are not synchronized in any way across CPUs, i.e.
> reading it on different CPUs may result in time going backwards
> etc., which is okay for this application though?

Hmm, in practice I have found that on modern x86 CPUs (Penryn and later) the 
TSC is in fact sychronized across packages at work.  At least, when I measure 
skew across packages it appears to be consistent with the time it would take a 
write to propagate from one to the other.

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237412 - in head: sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/components/dis

2012-06-22 Thread Jung-uk Kim
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2012-06-22 05:58:47 -0400, Konstantin Belousov wrote:
> On Fri, Jun 22, 2012 at 12:40:45AM +, Jung-uk Kim wrote:
>> Author: jkim Date: Fri Jun 22 00:40:44 2012 New Revision: 237412 
>> URL: http://svn.freebsd.org/changeset/base/237412
>> 
>> Log: Merge ACPICA 20120620.
> 
> I think it is caused by import, malloc is called while spinlock is
> held:
> 
> ACPI: Executed 1 blocks of module-level executable AML code acpi0:
> Power Button (fixed) panic: blockable sleep lock (sleep mutex) 16 @
> /usr/home/kostik/work/build/bsd/DEV/src/sys/vm/uma_core.c:2040 
> cpuid = 0 KDB: stack backtrace: db_trace_self_wrapper() at
> 0x80279d0a = db_trace_self_wrapper+0x2a panic() at
> 0x80325a28 = panic+0x1d8 witness_checkorder() at
> 0x80377938 = witness_checkorder+0x1d8 _mtx_lock_flags() at
> 0x80313777 = _mtx_lock_flags+0x87 uma_zalloc_arg() at
> 0x804db97a = uma_zalloc_arg+0x2ea malloc() at
> 0x8030f7cd = malloc+0xbd AcpiUtAllocate() at
> 0x802704f1 = AcpiUtAllocate+0x31 AcpiUtAllocateZeroed() at
> 0x80270559 = AcpiUtAllocateZeroed+0x19 
> AcpiSetupGpeForWake() at 0x8025becc =
> AcpiSetupGpeForWake+0xfc acpi_probe_child() at 0x802848e9 =
> acpi_probe_child+0x2b9 AcpiNsWalkNamespace() at 0x802686ef
> = AcpiNsWalkNamespace+0x15f AcpiWalkNamespace() at
> 0x80268c0f = AcpiWalkNamespace+0xbf acpi_attach() at
> 0x80283e43 = acpi_attach+0x993 device_attach() at
> 0x8035ab62 = device_attach+0x72 bus_generic_attach() at
> 0x8035bd3a = bus_generic_attach+0x1a nexus_acpi_attach() at
> 0x804fbd89 = nexus_acpi_attach+0x69 device_attach() at
> 0x8035ab62 = device_attach+0x72 bus_generic_new_pass() at
> 0x8035bf46 = bus_generic_new_pass+0xd6 bus_set_pass() at
> 0x803597ba = bus_set_pass+0x7a configure() at
> 0x804fd51a = configure+0xa mi_startup() at
> 0x802d5c17 = mi_startup+0x77 btext() at 0x802531cc
> = btext+0x2c KDB: enter: panic [ thread pid 0 tid 10 ] Stopped
> at  0x8035fffb = kdb_enter+0x3b:movq
> $0,0x1027d62(%rip) db> show alllocks Process 0 (kernel) thread
> 0x80837cc0 (10) exclusive sleep mutex Giant (Giant) r =
> 0 (0x8133a900) locked @
> /usr/home/kostik/work/build/bsd/DEV/src/sys/kern/kern_module.c:116 
> exclusive spin mutex ACPI lock (0xfe000321da80) (ACPI lock
> (0xfe000321da80)) r = 0 (0xfe000321da80) locked @
> /usr/home/kostik/work/build/bsd/DEV/src/sys/dev/acpica/Osd/OsdSynch.c:535

Hmm...
> 
I was afraid it might happen.  I'll look into it ASAP.

Sorry for the trouble,

Jung-uk Kim
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/klPoACgkQmlay1b9qnVMg+QCggRXxXE2Wpc6kXWSpwbykhrWq
RvQAniVjs7p/084ZnlDPA+GQqyxTIF/w
=+7Iw
-END PGP SIGNATURE-
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237445 - head/sys/i386/i386

2012-06-22 Thread Konstantin Belousov
Author: kib
Date: Fri Jun 22 16:05:56 2012
New Revision: 237445
URL: http://svn.freebsd.org/changeset/base/237445

Log:
  Commit changes missed from r237435.  Properly calculate the signal
  trampoline addresses after the shared page is enabled.  Handle FreeBSD
  ABIs without shared page support too.
  
  Reported and tested by:   David Wolfskill 
 (previous version)
  Pointy hat to: kib
  MFC after:   1 month

Modified:
  head/sys/i386/i386/machdep.c

Modified: head/sys/i386/i386/machdep.c
==
--- head/sys/i386/i386/machdep.cFri Jun 22 14:58:40 2012
(r237444)
+++ head/sys/i386/i386/machdep.cFri Jun 22 16:05:56 2012
(r237445)
@@ -469,7 +469,13 @@ osendsig(sig_t catcher, ksiginfo_t *ksi,
}
 
regs->tf_esp = (int)fp;
-   regs->tf_eip = PS_STRINGS - szosigcode;
+   if (p->p_sysent->sv_sigcode_base != 0) {
+   regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode -
+   szosigcode;
+   } else {
+   /* a.out sysentvec does not use shared page */
+   regs->tf_eip = p->p_sysent->sv_psstrings - szosigcode;
+   }
regs->tf_eflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucodesel;
regs->tf_ds = _udatasel;
@@ -596,7 +602,8 @@ freebsd4_sendsig(sig_t catcher, ksiginfo
}
 
regs->tf_esp = (int)sfp;
-   regs->tf_eip = PS_STRINGS - szfreebsd4_sigcode;
+   regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode -
+   szfreebsd4_sigcode;
regs->tf_eflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucodesel;
regs->tf_ds = _udatasel;
@@ -747,7 +754,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, 
}
 
regs->tf_esp = (int)sfp;
-   regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
+   regs->tf_eip = p->p_sysent->sv_sigcode_base;
regs->tf_eflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucodesel;
regs->tf_ds = _udatasel;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237446 - head/sys/cam

2012-06-22 Thread Alexander Motin
Author: mav
Date: Fri Jun 22 16:20:13 2012
New Revision: 237446
URL: http://svn.freebsd.org/changeset/base/237446

Log:
  Don't print SCSI Queue Full and CAM_REQUEUE_REQ statuses as errors if they
  were handled and retried. They are part of normal operation for SCSI TCQ.
  
  MFC after:3 days

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==
--- head/sys/cam/cam_periph.c   Fri Jun 22 16:05:56 2012(r237445)
+++ head/sys/cam/cam_periph.c   Fri Jun 22 16:20:13 2012(r237446)
@@ -1354,6 +1354,7 @@ camperiphscsistatuserror(union ccb *ccb,
}
*timeout = 0;
error = ERESTART;
+   *print = 0;
break;
}
/* FALLTHROUGH */
@@ -1683,8 +1684,10 @@ cam_periph_error(union ccb *ccb, cam_fla
} else if (sense_flags & SF_NO_RETRY) {
error = EIO;
action_string = "Retry was blocked";
-   } else
+   } else {
error = ERESTART;
+   print = 0;
+   }
break;
case CAM_RESRC_UNAVAIL:
/* Wait a bit for the resource shortage to abate. */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237448 - head/lib/libedit

2012-06-22 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Jun 22 18:01:22 2012
New Revision: 237448
URL: http://svn.freebsd.org/changeset/base/237448

Log:
  Merge changes from upstream libedit.
  
  Our libedit has been diverging from the mainstream version
  maintained in NetBSD. As a consequence it has been difficult
  to do an appropriate MFV and we have been bringing only
  partial updates.
  
  Here we update most of the files to at least match the
  version available in NetBSD's snapshot of 20091228. This
  version was chosen because it still doesn't include wide
  character support (UTF-8), which involves many changes and
  new files.
  
  From NetBSD's logs:
  
  Dec 15 22:13:33 2006 - editline.3 el.c el.h histedit.h
  add EL_GETFP, and EL_SETFP.
  
  Apr 5 15:53:28 2008 - editline.3 el.c histedit.h readline.c
  add EL_REFRESH for the benefit of readline
  
  Sep 10 15:45:37 2008 - common.c el.c read.c refresh.c sig.c term.c term.h 
tty.c
  Allow a single process to control multiple ttys (for pthreads using 
_REENTRANT)
  using multiple EditLine objects.
  
  Jan 18 12:17:24 2009 - el.c read.c readline.c
  fix -Wsign-compare issues
  
  Feb 6 14:40:32 2009 - history.c
  Plug memory leak, from MySQL.
  
  Feb 5 19:15:44 2009 - histedit.h read.c
  match documentation in el_push
  
  Feb 6 13:14:37 2009 - vi.c
  Portability fix.
  
  Feb 12 13:39:49 2009 - readline.c term.c
  More fixes for existing portability stuff.
  
  Feb 15 21:24:13 2009 - el.h read.c
  don't restart on EINTR, instead return NULL immediately. From Anon Ymous
  
  Feb 15 21:25:01 2009 - sig.c sig.h
  in order for read() to return EINTR we need to use sigaction, not signal,
  otherwise SA_RESTART is set.
  
  Feb 15 21:55:23 2009 - chared.c chared.h common.c emacs.c filecomplete.c
  filecomplete.h key.c key.h read.c readline.c refresh.c search.c
  term.c tokenizer.c tty.c vi.c
  pass lint on _LP64.
  
  Feb 17 21:34:26 2009 - el.c histedit.hprompt.c prompt.h
  allow for a prompt argument.
  
  Feb 18 15:04:40 2009 - sig.c
  SA_RESTART for all signals but SIGINT. From Anon Ymous.
  
  Feb 19 15:20:22 2009 - read.c sig.c sig.h
  reset and redraw on sigcont. From Anon Ymous.
  
  Feb 21 23:31:56 2009 - key.c key.h readline.c vi.c
  more size_t stuff.
  
  Mar 10 20:46:15 2009 - editline.3 read.c
  make el_gets set the count to -1 on error to distinguish between EOF and
  error.
  
  Mar 31 17:38:27 2009 - editline.3 el.c histedit.h prompt.c prompt.h
  refresh.c term.c term.h
  Implement literal prompt sequences. Now someone can implement
  RL_PROMPT_START_LITERAL/RL_PROMPT_END_LITERAL :-)
  
  Mar 31 21:33:17 2009 - term.c
  cast to size_t to avoid sign / unsigned comparison warning.
  
  Apr 23 02:03 2009 - term.c
  Apply patch (requested by msaitoh in ticket #2007):
  Coverity CID 1668: Plug memory leak when malloc() failed.:55 2009
  
  May 11 18:33:30 2009 - editline.3 el.c histedit.h
  restore binary compatibility by providing new prompt functions that take
  an extra literal character.
  
  May 19 21:45:14 2009 - refresh.c
  always scroll when we advance past bottom. From Caleb Welton
  cwelton at greenplum dot com.
  
  Jul 17 12:27:57 2009 - term.c
  - off by one in the term.h case.
  - make code more similar to tcsh (if we want to handle wide chars, this is
needed; for now it is a no-op)
  
  Jul 22 15:56:29 2009 - el.c
  Move filename to the scope it is being used.
  From Michael Cook mcook at bbn dot com
  
  Jul 22 15:57:00 2009 - read.c
  Always initialize nread since it is an out param.
  From Michael Cook mcook at bbn dot com
  
  Jul 22 18:25:26 2009 - el.c
  Only need path if we have issetugid... From Anon Ymous
  
  Jul 25 21:19:23 2009 - el.c
  Ignore comment lines in .editrc from Jess Thrysoee
  
  Sep 7 21:24:33 2009
  histedit.h history.c readline.c
  apply apple patches from:
  http://opensource.apple.com/source/libedit/libedit-11/patches/
  
  Dec 28 21:52:43 2009 - refresh.c
  Fix bug where tab completion on the second or > line that caused listing
  ended up corrupting the display by an extra space in the beginning. Reported
  by Mac Chan.
  
  Dec 28 22:15:36 2009 - refresh.c term.c
  reduce diff with tcsh
  
  Obtained from:NetBSD
  Tested by:bapt, jilles and current@
  MFC after:1 week

Modified:
  head/lib/libedit/common.c
  head/lib/libedit/editline.3
  head/lib/libedit/editrc.5
  head/lib/libedit/el.c
  head/lib/libedit/el.h
  head/lib/libedit/histedit.h
  head/lib/libedit/history.c
  head/lib/libedit/key.c
  head/lib/libedit/key.h
  head/lib/libedit/prompt.c
  head/lib/libedit/prompt.h
  head/lib/libedit/read.c
  head/lib/libedit/refresh.c
  head/lib/libedit/search.c
  head/lib/libedit/sig.c
  head/lib/libedit/sig.h
  head/lib/libedit/term.c
  head/lib/libedit/term.h
  head/lib/libedit/tty.c
  head/lib/libedit/vi.c

Modified: head/lib/libedit/common.c
==
--- head/lib/libedit/common.c   Fri Jun 22 16:31:00 2012(r237447)
+++ he

svn commit: r237451 - head/sys/vm

2012-06-22 Thread Attilio Rao
Author: attilio
Date: Fri Jun 22 18:34:11 2012
New Revision: 237451
URL: http://svn.freebsd.org/changeset/base/237451

Log:
  - Add a comment explaining the locking of the cached pages pool held
by vm_objects.
  - Add flags for the per-object lock and free pages queue mutex lock.
Use the newly added flags to mark the cache root within the vm_object
structure.
  
  Please note that other vm_object members should be marked with correct
  locking but they are left for other commits.
  
  In collabouration with:   alc
  
  MFC after:3 days3 days3 days

Modified:
  head/sys/vm/vm_object.h

Modified: head/sys/vm/vm_object.h
==
--- head/sys/vm/vm_object.h Fri Jun 22 18:20:26 2012(r237450)
+++ head/sys/vm/vm_object.h Fri Jun 22 18:34:11 2012(r237451)
@@ -76,8 +76,21 @@
  *
  * vm_object_t Virtual memory object.
  *
+ * The root of cached pages pool is protected by both the per-object mutex
+ * and the free pages queue mutex.
+ * On insert in the cache splay tree, the per-object mutex is expected
+ * to be already held and the free pages queue mutex will be
+ * acquired during the operation too.
+ * On remove and lookup from the cache splay tree, only the free
+ * pages queue mutex is expected to be locked.
+ * These rules allow for reliably checking for the presence of cached
+ * pages with only the per-object lock held, thereby reducing contention
+ * for the free pages queue mutex.
+ *
  * List of locks
  * (c) const until freed
+ * (o) per-object mutex
+ * (f) free pages queue mutex
  *
  */
 
@@ -102,7 +115,7 @@ struct vm_object {
vm_ooffset_t backing_object_offset;/* Offset in backing object */
TAILQ_ENTRY(vm_object) pager_object_list; /* list of all objects of 
this pager type */
LIST_HEAD(, vm_reserv) rvq; /* list of reservations */
-   vm_page_t cache;/* root of the cache page splay tree */
+   vm_page_t cache;/* (o + f) root of the cache page splay 
tree */
void *handle;
union {
/*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237452 - in head: sbin/camcontrol sys/cam/scsi

2012-06-22 Thread Kenneth D. Merry
Author: ken
Date: Fri Jun 22 18:57:06 2012
New Revision: 237452
URL: http://svn.freebsd.org/changeset/base/237452

Log:
  Change 'camcontrol defects' to first probe a drive to find out how much
  defect information it has before grabbing the full defect list.
  
  This works around a bug with some Hitachi drives that generate data overrun
  errors when they are asked for more defect data than they have.
  
  The change is done in a spec-compliant way, so it should have no negative
  impact on drives that don't have this issue.
  
  This is based on work originally done at Sandvine.
  
  scsi_da.h:Add a define for the maximum amount of data that can be
contained in a defect list.
  
  camcontrol.c: Update the readdefects() function to issue an initial
command to determine the length of the defect list, and
then use that length in the request for the full defect
list.
  
  camcontrol.8: Add a note that some drives will report 0 defects available
if you don't request either the PLIST or GLIST.
  
  Submitted by: Mark Johnston  (original version)
  MFC after:3 days

Modified:
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c
  head/sys/cam/scsi/scsi_da.h

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Fri Jun 22 18:34:11 2012
(r237451)
+++ head/sbin/camcontrol/camcontrol.8   Fri Jun 22 18:57:06 2012
(r237452)
@@ -497,6 +497,8 @@ is specified,
 .Nm
 will print out the number of defects given in the READ DEFECT DATA header
 returned from the drive.
+Some drives will report 0 defects if neither the primary or grown defect
+lists are requested.
 .It Ic modepage
 Allows the user to display and optionally edit a SCSI mode page.
 The mode

Modified: head/sbin/camcontrol/camcontrol.c
==
--- head/sbin/camcontrol/camcontrol.c   Fri Jun 22 18:34:11 2012
(r237451)
+++ head/sbin/camcontrol/camcontrol.c   Fri Jun 22 18:57:06 2012
(r237452)
@@ -1799,13 +1799,14 @@ readdefects(struct cam_device *device, i
union ccb *ccb = NULL;
struct scsi_read_defect_data_10 *rdd_cdb;
u_int8_t *defect_list = NULL;
-   u_int32_t dlist_length = 65000;
+   u_int32_t max_dlist_length = SRDD10_MAX_LENGTH, dlist_length = 0;
u_int32_t returned_length = 0;
u_int32_t num_returned = 0;
u_int8_t returned_format;
unsigned int i;
int c, error = 0;
-   int lists_specified = 0;
+   int lists_specified;
+   int get_length = 1;
 
while ((c = getopt(argc, argv, combinedopt)) != -1) {
switch(c){
@@ -1842,20 +1843,33 @@ readdefects(struct cam_device *device, i
ccb = cam_getccb(device);
 
/*
-* Hopefully 65000 bytes is enough to hold the defect list.  If it
-* isn't, the disk is probably dead already.  We'd have to go with
-* 12 byte command (i.e. alloc_length is 32 bits instead of 16)
-* to hold them all.
+* Eventually we should probably support the 12 byte READ DEFECT
+* DATA command.  It supports a longer parameter list, which may be
+* necessary on newer drives with lots of defects.  According to
+* the SBC-3 spec, drives are supposed to return an illegal request
+* if they have more defect data than will fit in 64K.
 */
-   defect_list = malloc(dlist_length);
+   defect_list = malloc(max_dlist_length);
if (defect_list == NULL) {
warnx("can't malloc memory for defect list");
error = 1;
goto defect_bailout;
}
 
+   /*
+* We start off asking for just the header to determine how much
+* defect data is available.  Some Hitachi drives return an error
+* if you ask for more data than the drive has.  Once we know the
+* length, we retry the command with the returned length.
+*/
+   dlist_length = sizeof(struct scsi_read_defect_data_hdr_10);
+
rdd_cdb =(struct scsi_read_defect_data_10 *)&ccb->csio.cdb_io.cdb_bytes;
 
+retry:
+
+   lists_specified = 0;
+
/*
 * cam_getccb() zeros the CCB header only.  So we need to zero the
 * payload portion of the ccb.
@@ -1917,6 +1931,51 @@ readdefects(struct cam_device *device, i
returned_length = scsi_2btoul(((struct
scsi_read_defect_data_hdr_10 *)defect_list)->length);
 
+   if (get_length != 0) {
+   get_length = 0;
+
+   if ((ccb->ccb_h.status & CAM_STATUS_MASK) ==
+CAM_SCSI_STATUS_ERROR) {
+   struct scsi_sense_data *sense;
+   int error_code, sense_key, asc, ascq;
+
+   sense = &ccb->csio.sense_data;
+ 

Re: svn commit: r237448 - head/lib/libedit

2012-06-22 Thread Baptiste Daroussin
On Fri, Jun 22, 2012 at 06:01:23PM +, Pedro F. Giffuni wrote:
> Author: pfg
> Date: Fri Jun 22 18:01:22 2012
> New Revision: 237448
> URL: http://svn.freebsd.org/changeset/base/237448
> 
> Log:
>   Merge changes from upstream libedit.
>   
>   Our libedit has been diverging from the mainstream version
>   maintained in NetBSD. As a consequence it has been difficult
>   to do an appropriate MFV and we have been bringing only
>   partial updates.
>   
>   Here we update most of the files to at least match the
>   version available in NetBSD's snapshot of 20091228. This
>   version was chosen because it still doesn't include wide
>   character support (UTF-8), which involves many changes and
>   new files.
>   
>   From NetBSD's logs:
>   
>   Dec 15 22:13:33 2006 - editline.3 el.c el.h histedit.h
>   add EL_GETFP, and EL_SETFP.
>   
>   Apr 5 15:53:28 2008 - editline.3 el.c histedit.h readline.c
>   add EL_REFRESH for the benefit of readline
>   
>   Sep 10 15:45:37 2008 - common.c el.c read.c refresh.c sig.c term.c term.h 
> tty.c
>   Allow a single process to control multiple ttys (for pthreads using 
> _REENTRANT)
>   using multiple EditLine objects.
>   
>   Jan 18 12:17:24 2009 - el.c read.c readline.c
>   fix -Wsign-compare issues
>   
>   Feb 6 14:40:32 2009 - history.c
>   Plug memory leak, from MySQL.
>   
>   Feb 5 19:15:44 2009 - histedit.h read.c
>   match documentation in el_push
>   
>   Feb 6 13:14:37 2009 - vi.c
>   Portability fix.
>   
>   Feb 12 13:39:49 2009 - readline.c term.c
>   More fixes for existing portability stuff.
>   
>   Feb 15 21:24:13 2009 - el.h read.c
>   don't restart on EINTR, instead return NULL immediately. From Anon Ymous
>   
>   Feb 15 21:25:01 2009 - sig.c sig.h
>   in order for read() to return EINTR we need to use sigaction, not signal,
>   otherwise SA_RESTART is set.
>   
>   Feb 15 21:55:23 2009 - chared.c chared.h common.c emacs.c filecomplete.c
>   filecomplete.h key.c key.h read.c readline.c refresh.c search.c
>   term.c tokenizer.c tty.c vi.c
>   pass lint on _LP64.
>   
>   Feb 17 21:34:26 2009 - el.c histedit.h  prompt.c prompt.h
>   allow for a prompt argument.
>   
>   Feb 18 15:04:40 2009 - sig.c
>   SA_RESTART for all signals but SIGINT. From Anon Ymous.
>   
>   Feb 19 15:20:22 2009 - read.c sig.c sig.h
>   reset and redraw on sigcont. From Anon Ymous.
>   
>   Feb 21 23:31:56 2009 - key.c key.h readline.c vi.c
>   more size_t stuff.
>   
>   Mar 10 20:46:15 2009 - editline.3 read.c
>   make el_gets set the count to -1 on error to distinguish between EOF and
>   error.
>   
>   Mar 31 17:38:27 2009 - editline.3 el.c histedit.h prompt.c prompt.h
>   refresh.c term.c term.h
>   Implement literal prompt sequences. Now someone can implement
>   RL_PROMPT_START_LITERAL/RL_PROMPT_END_LITERAL :-)
>   
>   Mar 31 21:33:17 2009 - term.c
>   cast to size_t to avoid sign / unsigned comparison warning.
>   
>   Apr 23 02:03 2009 - term.c
>   Apply patch (requested by msaitoh in ticket #2007):
>   Coverity CID 1668: Plug memory leak when malloc() failed.:55 2009
>   
>   May 11 18:33:30 2009 - editline.3 el.c histedit.h
>   restore binary compatibility by providing new prompt functions that take
>   an extra literal character.
>   
>   May 19 21:45:14 2009 - refresh.c
>   always scroll when we advance past bottom. From Caleb Welton
>   cwelton at greenplum dot com.
>   
>   Jul 17 12:27:57 2009 - term.c
>   - off by one in the term.h case.
>   - make code more similar to tcsh (if we want to handle wide chars, this is
> needed; for now it is a no-op)
>   
>   Jul 22 15:56:29 2009 - el.c
>   Move filename to the scope it is being used.
>   From Michael Cook mcook at bbn dot com
>   
>   Jul 22 15:57:00 2009 - read.c
>   Always initialize nread since it is an out param.
>   From Michael Cook mcook at bbn dot com
>   
>   Jul 22 18:25:26 2009 - el.c
>   Only need path if we have issetugid... From Anon Ymous
>   
>   Jul 25 21:19:23 2009 - el.c
>   Ignore comment lines in .editrc from Jess Thrysoee
>   
>   Sep 7 21:24:33 2009
>   histedit.h history.c readline.c
>   apply apple patches from:
>   http://opensource.apple.com/source/libedit/libedit-11/patches/
>   
>   Dec 28 21:52:43 2009 - refresh.c
>   Fix bug where tab completion on the second or > line that caused listing
>   ended up corrupting the display by an extra space in the beginning. Reported
>   by Mac Chan.
>   
>   Dec 28 22:15:36 2009 - refresh.c term.c
>   reduce diff with tcsh
>   
>   Obtained from:  NetBSD
>   Tested by:  bapt, jilles and current@
>   MFC after:  1 week
> 
> Modified:
>   head/lib/libedit/common.c
>   head/lib/libedit/editline.3
>   head/lib/libedit/editrc.5
>   head/lib/libedit/el.c
>   head/lib/libedit/el.h
>   head/lib/libedit/histedit.h
>   head/lib/libedit/history.c
>   head/lib/libedit/key.c
>   head/lib/libedit/key.h
>   head/lib/libedit/prompt.c
>   head/lib/libedit/prompt.h
>   head/lib/libedit/read.c
>   head/lib/libedit/refresh.c
>   head/lib/libedit/sear

Re: svn commit: r237448 - head/lib/libedit

2012-06-22 Thread Doug Barton
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

As a general rule, please trim out replies. This list is worse than
most in the sense that people often reply to hundreds of lines only to
add a line or 2 at the bottom.

By trimming your reply you both save electrons, and make it easier for
people to see what you have to say.


Doug
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBCAAGBQJP5NWTAAoJEFzGhvEaGryEpVsH/3I60AiJ6JODDA9mx+ufW9LG
SAr/p13YGlswZxL5LOLCLOvwjNrvK6CJieb42XI+70PYkGAGH8syKunTy9s4EPuQ
2wXWHw4jlJaUfMTOFsXOvoZIFTrH0YPRt3qZic4TdfuxWlEkqrk4G37+lVNMhdsW
0MLJD/eJC5rV3Ve/YMKB2OSPK47mukOmY0spFXG/N2NQRryOuV8N3D6ycbWGDn7q
YJwpO98YxbbyxLEV394rGwVCK8T6taJXRBOLMu9VFR0L7321TPuayPc3cLg+0hQC
owr6vN2ga0uD7vjhoKbApBTTHzWAGYVWN1LU+rpE0/b5QGZByq2Muiz5SARBncI=
=cYw2
-END PGP SIGNATURE-
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237458 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2012-06-22 Thread Martin Matuska
Author: mm
Date: Fri Jun 22 20:42:11 2012
New Revision: 237458
URL: http://svn.freebsd.org/changeset/base/237458

Log:
  Import Illumos revision 13736:9f1d48e1681f
  2901 ZFS receive fails for exabyte sparse files
  
  References:
  https://www.illumos.org/issues/2901
  
  Obtained from:illumos (issue #2901)
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c  Fri Jun 
22 20:38:08 2012(r237457)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c  Fri Jun 
22 20:42:11 2012(r237458)
@@ -93,6 +93,9 @@ dump_free(dmu_sendarg_t *dsp, uint64_t o
 {
struct drr_free *drrf = &(dsp->dsa_drr->drr_u.drr_free);
 
+   if (length != -1ULL && offset + length < offset)
+   length = -1ULL;
+
/*
 * If there is a pending op, but it's not PENDING_FREE, push it out,
 * since free block aggregation can only be done for blocks of the
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237459 - head/sys/netinet6

2012-06-22 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Jun 22 21:26:35 2012
New Revision: 237459
URL: http://svn.freebsd.org/changeset/base/237459

Log:
  Just add a comment to further investigate when being closer to that code
  again next time.  The condition of the 2nd if() is very unlikely ever met.

Modified:
  head/sys/netinet6/in6_src.c

Modified: head/sys/netinet6/in6_src.c
==
--- head/sys/netinet6/in6_src.c Fri Jun 22 20:42:11 2012(r237458)
+++ head/sys/netinet6/in6_src.c Fri Jun 22 21:26:35 2012(r237459)
@@ -597,6 +597,7 @@ selectroute(struct sockaddr_in6 *dstsock
if (ron->ro_rt == NULL) {
in6_rtalloc(ron, fibnum); /* multi path case? */
if (ron->ro_rt == NULL) {
+   /* XXX-BZ WT.? */
if (ron->ro_rt) {
RTFREE(ron->ro_rt);
ron->ro_rt = NULL;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237460 - head/sys/dev/twa

2012-06-22 Thread Alexander Motin
Author: mav
Date: Fri Jun 22 21:46:41 2012
New Revision: 237460
URL: http://svn.freebsd.org/changeset/base/237460

Log:
  Return CAM_SEL_TIMEOUT and CAM_DEV_NOT_THERE instead of CAM_TID_INVALID
  and CAM_LUN_INVALID for case of missing devices. In removes tons of error
  messages from CAM during bus scans.
  
  Reported and tested by:   Mike Tancsa 
  MFC after:3 days

Modified:
  head/sys/dev/twa/tw_osl_cam.c

Modified: head/sys/dev/twa/tw_osl_cam.c
==
--- head/sys/dev/twa/tw_osl_cam.c   Fri Jun 22 21:26:35 2012
(r237459)
+++ head/sys/dev/twa/tw_osl_cam.c   Fri Jun 22 21:46:41 2012
(r237460)
@@ -678,9 +678,9 @@ tw_osl_complete_io(struct tw_cl_req_hand
ccb->ccb_h.status = CAM_REQ_CMP;
else {
if (req_pkt->status & TW_CL_ERR_REQ_INVALID_TARGET)
-   ccb->ccb_h.status |= CAM_TID_INVALID;
+   ccb->ccb_h.status |= CAM_SEL_TIMEOUT;
else if (req_pkt->status & TW_CL_ERR_REQ_INVALID_LUN)
-   ccb->ccb_h.status |= CAM_LUN_INVALID;
+   ccb->ccb_h.status |= CAM_DEV_NOT_THERE;
else if (req_pkt->status & TW_CL_ERR_REQ_SCSI_ERROR)
ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR;
else if (req_pkt->status & TW_CL_ERR_REQ_BUS_RESET)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r237463 - head/sys/dev/cxgbe

2012-06-22 Thread Navdeep Parhar
Author: np
Date: Fri Jun 22 22:59:42 2012
New Revision: 237463
URL: http://svn.freebsd.org/changeset/base/237463

Log:
  Do not allocate extra vectors when adapter is not TOE
  capable (or toecaps have been disallowed by the user).
  
  + one very minor unrelated cleanup in t4_sge.c

Modified:
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cFri Jun 22 22:50:50 2012
(r237462)
+++ head/sys/dev/cxgbe/t4_main.cFri Jun 22 22:59:42 2012
(r237463)
@@ -1308,10 +1308,12 @@ cfg_itype_and_nqueues(struct adapter *sc
iaq->nrxq10g = nrxq10g = t4_nrxq10g;
iaq->nrxq1g = nrxq1g = t4_nrxq1g;
 #ifdef TCP_OFFLOAD
-   iaq->nofldtxq10g = t4_nofldtxq10g;
-   iaq->nofldtxq1g = t4_nofldtxq1g;
-   iaq->nofldrxq10g = nofldrxq10g = t4_nofldrxq10g;
-   iaq->nofldrxq1g = nofldrxq1g = t4_nofldrxq1g;
+   if (is_offload(sc)) {
+   iaq->nofldtxq10g = t4_nofldtxq10g;
+   iaq->nofldtxq1g = t4_nofldtxq1g;
+   iaq->nofldrxq10g = nofldrxq10g = t4_nofldrxq10g;
+   iaq->nofldrxq1g = nofldrxq1g = t4_nofldrxq1g;
+   }
 #endif
 
for (itype = INTR_MSIX; itype; itype >>= 1) {
@@ -1380,7 +1382,8 @@ restart:
}
iaq->nrxq10g = min(n, nrxq10g);
 #ifdef TCP_OFFLOAD
-   iaq->nofldrxq10g = min(n, nofldrxq10g);
+   if (is_offload(sc))
+   iaq->nofldrxq10g = min(n, nofldrxq10g);
 #endif
}
 
@@ -1395,7 +1398,8 @@ restart:
}
iaq->nrxq1g = min(n, nrxq1g);
 #ifdef TCP_OFFLOAD
-   iaq->nofldrxq1g = min(n, nofldrxq1g);
+   if (is_offload(sc))
+   iaq->nofldrxq1g = min(n, nofldrxq1g);
 #endif
}
 
@@ -1408,7 +1412,8 @@ restart:
 */
iaq->nirq = iaq->nrxq10g = iaq->nrxq1g = 1;
 #ifdef TCP_OFFLOAD
-   iaq->nofldrxq10g = iaq->nofldrxq1g = 1;
+   if (is_offload(sc))
+   iaq->nofldrxq10g = iaq->nofldrxq1g = 1;
 #endif
 
 allocate:

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Fri Jun 22 22:50:50 2012(r237462)
+++ head/sys/dev/cxgbe/t4_sge.c Fri Jun 22 22:59:42 2012(r237463)
@@ -1031,7 +1031,7 @@ get_fl_payload(struct adapter *sc, struc
 static int
 t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0)
 {
-   struct sge_rxq *rxq = (void *)iq;
+   struct sge_rxq *rxq = iq_to_rxq(iq);
struct ifnet *ifp = rxq->ifp;
const struct cpl_rx_pkt *cpl = (const void *)(rss + 1);
 #ifdef INET
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r237350 - head/sys/dev/puc

2012-06-22 Thread Marcel Moolenaar

On Jun 20, 2012, at 8:10 PM, Max Khon wrote:
> 
> Modified: head/sys/dev/puc/puc_cfg.h
> ==
> --- head/sys/dev/puc/puc_cfg.hThu Jun 21 02:48:49 2012
> (r237349)
> +++ head/sys/dev/puc/puc_cfg.hThu Jun 21 03:10:48 2012
> (r237350)
> @@ -79,7 +79,7 @@ struct puc_cfg {
>   int8_t  ports;
>   int8_t  rid;/* Rid of first port */
>   int8_t  d_rid;  /* Delta rid of next ports */
> - int8_t  d_ofs;  /* Delta offset of next ports */
> + int16_t d_ofs;  /* Delta offset of next ports */
>   puc_config_f*config_function;
> };

The purpose of the uint8_t is to minimize wastage. For the uncommon
cases there's the config_function. Given that uint8_t has been adequate
for a very long time, I think it's fair to say that the MOXA devices
have an uncommon configuration and that you shouldn't pessimize the
common case by extending the type of d_ofs and as a side-effect add
padding before it *and* after it -- the structure was optimal for both
ILP32 and LP64.

Please revert the above change and handle the uncommonly large offset
by extending the existing moxa configuration file. It's the precedence
that should have been followed anyway.

Thanks,

-- 
Marcel Moolenaar
mar...@xcllnt.net


___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"