svn commit: r244607 - head/sys/dev/usb

2012-12-23 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Dec 23 10:21:01 2012
New Revision: 244607
URL: http://svnweb.freebsd.org/changeset/base/244607

Log:
  Fix regression issue after r244503.
  
  MFC after:1 week

Modified:
  head/sys/dev/usb/usb_msctest.c

Modified: head/sys/dev/usb/usb_msctest.c
==
--- head/sys/dev/usb/usb_msctest.c  Sun Dec 23 00:03:28 2012
(r244606)
+++ head/sys/dev/usb/usb_msctest.c  Sun Dec 23 10:21:01 2012
(r244607)
@@ -83,7 +83,7 @@ enum {
DIR_NONE,
 };
 
-#defineSCSI_MAX_LEN0x100
+#defineSCSI_MAX_LENMAX(0x100, BULK_SIZE)
 #defineSCSI_INQ_LEN0x24
 #defineSCSI_SENSE_LEN  0xFF
 
@@ -150,6 +150,7 @@ struct bbb_transfer {
usb_size_t data_rem;/* bytes */
usb_timeout_t data_timeout; /* ms */
usb_frlength_t actlen;  /* bytes */
+   usb_frlength_t buffer_size; /* bytes */
 
uint8_t cmd_len;/* bytes */
uint8_t dir;
@@ -192,7 +193,7 @@ static const struct usb_config bbb_confi
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
-   .bufsize = MAX(SCSI_MAX_LEN, BULK_SIZE),
+   .bufsize = SCSI_MAX_LEN,
.flags = {.proxy_buffer = 1,.short_xfer_ok = 1,},
.callback = &bbb_data_read_callback,
.timeout = 4 * USB_MS_HZ,   /* 4 seconds */
@@ -211,7 +212,7 @@ static const struct usb_config bbb_confi
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
-   .bufsize = BULK_SIZE,
+   .bufsize = SCSI_MAX_LEN,
.flags = {.ext_buffer = 1,.proxy_buffer = 1,},
.callback = &bbb_data_write_callback,
.timeout = 4 * USB_MS_HZ,   /* 4 seconds */
@@ -553,6 +554,8 @@ bbb_attach(struct usb_device *udev, uint
/* store pointer to DMA buffers */
sc->buffer = usbd_xfer_get_frame_buffer(
sc->xfer[ST_DATA_RD], 0);
+   sc->buffer_size =
+   usbd_xfer_max_len(sc->xfer[ST_DATA_RD]);
sc->cbw = usbd_xfer_get_frame_buffer(
sc->xfer[ST_COMMAND], 0);
sc->csw = usbd_xfer_get_frame_buffer(
@@ -833,8 +836,8 @@ usb_msc_eject(struct usb_device *udev, u
 * TCTMobile needs DIR_IN flag. To get it, we
 * supply a dummy data with the command.
 */
-   err = bbb_command_start(sc, DIR_IN, 0, &sc->buffer,
-   sizeof(sc->buffer), &scsi_tct_eject,
+   err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
+   sc->buffer_size, &scsi_tct_eject,
sizeof(scsi_tct_eject), USB_MS_HZ);
break;
default:
___
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: r244608 - head/usr.sbin/pkg

2012-12-23 Thread Matthew Seaman
Author: matthew (ports committer)
Date: Sun Dec 23 11:22:18 2012
New Revision: 244608
URL: http://svnweb.freebsd.org/changeset/base/244608

Log:
  Third time's the charm.  pkg -N output needs to go to stderr.
  
  Approved by:  bapt
  MFC after:2 weeks

Modified:
  head/usr.sbin/pkg/pkg.c

Modified: head/usr.sbin/pkg/pkg.c
==
--- head/usr.sbin/pkg/pkg.c Sun Dec 23 10:21:01 2012(r244607)
+++ head/usr.sbin/pkg/pkg.c Sun Dec 23 11:22:18 2012(r244608)
@@ -457,10 +457,8 @@ main(__unused int argc, char *argv[])
 * a system is configured to use pkg, don't bootstrap pkg
 * when that argument is given as argv[1].
 */
-   if ( argv[1] != NULL && strcmp(argv[1], "-N") == 0) {
-   printf("%s", "pkg is not installed\n");
-   exit(EXIT_FAILURE);
-   }
+   if ( argv[1] != NULL && strcmp(argv[1], "-N") == 0)
+   errx(EXIT_FAILURE, "pkg is not installed\n");
 
/*
 * Do not ask for confirmation if either of stdin or stdout is
___
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: r244627 - head/share/man/man9

2012-12-23 Thread Andriy Gapon
Author: avg
Date: Sun Dec 23 12:56:04 2012
New Revision: 244627
URL: http://svnweb.freebsd.org/changeset/base/244627

Log:
  lock.9: fix incorrect descriptions of LK_SHARED and LK_DOWNGRADE behavior
  
  Reviewed by:  attilio
  MFC after:5 days
  X-MFC after:  r243900

Modified:
  head/share/man/man9/lock.9

Modified: head/share/man/man9/lock.9
==
--- head/share/man/man9/lock.9  Sun Dec 23 12:46:28 2012(r244626)
+++ head/share/man/man9/lock.9  Sun Dec 23 12:56:04 2012(r244627)
@@ -148,7 +148,9 @@ Flags indicating what action is to be ta
 .Bl -tag -width ".Dv LK_CANRECURSE"
 .It Dv LK_SHARED
 Acquire a shared lock.
-If an exclusive lock is currently held, it will be downgraded.
+If an exclusive lock is currently held,
+.Dv EDEADLK
+will be returned.
 .It Dv LK_EXCLUSIVE
 Acquire an exclusive lock.
 If an exclusive lock is already held, and
@@ -158,7 +160,8 @@ is not set, the system will
 .It Dv LK_DOWNGRADE
 Downgrade exclusive lock to a shared lock.
 Downgrading a shared lock is not permitted.
-If an exclusive lock has been recursed, all references will be downgraded.
+If an exclusive lock has been recursed, the system will
+.Xr panic 9 .
 .It Dv LK_UPGRADE
 Upgrade a shared lock to an exclusive lock.
 If this call fails, the shared lock is lost.
___
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: r244629 - head

2012-12-23 Thread Andriy Gapon
Author: avg
Date: Sun Dec 23 13:04:04 2012
New Revision: 244629
URL: http://svnweb.freebsd.org/changeset/base/244629

Log:
  UPDATING: add a note about the clang+zfs+i386 stack overflow issue

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Sun Dec 23 13:04:00 2012(r244628)
+++ head/UPDATING   Sun Dec 23 13:04:04 2012(r244629)
@@ -26,6 +26,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20121223:
+   After switching to Clang as the default compiler some users of ZFS
+   on i386 systems started to experience stack overflow kernel panics.
+   Please consider using 'options KSTACK_PAGES=4' in such configurations.
+
 20121222:
GEOM_LABEL now mangles label names read from file system metadata.
Mangling affect labels containing spaces, non-printable characters,
___
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: r244628 - in head: contrib/llvm/include/llvm/MC contrib/llvm/lib/ExecutionEngine/RuntimeDyld contrib/llvm/lib/MC contrib/llvm/lib/Target/Mips contrib/llvm/lib/Target/Mips/InstPrinter co...

2012-12-23 Thread Dimitry Andric
Author: dim
Date: Sun Dec 23 13:04:00 2012
New Revision: 244628
URL: http://svnweb.freebsd.org/changeset/base/244628

Log:
  Upgrade our copy of llvm/clang to 3.2 release.
  
  Release notes for llvm:
  http://llvm.org/releases/3.2/docs/ReleaseNotes.html
  
  Release notes for clang:
  http://llvm.org/releases/3.2/tools/clang/docs/ReleaseNotes.html
  
  MFC after:2 weeks

Modified:
  head/contrib/llvm/include/llvm/MC/MCExpr.h
  head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
  head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
  head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
  head/contrib/llvm/lib/MC/MCExpr.cpp
  head/contrib/llvm/lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
  head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
  head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsBaseInfo.h
  head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
  head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsFixupKinds.h
  head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
  head/contrib/llvm/lib/Target/Mips/Mips64InstrInfo.td
  head/contrib/llvm/lib/Target/Mips/MipsCodeEmitter.cpp
  head/contrib/llvm/lib/Target/Mips/MipsISelLowering.cpp
  head/contrib/llvm/lib/Target/Mips/MipsInstrInfo.td
  head/contrib/llvm/lib/Target/Mips/MipsJITInfo.cpp
  head/contrib/llvm/lib/Target/Mips/MipsJITInfo.h
  head/contrib/llvm/lib/Target/Mips/MipsMCInstLower.cpp
  head/contrib/llvm/lib/Transforms/Scalar/SROA.cpp
  head/contrib/llvm/tools/clang/include/clang/Sema/Scope.h
  head/contrib/llvm/tools/clang/lib/Basic/Version.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp
  head/contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp
  head/contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp
  head/contrib/llvm/tools/clang/lib/Sema/IdentifierResolver.cpp
  head/lib/clang/include/clang/Basic/Version.inc
  head/usr.bin/clang/clang/clang.1
Directory Properties:
  head/contrib/llvm/   (props changed)
  head/contrib/llvm/tools/clang/   (props changed)

Modified: head/contrib/llvm/include/llvm/MC/MCExpr.h
==
--- head/contrib/llvm/include/llvm/MC/MCExpr.h  Sun Dec 23 12:56:04 2012
(r244627)
+++ head/contrib/llvm/include/llvm/MC/MCExpr.h  Sun Dec 23 13:04:00 2012
(r244628)
@@ -197,7 +197,11 @@ public:
 VK_Mips_GOT_PAGE,
 VK_Mips_GOT_OFST,
 VK_Mips_HIGHER,
-VK_Mips_HIGHEST
+VK_Mips_HIGHEST,
+VK_Mips_GOT_HI16,
+VK_Mips_GOT_LO16,
+VK_Mips_CALL_HI16,
+VK_Mips_CALL_LO16
   };
 
 private:

Modified: head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
==
--- head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp   Sun Dec 
23 12:56:04 2012(r244627)
+++ head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp   Sun Dec 
23 13:04:00 2012(r244628)
@@ -346,7 +346,7 @@ uint8_t *RuntimeDyldImpl::createStubFunc
 uint32_t *StubAddr = (uint32_t*)Addr;
 *StubAddr = 0xe51ff004; // ldr pc,
 return (uint8_t*)++StubAddr;
-  } else if (Arch == Triple::mipsel) {
+  } else if (Arch == Triple::mipsel || Arch == Triple::mips) {
 uint32_t *StubAddr = (uint32_t*)Addr;
 // 0:   3c19lui t9,%hi(addr).
 // 4:   2739addiu   t9,t9,%lo(addr).

Modified: head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
==
--- head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Sun Dec 23 12:56:04 2012(r244627)
+++ head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Sun Dec 23 13:04:00 2012(r244628)
@@ -676,7 +676,8 @@ void RuntimeDyldELF::processRelocationRe
 RelType, 0);
   Section.StubOffset += getMaxStubSize();
 }
-  } else if (Arch == Triple::mipsel && RelType == ELF::R_MIPS_26) {
+  } else if ((Arch == Triple::mipsel || Arch == Triple::mips) &&
+ RelType == ELF::R_MIPS_26) {
 // This is an Mips branch relocation, need to use a stub function.
 DEBUG(dbgs() << "\t\tThis is a Mips branch relocation.");
 SectionEntry &Section = Sections[Rel.SectionID];

Modified: head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
==
--- head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h Sun Dec 
23 12:56:04 2012(r244627)
+++ head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h Sun Dec 
23 13:04:00 2012(r244628)
@@ -168,7 +168,7 @@ protected:
   inline unsigned getMaxStubSize() {
 if (Arch == Triple::arm || Arch == Triple::thumb)
   return 8; // 32-bit instruction and 32-bit address
-else if (Arch == Triple::mipsel)
+else if (Arch

Re: svn commit: r244605 - head/usr.sbin/gssd

2012-12-23 Thread Rick Macklem
Benjamin Kaduk wrote:
> Hi Rick,
> 
> 
> Thanks for all this -- it's good stuff to have.
> 
> 
> On Sat, Dec 22, 2012 at 6:34 PM, Rick Macklem < rmack...@freebsd.org >
> wrote:
> 
> 
> Author: rmacklem
> Date: Sat Dec 22 23:34:28 2012
> New Revision: 244605
> URL: http://svnweb.freebsd.org/changeset/base/244605
> 
> Log:
> Document the new gssd daemon options added by r244604.
> This is a content change.
> 
> MFC after: 2 weeks
> 
> Modified:
> head/usr.sbin/gssd/gssd.8
> 
> Modified: head/usr.sbin/gssd/gssd.8
> ==
> --- head/usr.sbin/gssd/gssd.8 Sat Dec 22 23:21:17 2012 (r244604)
> +++ head/usr.sbin/gssd/gssd.8 Sat Dec 22 23:34:28 2012 (r244605)
> @@ -46,6 +49,29 @@ Run in debug mode.
> In this mode,
> .Nm
> will not fork when it starts.
> +.It Fl s Ar dir-list
> +Look for an appropriate credential cache file in this list of
> directories.
> +The list should be full pathnames from root, separated by ':'
> characters.
> +Usually this list will simply be "/tmp".
> +Without this option, the
> +.Nm
> +daemon assumes that the credential cache file is called
> /tmp/krb5cc_,
> +where  is the effective uid for the RPC caller.
> +.It Fl c Ar file-substring
> +Set a file-substring for the credential cache file names.
> +Only files with this substring embedded in their names will be
> +selected as candidates when the
> +.Fl s
> +has been specified.
> 
> 
> 
> This grammar seems a bit fishy ("when the -s has been specified");
> "when -s has been specified" or
> "when a search directory has been specified with -s" would probably be
> better.
> 
Sure.

> 
> +If not specified, it defaults to "krb5cc_".
> +.It Fl r Ar preferred-realm
> +Set a preferred Kerberos realm for the search of the directory list
> for
> 
> 
> 
> "Directory list" sounds like there are multiple directories involved,
> perhaps
> "directory listing" is better?
> 
It can be a list, for example: "/tmp:/var/tmp". Personally, I thought
having a list was overkill, but during the email discussion with the people
that reported the problem, it was felt that a list might be needed (and
the Linux gssd does take a list of directories).

However, it probably isn't clear that the preferred realm applies to
the principal names in the credential cache file entries being examined.

> 
> +a credentials cache file.
> +When set, files with TGT credentials for this realm will be selected
> over
> +other credential files.
> +This option is only meaningful when the
> +.Fl s
> +option has been specified.
> 
> 
> 
> There is something of a movement among the doc types to remove
> "redundant" words,
> making this "when -s has been specified", but others (some quite
> senior) do not approve
> of this "useless churn". Might not be worth changing now, but for new
> content, something
> to consider.
> 
> 
> Let me know if I should make the patch.
> 
Sure, if you'd like to. Otherwise, I'll try and come up with a fixup.

Thanks for pointing this out, rick

> 
> -Ben Kaduk
___
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: r244604 - head/usr.sbin/gssd

2012-12-23 Thread Stefan Farfeleder
On Sat, Dec 22, 2012 at 11:21:17PM +, Rick Macklem wrote:
> Author: rmacklem
> Date: Sat Dec 22 23:21:17 2012
> New Revision: 244604
> URL: http://svnweb.freebsd.org/changeset/base/244604
> 
> Log:
>   It was reported via email that some sshds create kerberos
>   credential cache files with names other than /tmp/krb5cc_.
>   The gssd daemon does not know how to find these credential caches.
>   This patch implements a new option "-s" that does a search for
>   credential cache files, using roughly the same algorithm as the
>   gssd daemon for Linux uses. The gssd behaviour is only changed
>   if the new "-s" option is specified. It also implements two other
>   new options related to the "-s" option.
>   
>   Reported by:Piete.Brooks at cl.cam.ac.uk, Herbert Poeckl
>   Tested by:  Herbert Poeckl (admin at ist.tugraz.at), Illias A. Marinos
>   MFC after:  2 weeks
> 
> Modified:
>   head/usr.sbin/gssd/gssd.c

I think you forgot to add -lkrb5 to the Makefile.

Stefan
___
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: r244631 - head/sys/cddl/dev/dtrace

2012-12-23 Thread Ryan Stone
Author: rstone
Date: Sun Dec 23 15:50:37 2012
New Revision: 244631
URL: http://svnweb.freebsd.org/changeset/base/244631

Log:
  Correct a series of errors in the hand-rolled locking for drace_debug.c:
  
  - Use spinlock_enter()/spinlock_exit() to prevent a thread holding a
debug lock from being preempted to prevent other threads waiting
on that lock from starvation.
  
  - Handle the possibility of CPU migration in between the fetch of curcpu
and the call to spinlock_enter() by saving curcpu in a local variable.
  
  - Use memory barriers to prevent reordering of loads and stores of the
data protected by the lock outside of the critical section
  
  - Eliminate false sharing of the locks by moving them into the structures
that they protect and aligning them to a cacheline boundary.
  
  - Record the owning thread in the lock to make debugging future problems
easier.
  
  Reviewed by:  rpaulo (initial version)
  MFC after:2 weeks

Modified:
  head/sys/cddl/dev/dtrace/dtrace_debug.c

Modified: head/sys/cddl/dev/dtrace/dtrace_debug.c
==
--- head/sys/cddl/dev/dtrace/dtrace_debug.c Sun Dec 23 14:19:04 2012
(r244630)
+++ head/sys/cddl/dev/dtrace/dtrace_debug.c Sun Dec 23 15:50:37 2012
(r244631)
@@ -33,11 +33,10 @@
 
 #include 
 
-#definedtrace_cmpset_long  atomic_cmpset_long
-
 #define DTRACE_DEBUG_BUFR_SIZE (32 * 1024)
 
 struct dtrace_debug_data {
+   uintptr_t lock __aligned(CACHE_LINE_SIZE);
char bufr[DTRACE_DEBUG_BUFR_SIZE];
char *first;
char *last;
@@ -46,20 +45,22 @@ struct dtrace_debug_data {
 
 static char dtrace_debug_bufr[DTRACE_DEBUG_BUFR_SIZE];
 
-static volatile u_long dtrace_debug_flag[MAXCPU];
-
 static void
 dtrace_debug_lock(int cpu)
 {
-   while (dtrace_cmpset_long(&dtrace_debug_flag[cpu], 0, 1) == 0)
-   /* Loop until the lock is obtained. */
+uintptr_t tid;
+
+   tid = (uintptr_t)curthread;
+   spinlock_enter();
+   while (atomic_cmpset_acq_ptr(&dtrace_debug_data[cpu].lock, 0, tid) == 
0)/* Loop until the lock is obtained. */
;
 }
 
 static void
 dtrace_debug_unlock(int cpu)
 {
-   dtrace_debug_flag[cpu] = 0;
+   atomic_store_rel_ptr(&dtrace_debug_data[cpu].lock, 0);
+   spinlock_exit();
 }
 
 static void
@@ -151,10 +152,11 @@ dtrace_debug_output(void)
  */
 
 static __inline void
-dtrace_debug__putc(char c)
+dtrace_debug__putc(int cpu, char c)
 {
-   struct dtrace_debug_data *d = &dtrace_debug_data[curcpu];
+   struct dtrace_debug_data *d;
 
+   d = &dtrace_debug_data[cpu];
*d->next++ = c;
 
if (d->next == d->last)
@@ -172,24 +174,30 @@ dtrace_debug__putc(char c)
 static void __used
 dtrace_debug_putc(char c)
 {
-   dtrace_debug_lock(curcpu);
+   int cpu;
+
+   cpu = curcpu;
+   dtrace_debug_lock(cpu);
 
-   dtrace_debug__putc(c);
+   dtrace_debug__putc(cpu, c);
 
-   dtrace_debug_unlock(curcpu);
+   dtrace_debug_unlock(cpu);
 }
 
 static void __used
 dtrace_debug_puts(const char *s)
 {
-   dtrace_debug_lock(curcpu);
+   int cpu;
+   
+   cpu = curcpu;
+   dtrace_debug_lock(cpu);
 
while (*s != '\0')
-   dtrace_debug__putc(*s++);
+   dtrace_debug__putc(cpu, *s++);
 
-   dtrace_debug__putc('\0');
+   dtrace_debug__putc(cpu, '\0');
 
-   dtrace_debug_unlock(curcpu);
+   dtrace_debug_unlock(cpu);
 }
 
 /*
@@ -219,7 +227,7 @@ dtrace_debug_ksprintn(char *nbuf, uintma
 #define MAXNBUF (sizeof(intmax_t) * NBBY + 1)
 
 static void
-dtrace_debug_vprintf(const char *fmt, va_list ap)
+dtrace_debug_vprintf(int cpu, const char *fmt, va_list ap)
 {
char nbuf[MAXNBUF];
const char *p, *percent, *q;
@@ -243,10 +251,10 @@ dtrace_debug_vprintf(const char *fmt, va
width = 0;
while ((ch = (u_char)*fmt++) != '%' || stop) {
if (ch == '\0') {
-   dtrace_debug__putc('\0');
+   dtrace_debug__putc(cpu, '\0');
return;
}
-   dtrace_debug__putc(ch);
+   dtrace_debug__putc(cpu, ch);
}
percent = fmt - 1;
qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
@@ -266,7 +274,7 @@ reswitch:   switch (ch = (u_char)*fmt++) {
ladjust = 1;
goto reswitch;
case '%':
-   dtrace_debug__putc(ch);
+   dtrace_debug__putc(cpu, ch);
break;
case '*':
if (!dot) {
@@ -301,7 +309,7 @@ reswitch:   switch (ch = (u_char)*fmt++) {
num = (u_int)va_arg(ap, int);
p = va_arg(ap, char *);
 

svn commit: r244633 - head/sys/netpfil/ipfw

2012-12-23 Thread Alexander V. Chernikov
Author: melifaro
Date: Sun Dec 23 16:28:18 2012
New Revision: 244633
URL: http://svnweb.freebsd.org/changeset/base/244633

Log:
  Use unified IP_FW_ARG_TABLEARG() macro for most tablearg checks.
  Log real value instead of IP_FW_TABLEARG (65535) in ipfw_log().
  
  Noticed by:   Vitaliy Tokarenko 
  MFC after:2 weeks

Modified:
  head/sys/netpfil/ipfw/ip_fw2.c
  head/sys/netpfil/ipfw/ip_fw_dynamic.c
  head/sys/netpfil/ipfw/ip_fw_log.c
  head/sys/netpfil/ipfw/ip_fw_private.h

Modified: head/sys/netpfil/ipfw/ip_fw2.c
==
--- head/sys/netpfil/ipfw/ip_fw2.c  Sun Dec 23 16:11:43 2012
(r244632)
+++ head/sys/netpfil/ipfw/ip_fw2.c  Sun Dec 23 16:28:18 2012
(r244633)
@@ -1850,8 +1850,7 @@ do {  
\
 
case O_TAG: {
struct m_tag *mtag;
-   uint32_t tag = (cmd->arg1 == IP_FW_TABLEARG) ?
-   tablearg : cmd->arg1;
+   uint32_t tag = IP_FW_ARG_TABLEARG(cmd->arg1);
 
/* Packet is already tagged with this tag? */
mtag = m_tag_locate(m, MTAG_IPFW, tag, NULL);
@@ -1930,8 +1929,7 @@ do {  
\
 
case O_TAGGED: {
struct m_tag *mtag;
-   uint32_t tag = (cmd->arg1 == IP_FW_TABLEARG) ?
-   tablearg : cmd->arg1;
+   uint32_t tag = IP_FW_ARG_TABLEARG(cmd->arg1);
 
if (cmdlen == 1) {
match = m_tag_locate(m, MTAG_IPFW,
@@ -2069,8 +2067,7 @@ do {  
\
case O_PIPE:
case O_QUEUE:
set_match(args, f_pos, chain);
-   args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) 
?
-   tablearg : cmd->arg1;
+   args->rule.info = IP_FW_ARG_TABLEARG(cmd->arg1);
if (cmd->opcode == O_PIPE)
args->rule.info |= IPFW_IS_PIPE;
if (V_fw_one_pass)
@@ -2090,8 +2087,7 @@ do {  
\
retval = (cmd->opcode == O_DIVERT) ?
IP_FW_DIVERT : IP_FW_TEE;
set_match(args, f_pos, chain);
-   args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) 
?
-   tablearg : cmd->arg1;
+   args->rule.info = IP_FW_ARG_TABLEARG(cmd->arg1);
break;
 
case O_COUNT:
@@ -2109,8 +2105,7 @@ do {  
\
(uintptr_t)f->x_next == chain->id) {
f_pos = (uintptr_t)f->next_rule;
} else {
-   int i = (cmd->arg1 == IP_FW_TABLEARG) ?
-   tablearg : cmd->arg1;
+   int i = IP_FW_ARG_TABLEARG(cmd->arg1);
/* make sure we do not jump backward */
if (i <= f->rulenum)
i = f->rulenum + 1;
@@ -2215,9 +2210,8 @@ do {  
\
(uintptr_t)f->x_next == chain->id) {
f_pos = (uintptr_t)f->next_rule;
} else {
-   jmpto = (cmd->arg1 ==
-   IP_FW_TABLEARG) ? tablearg:
-   cmd->arg1;
+   jmpto = IP_FW_ARG_TABLEARG(
+   cmd->arg1);
f_pos = ipfw_find_rule(chain,
jmpto, 0);
/* update the cache */
@@ -2337,8 +2331,7 @@ do {  
\
case O_NETGRAPH:
case O_NGTEE:
set_match(args, f_pos, chain);
-   args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) 
?
-   tablearg : cmd->arg1;
+  

svn commit: r244634 - head/sys/netpfil/ipfw

2012-12-23 Thread Alexander V. Chernikov
Author: melifaro
Date: Sun Dec 23 18:35:42 2012
New Revision: 244634
URL: http://svnweb.freebsd.org/changeset/base/244634

Log:
  Add parentheses to IP_FW_ARG_TABLEARG() definition.
  
  Suggested by: glebius
  MFC with: r244633

Modified:
  head/sys/netpfil/ipfw/ip_fw_private.h

Modified: head/sys/netpfil/ipfw/ip_fw_private.h
==
--- head/sys/netpfil/ipfw/ip_fw_private.h   Sun Dec 23 16:28:18 2012
(r244633)
+++ head/sys/netpfil/ipfw/ip_fw_private.h   Sun Dec 23 18:35:42 2012
(r244634)
@@ -259,7 +259,7 @@ struct sockopt; /* used by tcp_var.h */
(_cntr)->bcnt = 0;  \
} while (0)
 
-#defineIP_FW_ARG_TABLEARG(a)   ((a) == IP_FW_TABLEARG) ? tablearg : (a)
+#defineIP_FW_ARG_TABLEARG(a)   (((a) == IP_FW_TABLEARG) ? tablearg : 
(a))
 /*
  * The lock is heavily used by ip_fw2.c (the main file) and ip_fw_nat.c
  * so the variable and the macros must be here.
___
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: r244635 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2012-12-23 Thread Andriy Gapon
Author: avg
Date: Sun Dec 23 19:58:41 2012
New Revision: 244635
URL: http://svnweb.freebsd.org/changeset/base/244635

Log:
  zfs: solaris doesn't have KM_ZERO, kmem_zalloc should be used instead
  
  To do:remove KM_ZERO declaration
  Pointyhat to: avg (for mindlessly using the pseudo-flag)
  MFC after:instantly (to fix stable/8 build)

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c   Sun Dec 23 
18:35:42 2012(r244634)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c   Sun Dec 23 
19:58:41 2012(r244635)
@@ -3799,7 +3799,7 @@ spa_generate_rootconf(const char *name)
nvlist_lookup_uint64_array(best_cfg, ZPOOL_CONFIG_HOLE_ARRAY,
&holes, &nholes);
 
-   tops = kmem_alloc(nchildren * sizeof(void *), KM_SLEEP | KM_ZERO);
+   tops = kmem_zalloc(nchildren * sizeof(void *), KM_SLEEP);
for (i = 0; i < nchildren; i++) {
if (i >= count)
break;

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sun Dec 
23 18:35:42 2012(r244634)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sun Dec 
23 19:58:41 2012(r244635)
@@ -300,8 +300,8 @@ resize_configs(nvlist_t ***configs, uint
 
if (id < *count)
return;
-   new_configs = kmem_alloc((id + 1) * sizeof(nvlist_t *),
-   KM_SLEEP | KM_ZERO);
+   new_configs = kmem_zalloc((id + 1) * sizeof(nvlist_t *),
+   KM_SLEEP);
for (i = 0; i < *count; i++)
new_configs[i] = (*configs)[i];
if (*configs != 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: r244638 - head/usr.sbin/gssd

2012-12-23 Thread Rick Macklem
Author: rmacklem
Date: Sun Dec 23 20:12:57 2012
New Revision: 244638
URL: http://svnweb.freebsd.org/changeset/base/244638

Log:
  Fix the Makefile so it can build gssd.c after r244604.
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/gssd/Makefile

Modified: head/usr.sbin/gssd/Makefile
==
--- head/usr.sbin/gssd/Makefile Sun Dec 23 20:03:53 2012(r244637)
+++ head/usr.sbin/gssd/Makefile Sun Dec 23 20:12:57 2012(r244638)
@@ -7,8 +7,8 @@ SRCS=   gssd.c gssd.h gssd_svc.c gssd_xdr.
 CFLAGS+= -I.
 WARNS?= 1
 
-DPADD= ${LIBGSSAPI}
-LDADD= -lgssapi
+DPADD= ${LIBGSSAPI} ${LIBKRB5} ${LIBHX509} ${LIBASN1} ${LIBROKEN} 
${LIBCOM_ERR} ${LIBCRYPT} ${LIBCRYPTO}
+LDADD= -lgssapi -lkrb5 -lhx509 -lasn1 -lroken -lcom_err -lcrypt -lcrypto
 
 CLEANFILES= gssd_svc.c gssd.h
 
___
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: r244608 - head/usr.sbin/pkg

2012-12-23 Thread Pawel Jakub Dawidek
On Sun, Dec 23, 2012 at 11:22:18AM +, Matthew Seaman wrote:
> Author: matthew (ports committer)
> Date: Sun Dec 23 11:22:18 2012
> New Revision: 244608
> URL: http://svnweb.freebsd.org/changeset/base/244608
> 
> Log:
>   Third time's the charm.  pkg -N output needs to go to stderr.
>   
>   Approved by:bapt
>   MFC after:  2 weeks
> 
> Modified:
>   head/usr.sbin/pkg/pkg.c
> 
> Modified: head/usr.sbin/pkg/pkg.c
> ==
> --- head/usr.sbin/pkg/pkg.c   Sun Dec 23 10:21:01 2012(r244607)
> +++ head/usr.sbin/pkg/pkg.c   Sun Dec 23 11:22:18 2012(r244608)
> @@ -457,10 +457,8 @@ main(__unused int argc, char *argv[])
>* a system is configured to use pkg, don't bootstrap pkg
>* when that argument is given as argv[1].
>*/
> - if ( argv[1] != NULL && strcmp(argv[1], "-N") == 0) {
> - printf("%s", "pkg is not installed\n");
> - exit(EXIT_FAILURE);
> - }
> + if ( argv[1] != NULL && strcmp(argv[1], "-N") == 0)
> + errx(EXIT_FAILURE, "pkg is not installed\n");

How about removing space after 'if (' and redundant '\n'?

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpG3jsEAoxv9.pgp
Description: PGP signature


Re: svn commit: r244604 - head/usr.sbin/gssd

2012-12-23 Thread Rick Macklem
Stefan Farfeleder wrote:
> On Sat, Dec 22, 2012 at 11:21:17PM +, Rick Macklem wrote:
> > Author: rmacklem
> > Date: Sat Dec 22 23:21:17 2012
> > New Revision: 244604
> > URL: http://svnweb.freebsd.org/changeset/base/244604
> >
> > Log:
> >   It was reported via email that some sshds create kerberos
> >   credential cache files with names other than /tmp/krb5cc_.
> >   The gssd daemon does not know how to find these credential caches.
> >   This patch implements a new option "-s" that does a search for
> >   credential cache files, using roughly the same algorithm as the
> >   gssd daemon for Linux uses. The gssd behaviour is only changed
> >   if the new "-s" option is specified. It also implements two other
> >   new options related to the "-s" option.
> >
> >   Reported by: Piete.Brooks at cl.cam.ac.uk, Herbert Poeckl
> >   Tested by: Herbert Poeckl (admin at ist.tugraz.at), Illias A.
> >   Marinos
> >   MFC after: 2 weeks
> >
> > Modified:
> >   head/usr.sbin/gssd/gssd.c
> 
> I think you forgot to add -lkrb5 to the Makefile.
> 
Oops, I forgot to commit the Makefile fix. It has been committed now.
(which for wonderful Kerberos, includes a half dozen extra libraries;-)

Thanks for pointing it out, rick

> Stefan
___
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: r244639 - head/usr.sbin/pkg

2012-12-23 Thread Matthew Seaman
Author: matthew (ports committer)
Date: Sun Dec 23 20:39:03 2012
New Revision: 244639
URL: http://svnweb.freebsd.org/changeset/base/244639

Log:
  Remove extraneous space and new-line.
  
  Submitted by: pjd, gcooper
  Approved by:  bapt
  MFC after:2 weeks

Modified:
  head/usr.sbin/pkg/pkg.c

Modified: head/usr.sbin/pkg/pkg.c
==
--- head/usr.sbin/pkg/pkg.c Sun Dec 23 20:12:57 2012(r244638)
+++ head/usr.sbin/pkg/pkg.c Sun Dec 23 20:39:03 2012(r244639)
@@ -457,8 +457,8 @@ main(__unused int argc, char *argv[])
 * a system is configured to use pkg, don't bootstrap pkg
 * when that argument is given as argv[1].
 */
-   if ( argv[1] != NULL && strcmp(argv[1], "-N") == 0)
-   errx(EXIT_FAILURE, "pkg is not installed\n");
+   if (argv[1] != NULL && strcmp(argv[1], "-N") == 0)
+   errx(EXIT_FAILURE, "pkg is not installed");
 
/*
 * Do not ask for confirmation if either of stdin or stdout is
___
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: r244640 - in head/contrib/llvm/tools/clang/lib: Basic Driver

2012-12-23 Thread Andrew Turner
Author: andrew
Date: Sun Dec 23 21:41:39 2012
New Revision: 244640
URL: http://svnweb.freebsd.org/changeset/base/244640

Log:
  Pull in r170096 from upstream clang trunk:
  
Initial support for FreeBSD on ARM.

Modified:
  head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains.h
  head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp

Modified: head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
==
--- head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp Sun Dec 23 20:39:03 
2012(r244639)
+++ head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp Sun Dec 23 21:41:39 
2012(r244640)
@@ -3078,7 +3078,9 @@ public:
 // name.
 if (Name == "apcs-gnu") {
   DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
-  SizeType = UnsignedLong;
+  // size_t is unsigned int on FreeBSD.
+  if (getTriple().getOS() != llvm::Triple::FreeBSD)
+SizeType = UnsignedLong;
 
   // Revert to using SignedInt on apcs-gnu to comply with existing 
behaviour.
   WCharType = SignedInt;

Modified: head/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp
==
--- head/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp Sun Dec 23 
20:39:03 2012(r244639)
+++ head/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp Sun Dec 23 
21:41:39 2012(r244640)
@@ -1667,6 +1667,19 @@ Tool &FreeBSD::SelectTool(const Compilat
   return *T;
 }
 
+bool FreeBSD::UseSjLjExceptions() const {
+  // FreeBSD uses SjLj exceptions on ARM oabi.
+  switch (getTriple().getEnvironment()) {
+  case llvm::Triple::GNUEABI:
+  case llvm::Triple::EABI:
+return false;
+
+  default:
+return (getTriple().getArch() == llvm::Triple::arm ||
+getTriple().getArch() == llvm::Triple::thumb);
+  }
+}
+
 /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
 
 NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple, const ArgList 
&Args)

Modified: head/contrib/llvm/tools/clang/lib/Driver/ToolChains.h
==
--- head/contrib/llvm/tools/clang/lib/Driver/ToolChains.h   Sun Dec 23 
20:39:03 2012(r244639)
+++ head/contrib/llvm/tools/clang/lib/Driver/ToolChains.h   Sun Dec 23 
21:41:39 2012(r244640)
@@ -468,6 +468,7 @@ public:
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
+  virtual bool UseSjLjExceptions() const;
 };
 
 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {

Modified: head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp
==
--- head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp  Sun Dec 23 20:39:03 
2012(r244639)
+++ head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp  Sun Dec 23 21:41:39 
2012(r244640)
@@ -665,6 +665,11 @@ static StringRef getARMFloatABI(const Dr
   break;
 }
 
+case llvm::Triple::FreeBSD:
+  // FreeBSD defaults to soft float
+  FloatABI = "soft";
+  break;
+
 default:
   switch(Triple.getEnvironment()) {
   case llvm::Triple::GNUEABIHF:
@@ -5422,6 +5427,17 @@ void freebsd::Assemble::ConstructJob(Com
  LastPICArg->getOption().matches(options::OPT_fpie))) {
   CmdArgs.push_back("-KPIC");
 }
+  } else if (getToolChain().getArch() == llvm::Triple::arm ||
+ getToolChain().getArch() == llvm::Triple::thumb) {
+CmdArgs.push_back("-mfpu=softvfp");
+switch(getToolChain().getTriple().getEnvironment()) {
+case llvm::Triple::GNUEABI:
+case llvm::Triple::EABI:
+  break;
+
+default:
+  CmdArgs.push_back("-matpcs");
+}
   }
 
   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
___
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: r244642 - head/release/picobsd/build

2012-12-23 Thread Luigi Rizzo
Author: luigi
Date: Sun Dec 23 22:41:54 2012
New Revision: 244642
URL: http://svnweb.freebsd.org/changeset/base/244642

Log:
  enable building picobsd with CC instead of CLANG

Modified:
  head/release/picobsd/build/picobsd

Modified: head/release/picobsd/build/picobsd
==
--- head/release/picobsd/build/picobsd  Sun Dec 23 22:13:53 2012
(r244641)
+++ head/release/picobsd/build/picobsd  Sun Dec 23 22:41:54 2012
(r244642)
@@ -445,6 +445,8 @@ do_kernel() {   # OK
${BINMAKE} ${o_par} KERNCONF=${l_kernconf}  \
-v -f ${PICO_TREE}/build/Makefile.conf ) || \
fail $? missing_kernel
+#  -DWITHOUT_CLANG_IS_CC   \
+
 }
 
 # Populate the variable part of the floppy filesystem. Must be done before
@@ -973,6 +975,7 @@ set_build_parameters() {
 if [ ${OSVERSION} -ge 500035 ] ; then
export MAKEOBJDIRPREFIX=${l_objtree}
export TARGET_ARCH=${o_arch} TARGET=${o_arch}
+   export WITHOUT_CLANG_IS_CC=1
# XXX why change machine_arch ?
#-- export MACHINE_ARCH=`uname -m` MACHINE=`uname -m`
# export CWARNFLAGS="-Wextra -Wno-sign-compare 
-Wno-missing-field-initializers"
___
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: r244643 - in head/sys: fs/devfs kern sys

2012-12-23 Thread Konstantin Belousov
Author: kib
Date: Sun Dec 23 22:43:27 2012
New Revision: 244643
URL: http://svnweb.freebsd.org/changeset/base/244643

Log:
  Do not force a writer to the devfs file to drain the buffer writes.
  
  Requested and tested by:  Ian Lepore 
  MFC after:2 weeks

Modified:
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/kern/sys_generic.c
  head/sys/sys/file.h

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Sun Dec 23 22:41:54 2012
(r244642)
+++ head/sys/fs/devfs/devfs_vnops.c Sun Dec 23 22:43:27 2012
(r244643)
@@ -1049,6 +1049,7 @@ devfs_open(struct vop_open_args *ap)
int error, ref, vlocked;
struct cdevsw *dsw;
struct file *fpop;
+   struct mtx *mtxp;
 
if (vp->v_type == VBLK)
return (ENXIO);
@@ -1099,6 +1100,16 @@ devfs_open(struct vop_open_args *ap)
 #endif
if (fp->f_ops == &badfileops)
finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
+   mtxp = mtx_pool_find(mtxpool_sleep, fp);
+
+   /*
+* Hint to the dofilewrite() to not force the buffer draining
+* on the writer to the file.  Most likely, the write would
+* not need normal buffers.
+*/
+   mtx_lock(mtxp);
+   fp->f_vnread_flags |= FDEVFS_VNODE;
+   mtx_unlock(mtxp);
return (error);
 }
 

Modified: head/sys/kern/sys_generic.c
==
--- head/sys/kern/sys_generic.c Sun Dec 23 22:41:54 2012(r244642)
+++ head/sys/kern/sys_generic.c Sun Dec 23 22:43:27 2012(r244643)
@@ -536,7 +536,8 @@ dofilewrite(td, fd, fp, auio, offset, fl
ktruio = cloneuio(auio);
 #endif
cnt = auio->uio_resid;
-   if (fp->f_type == DTYPE_VNODE)
+   if (fp->f_type == DTYPE_VNODE &&
+   (fp->f_vnread_flags & FDEVFS_VNODE) == 0)
bwillwrite();
if ((error = fo_write(fp, auio, td->td_ucred, flags, td))) {
if (auio->uio_resid != cnt && (error == ERESTART ||

Modified: head/sys/sys/file.h
==
--- head/sys/sys/file.h Sun Dec 23 22:41:54 2012(r244642)
+++ head/sys/sys/file.h Sun Dec 23 22:43:27 2012(r244643)
@@ -178,7 +178,8 @@ struct file {
 #definef_advicef_vnun.fvn_advice
 
 #defineFOFFSET_LOCKED   0x1
-#defineFOFFSET_LOCK_WAITING 0x2 
+#defineFOFFSET_LOCK_WAITING 0x2
+#defineFDEVFS_VNODE 0x4
 
 #endif /* _KERNEL || _WANT_FILE */
 
___
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: r244644 - head/tools/tools/netrate/netreceive

2012-12-23 Thread Luigi Rizzo
Author: luigi
Date: Sun Dec 23 23:03:45 2012
New Revision: 244644
URL: http://svnweb.freebsd.org/changeset/base/244644

Log:
  small cleanup of the code, and add support for running multiple
  threads on each socket.

Modified:
  head/tools/tools/netrate/netreceive/netreceive.c

Modified: head/tools/tools/netrate/netreceive/netreceive.c
==
--- head/tools/tools/netrate/netreceive/netreceive.cSun Dec 23 22:43:27 
2012(r244643)
+++ head/tools/tools/netrate/netreceive/netreceive.cSun Dec 23 23:03:45 
2012(r244644)
@@ -43,27 +43,158 @@
 
 #define MAXSOCK 20
 
+#include 
+#include 
+#include   /* clock_getres() */
+
+static int round_to(int n, int l)
+{
+   return ((n + l - 1)/l)*l;
+}
+
+/*
+ * Each socket uses multiple threads so the receiver is
+ * more efficient. A collector thread runs the stats.
+ */
+struct td_desc {
+   pthread_t td_id;
+   uint64_t count; /* rx counter */
+   int fd;
+   char *buf;
+   int buflen;
+};
+
 static void
 usage(void)
 {
 
-   fprintf(stderr, "netreceive [port]\n");
+   fprintf(stderr, "netreceive port [nthreads]\n");
exit(-1);
 }
 
+static __inline void
+timespec_add(struct timespec *tsa, struct timespec *tsb)
+{
+
+tsa->tv_sec += tsb->tv_sec;
+tsa->tv_nsec += tsb->tv_nsec;
+if (tsa->tv_nsec >= 10) {
+tsa->tv_sec++;
+tsa->tv_nsec -= 10;
+}
+}
+
+static __inline void
+timespec_sub(struct timespec *tsa, struct timespec *tsb)
+{
+
+tsa->tv_sec -= tsb->tv_sec;
+tsa->tv_nsec -= tsb->tv_nsec;
+if (tsa->tv_nsec < 0) {
+tsa->tv_sec--;
+tsa->tv_nsec += 10;
+}
+}
+
+static void *
+rx_body(void *data)
+{
+   struct td_desc *t = data;
+   struct pollfd fds;
+   int y;
+
+   fds.fd = t->fd;
+   fds.events = POLLIN;
+
+   for (;;) {
+   if (poll(&fds, 1, -1) < 0) 
+   perror("poll on thread");
+   if (!(fds.revents & POLLIN))
+   continue;
+   for (;;) {
+   y = recv(t->fd, t->buf, t->buflen, MSG_DONTWAIT);
+   if (y < 0)
+   break;
+   t->count++;
+   }
+   }
+   return NULL;
+}
+
+int
+make_threads(struct td_desc **tp, int *s, int nsock, int nthreads)
+{
+   int i, si, nt = nsock * nthreads;
+   int lb = round_to(nt * sizeof (struct td_desc *), 64);
+   int td_len = round_to(sizeof(struct td_desc), 64); // cache align
+   char *m = calloc(1, lb + td_len * nt);
+
+   printf("td len %d -> %d\n", (int)sizeof(struct td_desc) , td_len);
+   /* pointers plus the structs */
+   if (m == NULL) {
+   perror("no room for pointers!");
+   exit(1);
+   }
+   tp = (struct td_desc **)m;
+   m += lb;/* skip the pointers */
+   for (si = i = 0; i < nt; i++, m += td_len) {
+   tp[i] = (struct td_desc *)m;
+   tp[i]->fd = s[si];
+   if (++si == nsock)
+   si = 0;
+   if (pthread_create(&tp[i]->td_id, NULL, rx_body, tp[i])) {
+   perror("unable to create thread");
+   exit(1);
+   }
+   }
+}
+
+int
+main_thread(struct td_desc **tp, int nsock, int nthreads)
+{
+   uint64_t c0, c1;
+   struct timespec now, then, delta;
+   /* now the parent collects and prints results */
+   c0 = c1 = 0;
+   clock_gettime(CLOCK_REALTIME, &then);
+   fprintf(stderr, "start at %ld.%09ld\n", then.tv_sec, then.tv_nsec);
+   while (1) {
+   int i, nt = nsock * nthreads;
+   int64_t dn;
+   uint64_t pps;
+
+   if (poll(NULL, 0, 500) < 0) 
+   perror("poll");
+   c0 = 0;
+   for (i = 0; i < nt; i++) {
+   c0 += tp[i]->count;
+   }
+   dn = c0 - c1;
+   clock_gettime(CLOCK_REALTIME, &now);
+   delta = now;
+   timespec_sub(&delta, &then);
+   then = now;
+   pps = dn;
+   pps = (pps * 10) / (delta.tv_sec*10 + 
delta.tv_nsec + 1);
+   fprintf(stderr, "%d pkts in %ld.%09ld ns %ld pps\n",
+   (int)dn, delta.tv_sec, delta.tv_nsec, (long)pps);
+   c1 = c0;
+   }
+}
+
 int
 main(int argc, char *argv[])
 {
struct addrinfo hints, *res, *res0;
char *dummy, *packet;
int port;
-   int error, v, i;
+   int error, v, nthreads = 1;
+   struct td_desc **tp;
const char *cause = NULL;
int s[MAXSOCK];
-   struct pollfd fds[MAXSOCK];
int nsock;
 
-   if (argc != 2)
+   if (argc < 2)