svn commit: r333601 - head/sys/dev/hwpmc

2018-05-13 Thread Matt Macy
Author: mmacy
Date: Mon May 14 06:11:25 2018
New Revision: 333601
URL: https://svnweb.freebsd.org/changeset/base/333601

Log:
  hwpmc: don't reference domain index with no memory backing it
  
  On multi-socket the domain will be correctly set for a given CPU
  regardless of whether or not NUMA is enabled.
  
  Approved by:  sbruno

Modified:
  head/sys/dev/hwpmc/hwpmc_logging.c

Modified: head/sys/dev/hwpmc/hwpmc_logging.c
==
--- head/sys/dev/hwpmc/hwpmc_logging.c  Mon May 14 05:21:18 2018
(r333600)
+++ head/sys/dev/hwpmc/hwpmc_logging.c  Mon May 14 06:11:25 2018
(r333601)
@@ -63,8 +63,10 @@ __FBSDID("$FreeBSD$");
 
 #ifdef NUMA
 #define NDOMAINS vm_ndomains
+#define curdomain PCPU_GET(domain)
 #else
 #define NDOMAINS 1
+#define curdomain 0
 #define malloc_domain(size, type, domain, flags) malloc((size), (type), 
(flags))
 #define free_domain(addr, type) free(addr, type)
 #endif
@@ -259,7 +261,7 @@ pmclog_get_buffer(struct pmc_owner *po)
KASSERT(po->po_curbuf[curcpu] == NULL,
("[pmclog,%d] po=%p current buffer still valid", __LINE__, po));
 
-   domain = PCPU_GET(domain);
+   domain = curdomain;
MPASS(pmc_dom_hdrs[domain]);
mtx_lock_spin(&pmc_dom_hdrs[domain]->pdbh_mtx);
if ((plb = TAILQ_FIRST(&pmc_dom_hdrs[domain]->pdbh_head)) != NULL)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333600 - in head/contrib/elftoolchain: elfcopy readelf

2018-05-13 Thread Phil Shafer
Author: phil
Date: Mon May 14 05:21:18 2018
New Revision: 333600
URL: https://svnweb.freebsd.org/changeset/base/333600

Log:
  Handle thread-local storage (TLS) segments correctly when
  copying (objcopy) and displaying (readelf) them.
  
  PR:   227552
  Submitted by: kaiw (maintainer)
  Reported by:  jachm...@unitix.org
  Reviewed by:  phil
  MFC after:1 day

Modified:
  head/contrib/elftoolchain/elfcopy/elfcopy.h
  head/contrib/elftoolchain/elfcopy/sections.c
  head/contrib/elftoolchain/elfcopy/segments.c
  head/contrib/elftoolchain/readelf/readelf.c

Modified: head/contrib/elftoolchain/elfcopy/elfcopy.h
==
--- head/contrib/elftoolchain/elfcopy/elfcopy.h Mon May 14 04:00:52 2018
(r333599)
+++ head/contrib/elftoolchain/elfcopy/elfcopy.h Mon May 14 05:21:18 2018
(r333600)
@@ -127,6 +127,7 @@ struct section {
uint64_t cap;   /* section capacity */
uint64_t align; /* section alignment */
uint64_t type;  /* section type */
+   uint64_t flags; /* section flags */
uint64_t vma;   /* section virtual addr */
uint64_t lma;   /* section load addr */
uint64_t pad_sz;/* section padding size */

Modified: head/contrib/elftoolchain/elfcopy/sections.c
==
--- head/contrib/elftoolchain/elfcopy/sections.cMon May 14 04:00:52 
2018(r333599)
+++ head/contrib/elftoolchain/elfcopy/sections.cMon May 14 05:21:18 
2018(r333600)
@@ -411,6 +411,7 @@ create_scn(struct elfcopy *ecp)
s->sz   = ish.sh_size;
s->align= ish.sh_addralign;
s->type = ish.sh_type;
+   s->flags= ish.sh_flags;
s->vma  = ish.sh_addr;
 
/*

Modified: head/contrib/elftoolchain/elfcopy/segments.c
==
--- head/contrib/elftoolchain/elfcopy/segments.cMon May 14 04:00:52 
2018(r333599)
+++ head/contrib/elftoolchain/elfcopy/segments.cMon May 14 05:21:18 
2018(r333600)
@@ -79,6 +79,8 @@ add_to_inseg_list(struct elfcopy *ecp, struct section 
continue;
if (s->vma + s->sz > seg->vaddr + seg->msz)
continue;
+   if (seg->type == PT_TLS && ((s->flags & SHF_TLS) == 0))
+   continue;
 
insert_to_inseg_list(seg, s);
if (seg->type == PT_LOAD)

Modified: head/contrib/elftoolchain/readelf/readelf.c
==
--- head/contrib/elftoolchain/readelf/readelf.c Mon May 14 04:00:52 2018
(r333599)
+++ head/contrib/elftoolchain/readelf/readelf.c Mon May 14 05:21:18 2018
(r333600)
@@ -2378,11 +2378,22 @@ dump_phdr(struct readelf *re)
}
printf("   %2.2d ", i);
/* skip NULL section. */
-   for (j = 1; (size_t)j < re->shnum; j++)
-   if (re->sl[j].addr >= phdr.p_vaddr &&
-   re->sl[j].addr + re->sl[j].sz <=
+   for (j = 1; (size_t)j < re->shnum; j++) {
+   if (re->sl[j].off < phdr.p_offset)
+   continue;
+   if (re->sl[j].off + re->sl[j].sz >
+   phdr.p_offset + phdr.p_filesz &&
+   re->sl[j].type != SHT_NOBITS)
+   continue;
+   if (re->sl[j].addr < phdr.p_vaddr ||
+   re->sl[j].addr + re->sl[j].sz >
phdr.p_vaddr + phdr.p_memsz)
-   printf("%s ", re->sl[j].name);
+   continue;
+   if (phdr.p_type == PT_TLS &&
+   (re->sl[j].flags & SHF_TLS) == 0)
+   continue;
+   printf("%s ", re->sl[j].name);
+   }
printf("\n");
}
 #undef PH_HDR
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333599 - head/sys/powerpc/aim

2018-05-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon May 14 04:00:52 2018
New Revision: 333599
URL: https://svnweb.freebsd.org/changeset/base/333599

Log:
  Final fix for alignment issues with the page table first patched with
  r333273 and partially reverted with r333594.
  
  Older CPUs implement addition of offsets into the page table by a
  bitwise OR rather than actual addition, which only works if the table is
  aligned at a multiple of its own size (they also require it to be aligned
  at a multiple of 256KB). Newer ones do not have that requirement, but it
  hardly matters to enforce it anyway.
  
  The original code was failing on newer systems with huge amounts of RAM
  (> 512 GB), in which the page table was 4 GB in size. Because the
  bootstrap memory allocator took its alignment parameter as an int, this
  turned into a 0, removing any alignment constraint at all and making
  the MMU fail. The first round of this patch (r333273) fixed this case by
  aligning it at 256 KB, which broke older CPUs. Fix this instead by widening
  the alignment parameter.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/mmu_oea64.h
  head/sys/powerpc/aim/moea64_native.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cMon May 14 01:08:47 2018
(r333598)
+++ head/sys/powerpc/aim/mmu_oea64.cMon May 14 04:00:52 2018
(r333599)
@@ -2446,7 +2446,7 @@ moea64_remove_all(mmu_t mmu, vm_page_t m)
  * calculated.
  */
 vm_offset_t
-moea64_bootstrap_alloc(vm_size_t size, u_int align)
+moea64_bootstrap_alloc(vm_size_t size, vm_size_t align)
 {
vm_offset_t s, e;
int i, j;

Modified: head/sys/powerpc/aim/mmu_oea64.h
==
--- head/sys/powerpc/aim/mmu_oea64.hMon May 14 01:08:47 2018
(r333598)
+++ head/sys/powerpc/aim/mmu_oea64.hMon May 14 04:00:52 2018
(r333599)
@@ -39,7 +39,7 @@ extern mmu_def_t oea64_mmu;
  */
 
 /* Allocate physical memory for use in moea64_bootstrap. */
-vm_offset_tmoea64_bootstrap_alloc(vm_size_t, u_int);
+vm_offset_tmoea64_bootstrap_alloc(vm_size_t size, vm_size_t align);
 /* Set an LPTE structure to match the contents of a PVO */
 void   moea64_pte_from_pvo(const struct pvo_entry *pvo, struct lpte *lpte);
 

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cMon May 14 01:08:47 2018
(r333598)
+++ head/sys/powerpc/aim/moea64_native.cMon May 14 04:00:52 2018
(r333599)
@@ -453,10 +453,11 @@ moea64_bootstrap_native(mmu_t mmup, vm_offset_t kernel
}
/*
 * PTEG table must be aligned on a 256k boundary, but can be placed
-* anywhere with that alignment. Some of our hash calculations,
-* however, assume that the PTEG table is aligned to its own size
-* (low-order bits are zero in an OR). As such, make alignment
-* bigger than strictly necessary for the time being.
+* anywhere with that alignment on POWER ISA 3+ systems. On earlier
+* systems, offset addition is done by the CPU with bitwise OR rather
+* than addition, so the table must also be aligned on a boundary of
+* its own size. Pick the larger of the two, which works on all
+* systems.
 */
moea64_pteg_table = (struct lpte *)moea64_bootstrap_alloc(size, 
MAX(256*1024, size));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333598 - head/sys/dev/hwpmc

2018-05-13 Thread Matt Macy
Author: mmacy
Date: Mon May 14 01:08:47 2018
New Revision: 333598
URL: https://svnweb.freebsd.org/changeset/base/333598

Log:
  pmc: don't add pmc owner to list until setup is complete
  
  Once a pmc owner is added to the pmc_ss_owners list it is
  visible for all to see. We don't want this to happen until
  setup is complete.
  
  Reported by:  mjg
  Approved by:  sbruno

Modified:
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==
--- head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 14 00:56:33 2018
(r333597)
+++ head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 14 01:08:47 2018
(r333598)
@@ -2733,13 +2733,6 @@ pmc_start(struct pmc *pm)
 */
 
if (mode == PMC_MODE_SS) {
-   if (po->po_sscount == 0) {
-   CK_LIST_INSERT_HEAD(&pmc_ss_owners, po, po_ssnext);
-   atomic_add_rel_int(&pmc_ss_count, 1);
-   PMCDBG1(PMC,OPS,1, "po=%p in global list", po);
-   }
-   po->po_sscount++;
-
/*
 * Log mapping information for all existing processes in the
 * system.  Subsequent mappings are logged as they happen;
@@ -2748,6 +2741,12 @@ pmc_start(struct pmc *pm)
if (po->po_logprocmaps == 0) {
pmc_log_all_process_mappings(po);
po->po_logprocmaps = 1;
+   }
+   po->po_sscount++;
+   if (po->po_sscount == 1) {
+   atomic_add_rel_int(&pmc_ss_count, 1);
+   CK_LIST_INSERT_HEAD(&pmc_ss_owners, po, po_ssnext);
+   PMCDBG1(PMC,OPS,1, "po=%p in global list", po);
}
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333597 - head/sys/sys

2018-05-13 Thread Matt Macy
Author: mmacy
Date: Mon May 14 00:56:33 2018
New Revision: 333597
URL: https://svnweb.freebsd.org/changeset/base/333597

Log:
  pmc: fix buildworld
  
  hid ck_queue.h from user
  
  Approved by:  sbruno

Modified:
  head/sys/sys/pmc.h

Modified: head/sys/sys/pmc.h
==
--- head/sys/sys/pmc.h  Mon May 14 00:21:04 2018(r333596)
+++ head/sys/sys/pmc.h  Mon May 14 00:56:33 2018(r333597)
@@ -40,8 +40,10 @@
 #include 
 #include 
 #include 
+#ifdef _KERNEL
 #include 
 #include 
+#endif
 
 #definePMC_MODULE_NAME "hwpmc"
 #definePMC_NAME_MAX64 /* HW counter name size */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333596 - in head/sys: dev/hwpmc kern sys

2018-05-13 Thread Matt Macy
Author: mmacy
Date: Mon May 14 00:21:04 2018
New Revision: 333596
URL: https://svnweb.freebsd.org/changeset/base/333596

Log:
  hwpmc: fix load/unload race and vm map LOR
  
  - fix load/unload race by allocating the per-domain list structure at boot
  
  - fix long extant vm map LOR by replacing pmc_sx sx_slock with global_epoch
to protect the liveness of elements of the pmc_ss_owners list
  
  Reported by:  pho
  Approved by:  sbruno

Modified:
  head/sys/dev/hwpmc/hwpmc_logging.c
  head/sys/dev/hwpmc/hwpmc_mod.c
  head/sys/kern/kern_pmc.c
  head/sys/sys/pmc.h
  head/sys/sys/pmckern.h

Modified: head/sys/dev/hwpmc/hwpmc_logging.c
==
--- head/sys/dev/hwpmc/hwpmc_logging.c  Mon May 14 00:14:00 2018
(r333595)
+++ head/sys/dev/hwpmc/hwpmc_logging.c  Mon May 14 00:21:04 2018
(r333596)
@@ -63,20 +63,10 @@ __FBSDID("$FreeBSD$");
 
 #ifdef NUMA
 #define NDOMAINS vm_ndomains
-
-static int
-getdomain(int cpu)
-{
-   struct pcpu *pc;
-
-   pc = pcpu_find(cpu);
-   return (pc->pc_domain);
-}
 #else
 #define NDOMAINS 1
 #define malloc_domain(size, type, domain, flags) malloc((size), (type), 
(flags))
 #define free_domain(addr, type) free(addr, type)
-#define getdomain(cpu) 0
 #endif
 
 /*
@@ -225,16 +215,6 @@ struct pmclog_buffer {
uint16_t plb_domain;
 } __aligned(CACHE_LINE_SIZE);
 
-struct pmc_domain_buffer_header {
-   struct mtx pdbh_mtx;
-   TAILQ_HEAD(, pmclog_buffer) pdbh_head;
-   struct pmclog_buffer *pdbh_plbs;
-   int pdbh_ncpus;
-} __aligned(CACHE_LINE_SIZE);
-
-struct pmc_domain_buffer_header *pmc_dom_hdrs[MAXMEMDOM];
-
-
 /*
  * Prototypes
  */
@@ -280,6 +260,7 @@ pmclog_get_buffer(struct pmc_owner *po)
("[pmclog,%d] po=%p current buffer still valid", __LINE__, po));
 
domain = PCPU_GET(domain);
+   MPASS(pmc_dom_hdrs[domain]);
mtx_lock_spin(&pmc_dom_hdrs[domain]->pdbh_mtx);
if ((plb = TAILQ_FIRST(&pmc_dom_hdrs[domain]->pdbh_head)) != NULL)
TAILQ_REMOVE(&pmc_dom_hdrs[domain]->pdbh_head, plb, plb_next);
@@ -1165,7 +1146,7 @@ pmclog_process_userlog(struct pmc_owner *po, struct pm
 void
 pmclog_initialize()
 {
-   int domain, cpu;
+   int domain;
struct pmclog_buffer *plb;
 
if (pmclog_buffer_size <= 0 || pmclog_buffer_size > 16*1024) {
@@ -1180,7 +1161,6 @@ pmclog_initialize()
  "than zero.\n", pmc_nlogbuffers_pcpu);
pmc_nlogbuffers_pcpu = PMC_NLOGBUFFERS_PCPU;
}
-
if (pmc_nlogbuffers_pcpu*pmclog_buffer_size > 32*1024) {
(void) printf("hwpmc: memory allocated pcpu must be less than 
32MB (is %dK).\n",
  
pmc_nlogbuffers_pcpu*pmclog_buffer_size);
@@ -1188,17 +1168,6 @@ pmclog_initialize()
pmclog_buffer_size = PMC_LOG_BUFFER_SIZE;
}
for (domain = 0; domain < NDOMAINS; domain++) {
-   pmc_dom_hdrs[domain] = malloc_domain(sizeof(struct 
pmc_domain_buffer_header), M_PMC, domain,
-   
M_WAITOK|M_ZERO);
-   mtx_init(&pmc_dom_hdrs[domain]->pdbh_mtx, "pmc_bufferlist_mtx", 
"pmc-leaf", MTX_SPIN);
-   TAILQ_INIT(&pmc_dom_hdrs[domain]->pdbh_head);
-   }
-   CPU_FOREACH(cpu) {
-   domain = getdomain(cpu);
-   KASSERT(pmc_dom_hdrs[domain] != NULL, ("no mem allocated for 
domain: %d", domain));
-   pmc_dom_hdrs[domain]->pdbh_ncpus++;
-   }
-   for (domain = 0; domain < NDOMAINS; domain++) {
int ncpus = pmc_dom_hdrs[domain]->pdbh_ncpus;
int total = ncpus*pmc_nlogbuffers_pcpu;
 
@@ -1231,12 +1200,10 @@ pmclog_shutdown()
mtx_destroy(&pmc_kthread_mtx);
 
for (domain = 0; domain < NDOMAINS; domain++) {
-   mtx_destroy(&pmc_dom_hdrs[domain]->pdbh_mtx);
while ((plb = TAILQ_FIRST(&pmc_dom_hdrs[domain]->pdbh_head)) != 
NULL) {
TAILQ_REMOVE(&pmc_dom_hdrs[domain]->pdbh_head, plb, 
plb_next);
free(plb->plb_base, M_PMC);
}
free(pmc_dom_hdrs[domain]->pdbh_plbs, M_PMC);
-   free(pmc_dom_hdrs[domain], M_PMC);
}
 }

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==
--- head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 14 00:14:00 2018
(r333595)
+++ head/sys/dev/hwpmc/hwpmc_mod.c  Mon May 14 00:21:04 2018
(r333596)
@@ -1564,12 +1564,14 @@ pmc_process_mmap(struct thread *td, struct pmckern_map
const struct pmc_process *pp;
 
freepath = fullpath = NULL;
+   epoch_exit(global_epoch);
pmc_getfilename((struct vnode *) pkm->pm_file, &fullpath, &freepath);
 
pid = td->td_proc->p_pid;
 
+   epoch_enter(global_epoch);

Re: svn commit: r333494 - head/share/man/man7

2018-05-13 Thread Rodney W. Grimes
> On Sat, May 12, 2018, 12:59 AM Rodney W. Grimes <
> free...@pdx.rh.cn85.dnsmgr.net> wrote:
> 
> > > On Fri, May 11, 2018 at 8:26 AM, Rodney W. Grimes
> > >  wrote:
> > > >> @@ -67,7 +72,8 @@ Changes are first committed to CURRENT and then
> > usuall
> > > >>  to STABLE.
> > > >>  Every few years the CURRENT branch is renamed to STABLE, and a new
> > > >>  CURRENT is branched, with an incremented major version number.
> > > >> -Releases are then branched off STABLE and numbered with consecutive
> > minor numbers.
> > > >> +Releases are then branched off STABLE and numbered with consecutive
> > minor
> > > >> +numbers.
> > > >
> > > > Proper place to line break long lines is at conjuncatives such
> > > > as the "and" above, yeilding:
> > >
> > > What?  Are you just inventing these rules out of blue sky?  What
> > > possible reason is there to do as you have proposed?
> >
> > Well known and established man page style rules, documented someplace,
> > which I can not seem to locate right now.
> >
> 
> Could you please find that if possible and share with us?
> Personally I'm about to rewrite some man page and that would be useful in
> my case!

It did take me some time to track down this "crazy concept you all
think I just invented", but it is infact in the GNU groff info
documentaton (found on my 5.4 systems in /usr/share/info/groff.info.gz):


   Here are a few hints for preparing text for input to `gtroff'.

   * First, keep the input lines short.  Short input lines are easier to
 edit, and `gtroff' packs words onto longer lines anyhow.

   * In keeping with this, it is helpful to begin a new line after every
 comma or phrase, since common corrections are to add or delete
 sentences or phrases.

   * End each sentence with two spaces - or better, start each sentence
 on a new line.  `gtroff' recognizes characters that usually end a
 sentence, and inserts sentence space accordingly.

   * Do not hyphenate words at the end of lines - `gtroff' is smart
 enough to hyphenate words as needed, but is not smart enough to
 take hyphens out and join a word back together.  Also, words such
 as "mother-in-law" should not be broken over a line, since then a
 space can occur where not wanted, such as "mother- in-law".


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


svn commit: r333595 - head/sys/kern

2018-05-13 Thread Matt Macy
Author: mmacy
Date: Mon May 14 00:14:00 2018
New Revision: 333595
URL: https://svnweb.freebsd.org/changeset/base/333595

Log:
  epoch(9): allow sx locks to be held across epoch_wait()
  
  The INVARIANTS checks in epoch_wait() were intended to
  prevent the block handler from returning with locks held.
  What it in fact did was preventing anything except Giant
  from being held across it. Check that the number of locks
  held has not changed instead.
  
  Approved by:  sbruno@

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Sun May 13 23:56:43 2018(r333594)
+++ head/sys/kern/subr_epoch.c  Mon May 14 00:14:00 2018(r333595)
@@ -469,7 +469,11 @@ epoch_wait(epoch_t epoch)
int old_cpu;
int old_pinned;
u_char old_prio;
+#ifdef INVARIANTS
+   int locks;
 
+   locks = curthread->td_locks;
+#endif
INIT_CHECK(epoch);
 
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
@@ -506,9 +510,9 @@ epoch_wait(epoch_t epoch)
/* restore thread priority */
sched_prio(td, old_prio);
thread_unlock(td);
-   KASSERT(td->td_locks == 0,
-   ("%d locks held", td->td_locks));
PICKUP_GIANT();
+   KASSERT(td->td_locks == locks,
+   ("%d residual locks held", td->td_locks - locks));
 }
 
 void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333594 - head/sys/powerpc/aim

2018-05-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun May 13 23:56:43 2018
New Revision: 333594
URL: https://svnweb.freebsd.org/changeset/base/333594

Log:
  Revert changes to hash table alignment in r333273, which booting on all G5
  systems, pending further analysis.

Modified:
  head/sys/powerpc/aim/moea64_native.c

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cSun May 13 23:55:11 2018
(r333593)
+++ head/sys/powerpc/aim/moea64_native.cSun May 13 23:56:43 2018
(r333594)
@@ -448,14 +448,18 @@ moea64_bootstrap_native(mmu_t mmup, vm_offset_t kernel
moea64_part_table =
(struct pate *)moea64_bootstrap_alloc(PART_SIZE, PART_SIZE);
if (hw_direct_map)
-   moea64_part_table =
-   (struct pate 
*)PHYS_TO_DMAP((vm_offset_t)moea64_part_table);
+   moea64_part_table = (struct pate *)PHYS_TO_DMAP(
+   (vm_offset_t)moea64_part_table);
}
/*
 * PTEG table must be aligned on a 256k boundary, but can be placed
-* anywhere with that alignment.
+* anywhere with that alignment. Some of our hash calculations,
+* however, assume that the PTEG table is aligned to its own size
+* (low-order bits are zero in an OR). As such, make alignment
+* bigger than strictly necessary for the time being.
 */
-   moea64_pteg_table = (struct lpte *)moea64_bootstrap_alloc(size, 
256*1024);
+   moea64_pteg_table = (struct lpte *)moea64_bootstrap_alloc(size, 
+   MAX(256*1024, size));
if (hw_direct_map)
moea64_pteg_table =
(struct lpte *)PHYS_TO_DMAP((vm_offset_t)moea64_pteg_table);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333592 - head/sys/fs/nfsserver

2018-05-13 Thread Rick Macklem
Author: rmacklem
Date: Sun May 13 23:38:01 2018
New Revision: 333592
URL: https://svnweb.freebsd.org/changeset/base/333592

Log:
  Fix the eir_server_scope reply argument for NFSv4.1 ExchangeID.
  
  In the reply to an ExchangeID operation, the NFSv4.1 server returns a
  "scope" value (eir_server_scope). If this value is the same, it indicates
  that two servers share state, which is never the case for FreeBSD servers.
  As such, the value needs to be unique and it was without this patch.
  However, I just found out that it is not supposed to change when the
  server reboots and without this patch, it did change.
  This patch fixes eir_server_scope so that it does not change when the
  server is rebooted.
  The only affect not having this patch has is that Linux clients don't
  reclaim opens and locks after a server reboot, which meant they lost
  any byte range locks held before the server rebooted.
  It only affects NFSv4.1 mounts and the FreeBSD NFSv4.1 client was not
  affected by this bug.
  
  MFC after:1 week

Modified:
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==
--- head/sys/fs/nfsserver/nfs_nfsdserv.cSun May 13 23:24:48 2018
(r333591)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.cSun May 13 23:38:01 2018
(r333592)
@@ -3835,9 +3835,9 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused 
txdr_hyper(owner_minor, tl);/* Minor */
(void)nfsm_strtom(nd, nd->nd_cred->cr_prison->pr_hostuuid,
strlen(nd->nd_cred->cr_prison->pr_hostuuid)); /* Major */
-   NFSM_BUILD(tl, uint32_t *, 3 * NFSX_UNSIGNED);
-   *tl++ = txdr_unsigned(NFSX_UNSIGNED);
-   *tl++ = time_uptime;/* Make scope a unique value. */
+   (void)nfsm_strtom(nd, nd->nd_cred->cr_prison->pr_hostuuid,
+   strlen(nd->nd_cred->cr_prison->pr_hostuuid)); /* Scope */
+   NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(1);
(void)nfsm_strtom(nd, "freebsd.org", strlen("freebsd.org"));
(void)nfsm_strtom(nd, version, strlen(version));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333591 - in head/sys: kern sys

2018-05-13 Thread Matt Macy
Author: mmacy
Date: Sun May 13 23:24:48 2018
New Revision: 333591
URL: https://svnweb.freebsd.org/changeset/base/333591

Log:
  epoch(9): cleanups, additional debug checks, and add global_epoch
  
  - GC the _nopreempt routines
  - to really benefit we'd need a separate routine
  - they're not currently in use
  - they complicate the API for no benefit at this time
  
  - check that we're actually in a epoch section at exit
  
  - handle epoch_call() early in boot
  
  - Fix copyright declaration language
  
  Approved by:  sbruno@

Modified:
  head/sys/kern/subr_epoch.c
  head/sys/sys/epoch.h

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Sun May 13 23:16:04 2018(r333590)
+++ head/sys/kern/subr_epoch.c  Sun May 13 23:24:48 2018(r333591)
@@ -1,27 +1,29 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (c) 2018, Matthew Macy 
  *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
+ * 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.
  *
- *  1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- *  2. Neither the name of Matthew Macy nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * 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 COPYRIGHT OWNER 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.
+ * 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 
@@ -49,7 +51,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-MALLOC_DEFINE(M_EPOCH, "epoch", "epoch based reclamation");
+static MALLOC_DEFINE(M_EPOCH, "epoch", "epoch based reclamation");
 
 /* arbitrary --- needs benchmarking */
 #define MAX_ADAPTIVE_SPIN 5000
@@ -116,6 +118,7 @@ struct epoch {
 static __read_mostly int domcount[MAXMEMDOM];
 static __read_mostly int domoffsets[MAXMEMDOM];
 static __read_mostly int inited;
+__read_mostly epoch_t global_epoch;
 
 static void epoch_call_task(void *context);
 
@@ -136,10 +139,8 @@ epoch_init(void *arg __unused)
migrate_count = counter_u64_alloc(M_WAITOK);
turnstile_count = counter_u64_alloc(M_WAITOK);
switch_count = counter_u64_alloc(M_WAITOK);
-   if (usedomains == false) {
-   inited = 1;
-   return;
-   }
+   if (usedomains == false)
+   goto done;
count = domain = 0;
domoffsets[0] = 0;
for (domain = 0; domain < vm_ndomains; domain++) {
@@ -156,9 +157,11 @@ epoch_init(void *arg __unused)
break;
}
}
+ done:
inited = 1;
+   global_epoch = epoch_alloc();
 }
-SYSINIT(epoch, SI_SUB_CPU + 1, SI_ORDER_FIRST, epoch_init, NULL);
+SYSINIT(epoch, SI_SUB_TASKQ + 1, SI_ORDER_FIRST, epoch_init, NULL);
 
 static void
 epoch_init_numa(epoch_t epoch)
@@ -311,19 +314,6 @@ epoch_enter(epoch_t epoch)
 }
 
 void
-epoch_enter_nopreempt(epoch_t epoch)
-{
-   struct epoch_pcpu_state *eps;
-
-   INIT_CHECK(epoch);

svn commit: r333590 - head/share/man/man9

2018-05-13 Thread Matt Macy
Author: mmacy
Date: Sun May 13 23:16:04 2018
New Revision: 333590
URL: https://svnweb.freebsd.org/changeset/base/333590

Log:
  Add epoch(9) man page
  
  Reviewed by:  gallatin@
  Approved by:  sbruno@

Added:
  head/share/man/man9/epoch.9   (contents, props changed)
Modified:
  head/share/man/man9/Makefile

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileSun May 13 23:04:35 2018
(r333589)
+++ head/share/man/man9/MakefileSun May 13 23:16:04 2018
(r333590)
@@ -123,6 +123,7 @@ MAN=accept_filter.9 \
drbr.9 \
driver.9 \
DRIVER_MODULE.9 \
+   epoch.9 \
EVENTHANDLER.9 \
eventtimers.9 \
extattr.9 \

Added: head/share/man/man9/epoch.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/epoch.9 Sun May 13 23:16:04 2018(r333590)
@@ -0,0 +1,161 @@
+.\"
+.\" Copyright (C) 2018 Matthew Macy . 
+.\"
+.\" 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(s), this list of conditions and the following disclaimer as
+.\"the first lines of this file unmodified other than the possible
+.\"addition of one or more copyright notices.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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$
+.\"
+.Dd May 13, 2018
+.Dt EPOCH 9
+.Os
+.Sh NAME
+.Nm epoch ,
+.Nm epoch_context ,
+.Nm epoch_alloc ,
+.Nm epoch_free ,
+.Nm epoch_enter ,
+.Nm epoch_exit ,
+.Nm epoch_wait ,
+.Nm epoch_call ,
+.Nm in_epoch ,
+.Nd kernel epoch based reclaimation
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/proc.h
+.In sys/epoch.h
+.Ft epoch_t
+.Fn epoch_alloc "void"
+.Ft void
+.Fn epoch_enter "epoch_t epoch"
+.Ft void
+.Fn epoch_exit "epoch_t epoch"
+.Ft void
+.Fn epoch_wait "epoch_t epoch"
+.Ft void
+.Fn epoch_call "epoch_t epoch" "epoch_context_t ctx" "void (*callback) 
(epoch_context_t)"
+.Ft int
+.Fn in_epoch "void"
+.Sh DESCRIPTION
+Epochs are used to guarantee liveness and immutability of data by
+deferring reclamation and mutation until a grace period has elapsed.
+Epochs do not have any lock ordering issues. Entering and leaving
+an epoch section will never block.
+.Pp
+Epochs are allocated with
+.Fn epoch_alloc
+and freed with
+.Fn epoch_free .
+Threads indicate the start of an epoch critical section by calling
+.Fn epoch_enter .
+The end of a critical section is indicated by calling
+.Fn epoch_exit .
+A thread can wait until a grace period has elapsed
+since any threads have entered
+the epoch by calling
+.Fn epoch_wait .
+If the thread can't sleep or is otherwise in a performance sensitive
+path it can ensure that a grace period has elapsed by calling
+.Fn epoch_call
+with a callback with any work that needs to wait for an epoch to elapse.
+Only non-sleepable locks can be acquired during a section protected by
+.Fn epoch_enter
+and
+.Fn epoch_exit .
+INVARIANTS can assert that a thread is in an epoch by using
+.Fn in_epoch .
+.Pp
+The epoch API currently does not support sleeping in epoch sections.
+A caller cannot do epoch_enter recursively on different epochs. A
+caller should never call
+.Fn epoch_wait
+in the middle of an epoch section as this will lead to a deadlock.
+.Pp
+Note that epochs are not a straight replacement for read locks. Callers
+must use safe list and tailq traversal routines in an epoch (see ck_queue).
+When modifying a list referenced from an epoch section safe removal
+routines must be used and the caller can no longer modify a list entry
+in place. An item to be modified must be handled with copy on write
+and frees must be deferred until after a grace period has elapsed.
+
+.Sh RETURN VALUES
+.Fn in_epoch
+will return 1 if curthread is in an epoch, 0 o

svn commit: r333589 - head/share/man/man5

2018-05-13 Thread Sevan Janiyan
Author: sevan (doc committer)
Date: Sun May 13 23:04:35 2018
New Revision: 333589
URL: https://svnweb.freebsd.org/changeset/base/333589

Log:
  Regen after r333588

Modified:
  head/share/man/man5/src.conf.5

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Sun May 13 22:58:40 2018
(r333588)
+++ head/share/man/man5/src.conf.5  Sun May 13 23:04:35 2018
(r333589)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd May 3, 2018
+.Dd May 14, 2018
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -848,7 +848,7 @@ and
 .Xr tcpmd5 4 .
 .It Va WITHOUT_ISCSI
 Set to not build
-.Xr iscid 8
+.Xr iscsid 8
 and related utilities.
 .It Va WITHOUT_JAIL
 Set to not build tools for the support of jails; e.g.,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333588 - head/tools/build/options

2018-05-13 Thread Sevan Janiyan
Author: sevan (doc committer)
Date: Sun May 13 22:58:40 2018
New Revision: 333588
URL: https://svnweb.freebsd.org/changeset/base/333588

Log:
  Typo
  
  Submitted by: jrm@
  Approved by:  bcr (mentor)
  Differential Revision:https://reviews.freebsd.org/D14836

Modified:
  head/tools/build/options/WITHOUT_ISCSI

Modified: head/tools/build/options/WITHOUT_ISCSI
==
--- head/tools/build/options/WITHOUT_ISCSI  Sun May 13 20:10:02 2018
(r333587)
+++ head/tools/build/options/WITHOUT_ISCSI  Sun May 13 22:58:40 2018
(r333588)
@@ -1,4 +1,4 @@
 .\" $FreeBSD$
 Set to not build
-.Xr iscid 8
+.Xr iscsid 8
 and related utilities.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333587 - head/sys/i386/include

2018-05-13 Thread Konstantin Belousov
Author: kib
Date: Sun May 13 20:10:02 2018
New Revision: 333587
URL: https://svnweb.freebsd.org/changeset/base/333587

Log:
  Fix PMC_IN_TRAP_HANDLER() for i386 after the 4/4 split.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/i386/include/pmc_mdep.h

Modified: head/sys/i386/include/pmc_mdep.h
==
--- head/sys/i386/include/pmc_mdep.hSun May 13 19:48:30 2018
(r333586)
+++ head/sys/i386/include/pmc_mdep.hSun May 13 20:10:02 2018
(r333587)
@@ -145,8 +145,8 @@ struct pmc_mdep;
 #definePMC_IN_USERSPACE(va) ((va) <= VM_MAXUSER_ADDRESS)
 
 #definePMC_IN_TRAP_HANDLER(PC) \
-   ((PC) >= (uintptr_t) start_exceptions &&\
-(PC) < (uintptr_t) end_exceptions)
+   ((PC) >= (uintptr_t)start_exceptions + setidt_disp &&   \
+(PC) < (uintptr_t) end_exceptions + setidt_disp)
 
 #definePMC_AT_FUNCTION_PROLOGUE_PUSH_BP(I) \
(((I) & 0x00ff) == 0xe58955) /* pushl %ebp; movl %esp,%ebp */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333586 - head/sys/fs/ext2fs

2018-05-13 Thread Fedor Uporov
Author: fsu
Date: Sun May 13 19:48:30 2018
New Revision: 333586
URL: https://svnweb.freebsd.org/changeset/base/333586

Log:
  Fix directory blocks checksumming.
  
  Reviewed by:pfg
  MFC after:  3 months
  
  Differential Revision:https://reviews.freebsd.org/D15396

Modified:
  head/sys/fs/ext2fs/ext2_csum.c
  head/sys/fs/ext2fs/ext2_extern.h
  head/sys/fs/ext2fs/ext2_htree.c
  head/sys/fs/ext2fs/ext2_inode_cnv.c
  head/sys/fs/ext2fs/ext2_lookup.c
  head/sys/fs/ext2fs/ext2_vnops.c

Modified: head/sys/fs/ext2fs/ext2_csum.c
==
--- head/sys/fs/ext2fs/ext2_csum.c  Sun May 13 19:29:35 2018
(r333585)
+++ head/sys/fs/ext2fs/ext2_csum.c  Sun May 13 19:48:30 2018
(r333586)
@@ -154,12 +154,37 @@ ext2_extattr_blk_csum_set(struct inode *ip, struct buf
header->h_checksum = ext2_extattr_blk_csum(ip, ip->i_facl, header);
 }
 
-static struct ext2fs_direct_tail *
-ext2_get_dirent_tail(struct inode *ip, struct ext2fs_direct_2 *ep)
+void
+ext2_init_dirent_tail(struct ext2fs_direct_tail *tp)
 {
+   memset(tp, 0, sizeof(struct ext2fs_direct_tail));
+   tp->e2dt_rec_len = sizeof(struct ext2fs_direct_tail);
+   tp->e2dt_reserved_ft = EXT2_FT_DIR_CSUM;
+}
+
+struct ext2fs_direct_tail *
+ext2_dirent_get_tail(struct inode *ip, struct ext2fs_direct_2 *ep)
+{
+   struct ext2fs_direct_2 *dep;
+   void *top;
struct ext2fs_direct_tail *tp;
+   unsigned int rec_len;
 
-   tp = EXT2_DIRENT_TAIL(ep, ip->i_e2fs->e2fs_bsize);
+   dep = ep;
+   top = EXT2_DIRENT_TAIL(ep, ip->i_e2fs->e2fs_bsize);
+   rec_len = dep->e2d_reclen;
+
+   while (rec_len && !(rec_len & 0x3)) {
+   dep = (struct ext2fs_direct_2 *)(((char *)dep) + rec_len);
+   if ((void *)dep >= top)
+   break;
+   rec_len = dep->e2d_reclen;
+   }
+
+   if (dep != top)
+   return (NULL);
+
+   tp = (struct ext2fs_direct_tail *)dep;
if (tp->e2dt_reserved_zero1 ||
tp->e2dt_rec_len != sizeof(struct ext2fs_direct_tail) ||
tp->e2dt_reserved_zero2 ||
@@ -189,13 +214,13 @@ ext2_dirent_csum(struct inode *ip, struct ext2fs_direc
return (crc);
 }
 
-static int
+int
 ext2_dirent_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep)
 {
uint32_t calculated;
struct ext2fs_direct_tail *tp;
 
-   tp = ext2_get_dirent_tail(ip, ep);
+   tp = ext2_dirent_get_tail(ip, ep);
if (tp == NULL)
return (0);
 
@@ -263,7 +288,7 @@ ext2_dx_csum(struct inode *ip, struct ext2fs_direct_2 
return (crc);
 }
 
-static int
+int
 ext2_dx_csum_verify(struct inode *ip, struct ext2fs_direct_2 *ep)
 {
uint32_t calculated;
@@ -304,7 +329,7 @@ ext2_dir_blk_csum_verify(struct inode *ip, struct buf 
 
ep = (struct ext2fs_direct_2 *)bp->b_data;
 
-   if (ext2_get_dirent_tail(ip, ep) != NULL)
+   if (ext2_dirent_get_tail(ip, ep) != NULL)
error = ext2_dirent_csum_verify(ip, ep);
else if (ext2_get_dx_count(ip, ep, NULL) != NULL)
error = ext2_dx_csum_verify(ip, ep);
@@ -316,12 +341,18 @@ ext2_dir_blk_csum_verify(struct inode *ip, struct buf 
return (error);
 }
 
-static void
+void
 ext2_dirent_csum_set(struct inode *ip, struct ext2fs_direct_2 *ep)
 {
+   struct m_ext2fs *fs;
struct ext2fs_direct_tail *tp;
 
-   tp = ext2_get_dirent_tail(ip, ep);
+   fs = ip->i_e2fs;
+
+   if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
+   return;
+
+   tp = ext2_dirent_get_tail(ip, ep);
if (tp == NULL)
return;
 
@@ -329,13 +360,19 @@ ext2_dirent_csum_set(struct inode *ip, struct ext2fs_d
ext2_dirent_csum(ip, ep, (char *)tp - (char *)ep);
 }
 
-static void
+void
 ext2_dx_csum_set(struct inode *ip, struct ext2fs_direct_2 *ep)
 {
+   struct m_ext2fs *fs;
struct ext2fs_htree_count *cp;
struct ext2fs_htree_tail *tp;
int count_offset, limit, count;
 
+   fs = ip->i_e2fs;
+
+   if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
+   return;
+
cp = ext2_get_dx_count(ip, ep, &count_offset);
if (cp == NULL)
return;
@@ -350,35 +387,6 @@ ext2_dx_csum_set(struct inode *ip, struct ext2fs_direc
tp->ht_checksum = ext2_dx_csum(ip, ep,  count_offset, count, tp);
 }
 
-void
-ext2_dir_blk_csum_set_mem(struct inode *ip, char *buf, int size)
-{
-   struct m_ext2fs *fs;
-   struct ext2fs_direct_2 *ep;
-
-   fs = ip->i_e2fs;
-
-   if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
-   return;
-
-   ep = (struct ext2fs_direct_2 *)buf;
-
-   if (ext2_htree_has_idx(ip)) {
-   if (ext2_get_dx_count(ip, ep, NULL) != NULL)
-   ext2_dx_csum_set(ip, ep);
-   } else {
- 

svn commit: r333585 - head/sys/fs/ext2fs

2018-05-13 Thread Fedor Uporov
Author: fsu
Date: Sun May 13 19:29:35 2018
New Revision: 333585
URL: https://svnweb.freebsd.org/changeset/base/333585

Log:
  Fix on-disk inode checksum calculation logic.
  
  Reviewed by:pfg
  MFC after:  3 months
  
  Differential Revision:https://reviews.freebsd.org/D15395

Modified:
  head/sys/fs/ext2fs/ext2_csum.c
  head/sys/fs/ext2fs/ext2_inode_cnv.c

Modified: head/sys/fs/ext2fs/ext2_csum.c
==
--- head/sys/fs/ext2fs/ext2_csum.c  Sun May 13 19:19:10 2018
(r333584)
+++ head/sys/fs/ext2fs/ext2_csum.c  Sun May 13 19:29:35 2018
(r333585)
@@ -535,29 +535,42 @@ static uint32_t
 ext2_ei_csum(struct inode *ip, struct ext2fs_dinode *ei)
 {
struct m_ext2fs *fs;
-   uint16_t old_hi;
-   uint32_t inum, gen, crc;
+   uint32_t inode_csum_seed, inum, gen, crc;
+   uint16_t dummy_csum = 0;
+   unsigned int offset, csum_size;
 
fs = ip->i_e2fs;
-
-   ei->e2di_chksum_lo = 0;
-   if ((EXT2_INODE_SIZE(ip->i_e2fs) > E2FS_REV0_INODE_SIZE &&
-   ei->e2di_extra_isize >= EXT2_INODE_CSUM_HI_EXTRA_END)) {
-   old_hi = ei->e2di_chksum_hi;
-   ei->e2di_chksum_hi = 0;
-   }
-
+   offset = offsetof(struct ext2fs_dinode, e2di_chksum_lo);
+   csum_size = sizeof(dummy_csum);
inum = ip->i_number;
gen = ip->i_gen;
+   crc = calculate_crc32c(fs->e2fs_csum_seed,
+   (uint8_t *)&inum, sizeof(inum));
+   inode_csum_seed = calculate_crc32c(crc,
+   (uint8_t *)&gen, sizeof(gen));
 
-   crc = calculate_crc32c(fs->e2fs_csum_seed, (uint8_t *)&inum, 
sizeof(inum));
-   crc = calculate_crc32c(crc, (uint8_t *)&gen, sizeof(gen));
-   crc = calculate_crc32c(crc, (uint8_t *)ei, fs->e2fs->e2fs_inode_size);
+   crc = calculate_crc32c(inode_csum_seed, (uint8_t *)ei, offset);
+   crc = calculate_crc32c(crc, (uint8_t *)&dummy_csum, csum_size);
+   offset += csum_size;
+   crc = calculate_crc32c(crc, (uint8_t *)ei + offset,
+   E2FS_REV0_INODE_SIZE - offset);
 
-   if ((EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE &&
-   ei->e2di_extra_isize >= EXT2_INODE_CSUM_HI_EXTRA_END))
-   ei->e2di_chksum_hi = old_hi;
+   if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) {
+   offset = offsetof(struct ext2fs_dinode, e2di_chksum_hi);
+   crc = calculate_crc32c(crc, (uint8_t *)ei +
+   E2FS_REV0_INODE_SIZE, offset - E2FS_REV0_INODE_SIZE);
 
+   if ((EXT2_INODE_SIZE(ip->i_e2fs) > E2FS_REV0_INODE_SIZE &&
+   ei->e2di_extra_isize >= EXT2_INODE_CSUM_HI_EXTRA_END)) {
+   crc = calculate_crc32c(crc, (uint8_t *)&dummy_csum,
+   csum_size);
+   offset += csum_size;
+   }
+
+   crc = calculate_crc32c(crc, (uint8_t *)ei + offset,
+   EXT2_INODE_SIZE(fs) - offset);
+   }
+
return (crc);
 }
 
@@ -573,10 +586,6 @@ ext2_ei_csum_verify(struct inode *ip, struct ext2fs_di
if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM))
return (0);
 
-   /* Check case, when dinode was not initialized */
-   if (!memcmp(ei, &ei_zero, sizeof(struct ext2fs_dinode)))
-   return (0);
-
provided = ei->e2di_chksum_lo;
calculated = ext2_ei_csum(ip, ei);
 
@@ -587,8 +596,17 @@ ext2_ei_csum_verify(struct inode *ip, struct ext2fs_di
} else
calculated &= 0x;
 
-   if (provided != calculated)
+   if (provided != calculated) {
+   /*
+* If it is first time used dinode,
+* it is expected that it will be zeroed
+* and we will not return checksum error in this case.
+*/
+   if (!memcmp(ei, &ei_zero, sizeof(struct ext2fs_dinode)))
+   return (0);
+
return (EIO);
+   }
 
return (0);
 }

Modified: head/sys/fs/ext2fs/ext2_inode_cnv.c
==
--- head/sys/fs/ext2fs/ext2_inode_cnv.c Sun May 13 19:19:10 2018
(r333584)
+++ head/sys/fs/ext2fs/ext2_inode_cnv.c Sun May 13 19:29:35 2018
(r333585)
@@ -92,10 +92,7 @@ ext2_print_inode(struct inode *in)
 int
 ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip)
 {
-   struct m_ext2fs *fs;
-   const static struct ext2fs_dinode ei_zero;
 
-   fs = ip->i_e2fs;
ip->i_nlink = ei->e2di_nlink;
/*
 * Godmar thinks - if the link count is zero, then the inode is
@@ -139,11 +136,7 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip)
 
memcpy(ip->i_data, ei->e2di_blocks, sizeof(ei->e2di_blocks));
 
-   if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM) &&
-   memcmp(ei, &ei_zero, EXT2_INODE_SIZE(fs)))
-

svn commit: r333584 - head/sys/fs/ext2fs

2018-05-13 Thread Fedor Uporov
Author: fsu
Date: Sun May 13 19:19:10 2018
New Revision: 333584
URL: https://svnweb.freebsd.org/changeset/base/333584

Log:
  Fix EXT2FS_DEBUG definition usage.
  
  Reviewed by:pfg
  MFC after:  3 months
  
  Differential Revision:https://reviews.freebsd.org/D15394

Modified:
  head/sys/fs/ext2fs/ext2_alloc.c
  head/sys/fs/ext2fs/ext2_bmap.c
  head/sys/fs/ext2fs/ext2_extents.c
  head/sys/fs/ext2fs/ext2_extents.h
  head/sys/fs/ext2fs/ext2_hash.c
  head/sys/fs/ext2fs/ext2_htree.c
  head/sys/fs/ext2fs/ext2_inode.c
  head/sys/fs/ext2fs/ext2_inode_cnv.c
  head/sys/fs/ext2fs/ext2_lookup.c
  head/sys/fs/ext2fs/ext2_subr.c
  head/sys/fs/ext2fs/ext2_vfsops.c
  head/sys/fs/ext2fs/ext2_vnops.c
  head/sys/fs/ext2fs/fs.h

Modified: head/sys/fs/ext2fs/ext2_alloc.c
==
--- head/sys/fs/ext2fs/ext2_alloc.c Sun May 13 17:44:26 2018
(r333583)
+++ head/sys/fs/ext2fs/ext2_alloc.c Sun May 13 19:19:10 2018
(r333584)
@@ -1381,8 +1381,8 @@ ext2_vfree(struct vnode *pvp, ino_t ino, int mode)
ibp = (char *)bp->b_data;
ino = (ino - 1) % fs->e2fs->e2fs_ipg;
if (isclr(ibp, ino)) {
-   printf("ino = %llu, fs = %s\n",
-   (unsigned long long)ino, fs->e2fs_fsmnt);
+   printf("ino = %ju, fs = %s\n",
+   ino, fs->e2fs_fsmnt);
if (fs->e2fs_ronly == 0)
panic("ext2_vfree: freeing free inode");
}

Modified: head/sys/fs/ext2fs/ext2_bmap.c
==
--- head/sys/fs/ext2fs/ext2_bmap.c  Sun May 13 17:44:26 2018
(r333583)
+++ head/sys/fs/ext2fs/ext2_bmap.c  Sun May 13 19:19:10 2018
(r333584)
@@ -48,8 +48,8 @@
 #include 
 #include 
 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/fs/ext2fs/ext2_extents.c
==
--- head/sys/fs/ext2fs/ext2_extents.c   Sun May 13 17:44:26 2018
(r333583)
+++ head/sys/fs/ext2fs/ext2_extents.c   Sun May 13 19:19:10 2018
(r333584)
@@ -53,7 +53,7 @@ static void
 ext4_ext_print_extent(struct ext4_extent *ep)
 {
 
-   printf("ext %p => (blk %u len %u start %lu)\n",
+   printf("ext %p => (blk %u len %u start %ju)\n",
ep, ep->e_blk, ep->e_len,
(uint64_t)ep->e_start_hi << 32 | ep->e_start_lo);
 }
@@ -69,7 +69,7 @@ ext4_ext_print_index(struct inode *ip, struct ext4_ext
 
fs = ip->i_e2fs;
 
-   printf("index %p => (blk %u pblk %lu)\n",
+   printf("index %p => (blk %u pblk %ju)\n",
ex, ex->ei_blk, (uint64_t)ex->ei_leaf_hi << 32 | ex->ei_leaf_lo);
 
if(!do_walk)
@@ -110,9 +110,9 @@ ext4_ext_print_path(struct inode *ip, struct ext4_exte
 {
int k, l;
 
-   l = path->ep_depth
+   l = path->ep_depth;
 
-   printf("ip=%d, Path:\n", ip->i_number);
+   printf("ip=%ju, Path:\n", ip->i_number);
for (k = 0; k <= l; k++, path++) {
if (path->ep_index) {
ext4_ext_print_index(ip, path->ep_index, 0);
@@ -123,13 +123,13 @@ ext4_ext_print_path(struct inode *ip, struct ext4_exte
 }
 
 void
-ext4_ext_print_extent_tree_status(struct inode * ip)
+ext4_ext_print_extent_tree_status(struct inode *ip)
 {
struct ext4_extent_header *ehp;
 
ehp = (struct ext4_extent_header *)(char *)ip->i_db;
 
-   printf("Extent status:ip=%d\n", ip->i_number);
+   printf("Extent status:ip=%ju\n", ip->i_number);
if (!(ip->i_flag & IN_E4EXTENTS))
return;
 

Modified: head/sys/fs/ext2fs/ext2_extents.h
==
--- head/sys/fs/ext2fs/ext2_extents.h   Sun May 13 17:44:26 2018
(r333583)
+++ head/sys/fs/ext2fs/ext2_extents.h   Sun May 13 19:19:10 2018
(r333584)
@@ -130,7 +130,7 @@ int ext4_ext_get_blocks(struct inode *ip, int64_t iblo
 unsigned long max_blocks, struct ucred *cred, struct buf **bpp,
 int *allocate, daddr_t *);
 #ifdef EXT2FS_DEBUG
-void ext4_ext_print_extent_tree_status(struct inode * ip);
+void ext4_ext_print_extent_tree_status(struct inode *ip);
 #endif
 
 #endif /* !_FS_EXT2FS_EXT2_EXTENTS_H_ */

Modified: head/sys/fs/ext2fs/ext2_hash.c
==
--- head/sys/fs/ext2fs/ext2_hash.c  Sun May 13 17:44:26 2018
(r333583)
+++ head/sys/fs/ext2fs/ext2_hash.c  Sun May 13 19:19:10 2018
(r333584)
@@ -61,6 +61,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/fs/ext2fs/ext2_htree.c
==
--- head/sys/fs/ext2fs/ext2_htree.c Sun May 13 17:44:26 2018
(r333583)
+++ head/sys/fs/ext2fs/ext2_htree.c Sun May 13 19:19:10 

svn commit: r333581 - head/sys/vm

2018-05-13 Thread Mark Johnston
Author: markj
Date: Sun May 13 13:00:59 2018
New Revision: 333581
URL: https://svnweb.freebsd.org/changeset/base/333581

Log:
  Get rid of vm_pageout_page_queued().
  
  vm_page_queue(), added in r333256, generalizes vm_pageout_page_queued(),
  so use it instead.  No functional change intended.
  
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D15402

Modified:
  head/sys/vm/vm_pageout.c

Modified: head/sys/vm/vm_pageout.c
==
--- head/sys/vm/vm_pageout.cSun May 13 12:42:53 2018(r333580)
+++ head/sys/vm/vm_pageout.cSun May 13 13:00:59 2018(r333581)
@@ -252,32 +252,16 @@ vm_pageout_end_scan(struct scan_state *ss)
 }
 
 /*
- * Ensure that the page has not been dequeued after a pageout batch was
- * collected.  See vm_page_dequeue_complete().
- */
-static inline bool
-vm_pageout_page_queued(vm_page_t m, int queue)
-{
-
-   vm_page_assert_locked(m);
-
-   if ((m->aflags & PGA_DEQUEUE) != 0)
-   return (false);
-   atomic_thread_fence_acq();
-   return (m->queue == queue);
-}
-
-/*
  * Add a small number of queued pages to a batch queue for later processing
  * without the corresponding queue lock held.  The caller must have enqueued a
  * marker page at the desired start point for the scan.  Pages will be
  * physically dequeued if the caller so requests.  Otherwise, the returned
  * batch may contain marker pages, and it is up to the caller to handle them.
  *
- * When processing the batch queue, vm_pageout_page_queued() must be used to
- * determine whether the page was logically dequeued by another thread.  Once
- * this check is performed, the page lock guarantees that the page will not be
- * disassociated from the queue.
+ * When processing the batch queue, vm_page_queue() must be used to
+ * determine whether the page has been logically dequeued by another thread.
+ * Once this check is performed, the page lock guarantees that the page will
+ * not be disassociated from the queue.
  */
 static __always_inline void
 vm_pageout_collect_batch(struct scan_state *ss, const bool dequeue)
@@ -751,7 +735,7 @@ recheck:
 * The page may have been disassociated from the queue
 * while locks were dropped.
 */
-   if (!vm_pageout_page_queued(m, queue))
+   if (vm_page_queue(m) != queue)
continue;
 
/*
@@ -1262,7 +1246,7 @@ recheck:
 * The page may have been disassociated from the queue
 * while locks were dropped.
 */
-   if (!vm_pageout_page_queued(m, PQ_INACTIVE)) {
+   if (vm_page_queue(m) != PQ_INACTIVE) {
addl_page_shortage++;
continue;
}
@@ -1542,7 +1526,7 @@ act_scan:
 * The page may have been disassociated from the queue
 * while locks were dropped.
 */
-   if (!vm_pageout_page_queued(m, PQ_ACTIVE))
+   if (vm_page_queue(m) != PQ_ACTIVE)
continue;
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333580 - head/sys/fs/nfsserver

2018-05-13 Thread Rick Macklem
Author: rmacklem
Date: Sun May 13 12:42:53 2018
New Revision: 333580
URL: https://svnweb.freebsd.org/changeset/base/333580

Log:
  Fix a slow leak of session structures in the NFSv4.1 server.
  
  For a fairly rare case of a client doing an ExchangeID after a hard reboot,
  the old confirmed clientid still exists, but some clients use a new
  co_verifier. For this case, the server was not freeing up the sessions on
  the old confirmed clientid.
  This patch fixes this case. It also adds two LIST_INIT() macros, which are
  actually no-ops, since the structure is malloc()d with M_ZERO so the pointer
  is already set to NULL.
  It should have minimal impact, since the only way I could exercise this
  code path was by doing a hard power cycle (pulling the plus) on a machine
  running Linux with a NFSv4.1 mount on the server.
  Originally spotted during testing of the ESXi 6.5 client.
  
  Tested by:andreas.n...@frequentis.com
  MFC after:2 months

Modified:
  head/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c
==
--- head/sys/fs/nfsserver/nfs_nfsdstate.c   Sun May 13 12:29:09 2018
(r333579)
+++ head/sys/fs/nfsserver/nfs_nfsdstate.c   Sun May 13 12:42:53 2018
(r333580)
@@ -180,9 +180,10 @@ nfsrv_setclient(struct nfsrv_descript *nd, struct nfsc
 nfsquad_t *clientidp, nfsquad_t *confirmp, NFSPROC_T *p)
 {
struct nfsclient *clp = NULL, *new_clp = *new_clpp;
-   int i, error = 0;
+   int i, error = 0, ret;
struct nfsstate *stp, *tstp;
struct sockaddr_in *sad, *rad;
+   struct nfsdsession *sep, *nsep;
int zapit = 0, gotit, hasstate = 0, igotlock;
static u_int64_t confirm_index = 0;
 
@@ -352,6 +353,15 @@ nfsrv_setclient(struct nfsrv_descript *nd, struct nfsc
 * can be thrown away once the SETCLIENTID_CONFIRM occurs.
 */
LIST_REMOVE(clp, lc_hash);
+
+   /* Get rid of all sessions on this clientid. */
+   LIST_FOREACH_SAFE(sep, &clp->lc_session, sess_list, nsep) {
+   ret = nfsrv_freesession(sep, NULL);
+   if (ret != 0)
+   printf("nfsrv_setclient: verifier changed free"
+   " session failed=%d\n", ret);
+   }
+
new_clp->lc_flags |= LCL_NEEDSCONFIRM;
if ((nd->nd_flag & ND_NFSV41) != 0)
new_clp->lc_confirm.lval[0] = confirmp->lval[0] =
@@ -387,6 +397,7 @@ nfsrv_setclient(struct nfsrv_descript *nd, struct nfsc
LIST_FOREACH(tstp, &new_clp->lc_stateid[i], ls_hash)
tstp->ls_clp = new_clp;
}
+   LIST_INIT(&new_clp->lc_session);
LIST_INSERT_HEAD(NFSCLIENTHASH(new_clp->lc_clientid), new_clp,
lc_hash);
nfsstatsv1.srvclients++;
@@ -451,6 +462,7 @@ nfsrv_setclient(struct nfsrv_descript *nd, struct nfsc
LIST_FOREACH(tstp, &new_clp->lc_stateid[i], ls_hash)
tstp->ls_clp = new_clp;
}
+   LIST_INIT(&new_clp->lc_session);
LIST_INSERT_HEAD(NFSCLIENTHASH(new_clp->lc_clientid), new_clp,
lc_hash);
nfsstatsv1.srvclients++;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333579 - head/sys/fs/nfsserver

2018-05-13 Thread Rick Macklem
Author: rmacklem
Date: Sun May 13 12:29:09 2018
New Revision: 333579
URL: https://svnweb.freebsd.org/changeset/base/333579

Log:
  The NFSv4.1 server should return NFSERR_BACKCHANBUSY instead of NFS_OK.
  
  When an NFSv4.1 session is busy due to a callback being in progress,
  nfsrv_freesession() should return NFSERR_BACKCHANBUSY instead of NFS_OK.
  The only effect this has is that the DestroySession operation will report
  the failure for this case and this probably has little or no effect on a
  client. Spotted by inspection and no failures related to this have been
  reported.
  
  MFC after:2 months

Modified:
  head/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c
==
--- head/sys/fs/nfsserver/nfs_nfsdstate.c   Sun May 13 11:31:32 2018
(r333578)
+++ head/sys/fs/nfsserver/nfs_nfsdstate.c   Sun May 13 12:29:09 2018
(r333579)
@@ -5982,7 +5982,7 @@ nfsrv_freesession(struct nfsdsession *sep, uint8_t *se
if (sep->sess_refcnt > 0) {
NFSUNLOCKSESSION(shp);
NFSUNLOCKSTATE();
-   return (0);
+   return (NFSERR_BACKCHANBUSY);
}
LIST_REMOVE(sep, sess_hash);
LIST_REMOVE(sep, sess_list);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333577 - in head: include lib/libc/softfloat/bits64 lib/msun lib/msun/man lib/msun/src

2018-05-13 Thread Konstantin Belousov
Author: kib
Date: Sun May 13 09:54:34 2018
New Revision: 333577
URL: https://svnweb.freebsd.org/changeset/base/333577

Log:
  Add implementations for clog(3), clogf(3), and clog(3).
  
  PR:   216863
  Submitted by: bde, Steven G. Kargl 
  MFC after:2 weeks

Added:
  head/lib/msun/man/clog.3   (contents, props changed)
  head/lib/msun/src/s_clog.c   (contents, props changed)
  head/lib/msun/src/s_clogf.c   (contents, props changed)
  head/lib/msun/src/s_clogl.c   (contents, props changed)
Modified:
  head/include/complex.h
  head/lib/libc/softfloat/bits64/softfloat-macros
  head/lib/msun/Makefile
  head/lib/msun/Symbol.map
  head/lib/msun/man/complex.3
  head/lib/msun/src/math_private.h

Modified: head/include/complex.h
==
--- head/include/complex.h  Sun May 13 09:47:28 2018(r333576)
+++ head/include/complex.h  Sun May 13 09:54:34 2018(r333577)
@@ -101,6 +101,10 @@ float complex  cexpf(float complex);
 double cimag(double complex) __pure2;
 float  cimagf(float complex) __pure2;
 long doublecimagl(long double complex) __pure2;
+double complex clog(double complex);
+float complex  clogf(float complex);
+long double complex
+   clogl(long double complex);
 double complex conj(double complex) __pure2;
 float complex  conjf(float complex) __pure2;
 long double complex

Modified: head/lib/libc/softfloat/bits64/softfloat-macros
==
--- head/lib/libc/softfloat/bits64/softfloat-macros Sun May 13 09:47:28 
2018(r333576)
+++ head/lib/libc/softfloat/bits64/softfloat-macros Sun May 13 09:54:34 
2018(r333577)
@@ -157,7 +157,7 @@ INLINE void
 z0 = a0>>count;
 }
 else {
-z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0;
+z1 = ( count < 128 ) ? ( a0>>( count & 63 ) ) : 0;
 z0 = 0;
 }
 *z1Ptr = z1;

Modified: head/lib/msun/Makefile
==
--- head/lib/msun/Makefile  Sun May 13 09:47:28 2018(r333576)
+++ head/lib/msun/Makefile  Sun May 13 09:54:34 2018(r333577)
@@ -57,7 +57,7 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
k_cos.c k_cosf.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_sinf.c \
k_tan.c k_tanf.c \
s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \
-   s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c \
+   s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c s_clog.c s_clogf.c \
s_copysign.c s_copysignf.c s_cos.c s_cosf.c \
s_csqrt.c s_csqrtf.c s_erf.c s_erff.c \
s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c \
@@ -101,7 +101,8 @@ COMMON_SRCS+=   catrigl.c \
e_lgammal.c e_lgammal_r.c \
e_remainderl.c e_sinhl.c e_sqrtl.c \
invtrig.c k_cosl.c k_sinl.c k_tanl.c \
-   s_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c s_cosl.c s_cprojl.c \
+   s_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c \
+   s_clogl.c s_cosl.c s_cprojl.c \
s_csqrtl.c s_erfl.c s_exp2l.c s_expl.c s_floorl.c s_fmal.c \
s_fmaxl.c s_fminl.c s_frexpl.c s_logbl.c s_logl.c s_nanl.c \
s_nextafterl.c s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c \
@@ -133,7 +134,8 @@ INCS+=  fenv.h math.h
 
 MAN=   acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \
ceil.3 cacos.3 ccos.3 ccosh.3 cexp.3 \
-   cimag.3 copysign.3 cos.3 cosh.3 csqrt.3 erf.3 exp.3 fabs.3 fdim.3 \
+   cimag.3 clog.3 copysign.3 cos.3 cosh.3 csqrt.3 erf.3 \
+   exp.3 fabs.3 fdim.3 \
feclearexcept.3 feenableexcept.3 fegetenv.3 \
fegetround.3 fenv.3 floor.3 \
fma.3 fmax.3 fmod.3 hypot.3 ieee.3 ieee_test.3 ilogb.3 j0.3 \
@@ -166,6 +168,7 @@ MLINKS+=cimag.3 cimagf.3 cimag.3 cimagl.3 \
cimag.3 conj.3 cimag.3 conjf.3 cimag.3 conjl.3 \
cimag.3 cproj.3 cimag.3 cprojf.3 cimag.3 cprojl.3 \
cimag.3 creal.3 cimag.3 crealf.3 cimag.3 creall.3
+MLINKS+=clog.3 clogf.3 clog.3 clogl.3
 MLINKS+=copysign.3 copysignf.3 copysign.3 copysignl.3
 MLINKS+=cos.3 cosf.3 cos.3 cosl.3
 MLINKS+=cosh.3 coshf.3 cosh.3 coshl.3

Modified: head/lib/msun/Symbol.map
==
--- head/lib/msun/Symbol.mapSun May 13 09:47:28 2018(r333576)
+++ head/lib/msun/Symbol.mapSun May 13 09:54:34 2018(r333577)
@@ -294,6 +294,9 @@ FBSD_1.5 {
casinl;
catanl;
catanhl;
+   clog;
+   clogf;
+   clogl;
sincos;
sincosf;
sincosl;

Added: head/lib/msun/man/clog.3
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/msun/man/clog.3Sun May 13 09:54:34 2018(r333577)
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2017 Steven G. Kargl 
+.\" All rights

svn commit: r333576 - in head/sys: kern sys ufs/ffs

2018-05-13 Thread Konstantin Belousov
Author: kib
Date: Sun May 13 09:47:28 2018
New Revision: 333576
URL: https://svnweb.freebsd.org/changeset/base/333576

Log:
  Detect and optimize reads from the hole on UFS.
  
  - Create getblkx(9) variant of getblk(9) which can return error.
  - Add GB_NOSPARSE flag for getblk()/getblkx() which requests that BMAP
was performed before the buffer is created, and EJUSTRETURN returned
in case the requested block does not exist.
  - Make ffs_read() use GB_NOSPARSE to avoid instantiating buffer (and
allocating the pages for it), copying from zero_region instead.
  
  The end result is less page allocations and buffer recycling when a
  hole is read, which is important for some benchmarks.
  
  Requested and reviewed by:jeff
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D14917

Modified:
  head/sys/kern/vfs_bio.c
  head/sys/kern/vfs_cluster.c
  head/sys/sys/buf.h
  head/sys/ufs/ffs/ffs_vnops.c

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Sat May 12 20:00:29 2018(r333575)
+++ head/sys/kern/vfs_bio.c Sun May 13 09:47:28 2018(r333576)
@@ -2138,30 +2138,37 @@ breadn_flags(struct vnode *vp, daddr_t blkno, int size
 void (*ckhashfunc)(struct buf *), struct buf **bpp)
 {
struct buf *bp;
-   int readwait, rv;
+   struct thread *td;
+   int error, readwait, rv;
 
CTR3(KTR_BUF, "breadn(%p, %jd, %d)", vp, blkno, size);
+   td = curthread;
/*
-* Can only return NULL if GB_LOCK_NOWAIT flag is specified.
+* Can only return NULL if GB_LOCK_NOWAIT or GB_SPARSE flags
+* are specified.
 */
-   *bpp = bp = getblk(vp, blkno, size, 0, 0, flags);
-   if (bp == NULL)
-   return (EBUSY);
+   error = getblkx(vp, blkno, size, 0, 0, flags, &bp);
+   if (error != 0) {
+   *bpp = NULL;
+   return (error);
+   }
+   flags &= ~GB_NOSPARSE;
+   *bpp = bp;
 
/*
 * If not found in cache, do some I/O
 */
readwait = 0;
if ((bp->b_flags & B_CACHE) == 0) {
-   if (!TD_IS_IDLETHREAD(curthread)) {
+   if (!TD_IS_IDLETHREAD(td)) {
 #ifdef RACCT
if (racct_enable) {
-   PROC_LOCK(curproc);
-   racct_add_buf(curproc, bp, 0);
-   PROC_UNLOCK(curproc);
+   PROC_LOCK(td->td_proc);
+   racct_add_buf(td->td_proc, bp, 0);
+   PROC_UNLOCK(td->td_proc);
}
 #endif /* RACCT */
-   curthread->td_ru.ru_inblock++;
+   td->td_ru.ru_inblock++;
}
bp->b_iocmd = BIO_READ;
bp->b_flags &= ~B_INVAL;
@@ -3822,8 +3829,21 @@ has_addr:
}
 }
 
+struct buf *
+getblk(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo,
+int flags)
+{
+   struct buf *bp;
+   int error;
+
+   error = getblkx(vp, blkno, size, slpflag, slptimeo, flags, &bp);
+   if (error != 0)
+   return (NULL);
+   return (bp);
+}
+
 /*
- * getblk:
+ * getblkx:
  *
  * Get a block given a specified block and offset into a file/device.
  * The buffers B_DONE bit will be cleared on return, making it almost
@@ -3858,12 +3878,13 @@ has_addr:
  * intends to issue a READ, the caller must clear B_INVAL and BIO_ERROR
  * prior to issuing the READ.  biodone() will *not* clear B_INVAL.
  */
-struct buf *
-getblk(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo,
-int flags)
+int
+getblkx(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo,
+int flags, struct buf **bpp)
 {
struct buf *bp;
struct bufobj *bo;
+   daddr_t d_blkno;
int bsize, error, maxsize, vmio;
off_t offset;
 
@@ -3878,6 +3899,7 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int 
flags &= ~(GB_UNMAPPED | GB_KVAALLOC);
 
bo = &vp->v_bufobj;
+   d_blkno = blkno;
 loop:
BO_RLOCK(bo);
bp = gbincore(bo, blkno);
@@ -3889,7 +3911,7 @@ loop:
 */
lockflags = LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK;
 
-   if (flags & GB_LOCK_NOWAIT)
+   if ((flags & GB_LOCK_NOWAIT) != 0)
lockflags |= LK_NOWAIT;
 
error = BUF_TIMELOCK(bp, lockflags,
@@ -3902,8 +3924,8 @@ loop:
if (error == ENOLCK)
goto loop;
/* We timed out or were interrupted. */
-   else if (error)
-   return (NULL);
+   else if (error != 0)
+   return (error);