The NetBSD Project

CVS log for src/sys/kern/subr_copy.c

[BACK] Up to [cvs.NetBSD.org] / src / sys / kern

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.19: download - view: text, markup, annotated - select for diffs
Mon May 22 14:07:24 2023 UTC (18 months, 3 weeks ago) by riastradh
Branches: MAIN
CVS tags: thorpej-ifq-base, thorpej-ifq, thorpej-altq-separation-base, thorpej-altq-separation, perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, HEAD
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +89 -2 lines
uiomove(9): Add uiopeek/uioskip operations.

This allows a caller to grab some data, consume part of it, and
atomically update the uio with only the amount it consumed.  This
way, the caller can use a buffer of a size that doesn't depend on how
much it will actually consume, which it may not know in advance --
e.g., because it depends on how much an underlying hardware tty
device will accept before it decides it has had too much.

Proposed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/05/09/msg028883.html

(Opinions were divided between `uioadvance' and `uioskip'.  I stuck
with `uioskip' because that was less work for me.)

Revision 1.18: download - view: text, markup, annotated - select for diffs
Tue Apr 11 10:22:04 2023 UTC (20 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +4 -3 lines
uiomove(9): Stronger assertions about iov array.

Revision 1.17: download - view: text, markup, annotated - select for diffs
Fri Feb 24 11:02:27 2023 UTC (21 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +2 -4 lines
kern: Eliminate most __HAVE_ATOMIC_AS_MEMBAR conditionals.

I'm leaving in the conditional around the legacy membar_enters
(store-before-load, store-before-store) in kern_mutex.c and in
kern_lock.c because they may still matter: store-before-load barriers
tend to be the most expensive kind, so eliding them is probably
worthwhile on x86.  (It also may not matter; I just don't care to do
measurements right now, and it's a single valid and potentially
justifiable use case in the whole tree.)

However, membar_release/acquire can be mere instruction barriers on
all TSO platforms including x86, so there's no need to go out of our
way with a bad API to conditionalize them.  If the procedure call
overhead is measurable we just could change them to be macros on x86
that expand into __insn_barrier.

Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html

Revision 1.16: download - view: text, markup, annotated - select for diffs
Sat Apr 9 23:51:09 2022 UTC (2 years, 8 months ago) by riastradh
Branches: MAIN
CVS tags: netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, bouyer-sunxi-drm-base, bouyer-sunxi-drm
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +4 -4 lines
ucas(9): Convert membar_exit to membar_release.

Revision 1.15: download - view: text, markup, annotated - select for diffs
Fri Feb 11 17:53:28 2022 UTC (2 years, 10 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +49 -9 lines
ucas(9): Membar audit.

- Omit needless membar_enter before ipi_trigger_broadcast.  This was
  presumably intended to imply a happens-before relation for the
  following two CPUs:

	/* CPU doing ucas */
	ucas_critical_enter()
		ucas_critical_pausing_cpus = ncpu - 1	(A)
		ipi_trigger_broadcast()

	/* other CPU walking by whistling innocently */
	IPI handler
	ucas_critical_cpu_gate()
		load ucas_critical_pausing_cpus		(B)

  That is, this was presumably meant to ensure (A) happens-before (B).
  This relation is already guaranteed by ipi(9), so there is no need
  for any explicit memory barrier.

- Issue a store-release in ucas_critical_cpu_gate so we have the
  following happens-before relation which was otherwise not guaranteed
  except if __HAVE_ATOMIC_AS_MEMBAR:

	/* other CPU walking by whistling innocently */
	...other logic touching the target ucas word...	(A)
	IPI handler
	ucas_critical_cpu_gate()
		...
		atomic_dec_uint(&ucas_critical_pausing_cpus)

  happens-before

	/* CPU doing ucas */
	ucas_critical_enter() -> ucas_critical_wait();
	...touching the word with ufetch/ustore...	(B)

  We need to ensure the logic (A) on another CPU touching the target
  ucas word happens-before we actually do the ucas at (B).

  (a) This requires the other CPU to do a store-release on
      ucas_critical_pausing_cpus in ucas_critical_cpu_gate, and

  (b) this requires the ucas CPU to do a load-acquire on
      ucas_critical_pausing_cpus in ucas_critical_wait.

  Without _both_ sides -- store-release and then load-acquire -- there
  is no such happens-before guarantee; another CPU may have a buffered
  store, for instance, that clobbers the ucas.

  For now, do the store-release with membar_exit conditional on
  __HAVE_ATOMIC_AS_MEMBAR and then atomic_dec_uint -- later with the
  C11 API we can dispense with the #ifdef and just use
  atomic_fetch_add_explicit(..., memory_order_release).  The
  load-acquire we can do with atomic_load_acquire.

- Issue a load-acquire in ucas_critical_cpu_gate so we have the
  following happens-before relation which was otherwise not guaranteed:

	/* CPU doing ucas */
	...ufetch/ustore...				(A)
	ucas_critical_exit()
		ucas_critical_pausing_cpus = -1;

	/* other CPU walking by whistling innocently */
	IPI handler
	ucas_critical_cpu_gate()
		...
		while (ucas_critical_pausing_cpus != -1)
			spin;
	...other logic touching the target ucas word...	(B)

  We need to ensure the logic (A) to do the ucas happens-before logic
  that might use it on another CPU at (B).

  (a) This requires that the ucas CPU do a store-release on
      ucas_critical_pausing_cpus in ucas_critical_exit, and

  (b) this requires that the other CPU do a load-acquire on
      ucas_critical_pausing_cpus in ucas_critical_cpu_gate.

  Without _both_ sides -- store-release and then load-acquire -- there
  is no such happens-before guarantee; the other CPU might witness a
  cached stale value of the target location but a new value of some
  other location in the wrong order.

- Use atomic_load/store_* to avoid the appearance of races, e.g. for
  sanitizers.

- Document which barriers pair up with which barriers and what they're
  doing.

Revision 1.14: download - view: text, markup, annotated - select for diffs
Sat May 23 23:42:43 2020 UTC (4 years, 6 months ago) by ad
Branches: MAIN
CVS tags: thorpej-i2c-spi-conf2-base, thorpej-i2c-spi-conf2, thorpej-i2c-spi-conf-base, thorpej-i2c-spi-conf, thorpej-futex2-base, thorpej-futex2, thorpej-futex-base, thorpej-futex, thorpej-cfargs2-base, thorpej-cfargs2, thorpej-cfargs-base, thorpej-cfargs, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +5 -5 lines
Move proc_lock into the data segment.  It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.

Revision 1.8.2.2: download - view: text, markup, annotated - select for diffs
Wed Apr 8 14:08:52 2020 UTC (4 years, 8 months ago) by martin
Branches: phil-wifi
Diff to: previous 1.8.2.1: preferred, colored; branchpoint 1.8: preferred, colored; next MAIN 1.9: preferred, colored
Changes since revision 1.8.2.1: +8 -9 lines
Merge changes from current as of 20200406

Revision 1.13: download - view: text, markup, annotated - select for diffs
Sat Mar 14 18:08:39 2020 UTC (4 years, 9 months ago) by ad
Branches: MAIN
CVS tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +3 -5 lines
- Hide the details of SPCF_SHOULDYIELD and related behind a couple of small
  functions: preempt_point() and preempt_needed().

- preempt(): if the LWP has exceeded its timeslice in kernel, strip it of
  any priority boost gained earlier from blocking.

Revision 1.11.6.1: download - view: text, markup, annotated - select for diffs
Sat Feb 29 20:21:03 2020 UTC (4 years, 9 months ago) by ad
Branches: ad-namecache
Diff to: previous 1.11: preferred, colored; next MAIN 1.12: preferred, colored
Changes since revision 1.11: +7 -6 lines
Sync with head.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Sat Feb 22 21:59:30 2020 UTC (4 years, 9 months ago) by chs
Branches: MAIN
CVS tags: is-mlppp-base, is-mlppp, ad-namecache-base3
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +7 -6 lines
check for errors from proc_vmspace_getref().

Revision 1.8.2.1: download - view: text, markup, annotated - select for diffs
Mon Jun 10 22:09:03 2019 UTC (5 years, 6 months ago) by christos
Branches: phil-wifi
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +324 -5 lines
Sync with HEAD

Revision 1.11: download - view: text, markup, annotated - select for diffs
Sun Apr 7 16:27:41 2019 UTC (5 years, 8 months ago) by thorpej
Branches: MAIN
CVS tags: phil-wifi-20191119, phil-wifi-20190609, netbsd-9-base, netbsd-9-4-RELEASE, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, isaki-audio2-base, isaki-audio2, ad-namecache-base2, ad-namecache-base1, ad-namecache-base
Branch point for: ad-namecache
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +6 -4 lines
Exclude references to _ucas_{32,64}_mp() for _RUMPKERNEL.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Sat Apr 6 15:52:35 2019 UTC (5 years, 8 months ago) by thorpej
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +12 -4 lines
Treat _RUMPKERNEL like a __HAVE_UCAS_FULL platform.  Add a comment
explaining what's going on.  Fixes librump build on sparc.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Sat Apr 6 03:06:28 2019 UTC (5 years, 8 months ago) by thorpej
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +314 -5 lines
Overhaul the API used to fetch and store individual memory cells in
userspace.  The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms.  The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.

Revision 1.7.16.1: download - view: text, markup, annotated - select for diffs
Mon Jun 25 07:26:04 2018 UTC (6 years, 5 months ago) by pgoyette
Branches: pgoyette-compat
CVS tags: pgoyette-compat-merge-20190127
Diff to: previous 1.7: preferred, colored; next MAIN 1.8: preferred, colored
Changes since revision 1.7: +29 -2 lines
Sync with HEAD

Revision 1.8: download - view: text, markup, annotated - select for diffs
Mon May 28 21:04:41 2018 UTC (6 years, 6 months ago) by chs
Branches: MAIN
CVS tags: phil-wifi-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625
Branch point for: phil-wifi
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +29 -2 lines
add copyin_pid(), to copyin from a different user address space.

Revision 1.1.24.1: download - view: text, markup, annotated - select for diffs
Sun Dec 3 11:38:45 2017 UTC (7 years ago) by jdolecek
Branches: tls-maxphys
Diff to: previous 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1: +3 -6 lines
update from HEAD

Revision 1.1.42.3: download - view: text, markup, annotated - select for diffs
Sun May 29 08:44:37 2016 UTC (8 years, 6 months ago) by skrll
Branches: nick-nhusb
Diff to: previous 1.1.42.2: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.42.2: +4 -4 lines
Sync with HEAD

Revision 1.7: download - view: text, markup, annotated - select for diffs
Wed May 25 17:43:58 2016 UTC (8 years, 6 months ago) by christos
Branches: MAIN
CVS tags: tls-maxphys-base-20171202, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-base, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, netbsd-8-base, netbsd-8-3-RELEASE, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, jdolecek-ncq-base, jdolecek-ncq, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: pgoyette-compat
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +4 -4 lines
Introduce security.pax.mprotect.ptrace sysctl which can be used to bypass
mprotect settings so that debuggers can write to the text segment of traced
processes so that they can insert breakpoints. Turned off by default.
Ok: chuq (for now)

Revision 1.1.42.2: download - view: text, markup, annotated - select for diffs
Sat Jun 6 14:40:22 2015 UTC (9 years, 6 months ago) by skrll
Branches: nick-nhusb
Diff to: previous 1.1.42.1: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.42.1: +3 -6 lines
Sync with HEAD

Revision 1.6: download - view: text, markup, annotated - select for diffs
Tue Apr 21 13:17:25 2015 UTC (9 years, 7 months ago) by riastradh
Branches: MAIN
CVS tags: nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +3 -6 lines
#ifdef DIAGNOSTIC panic -> KASSERT

Revision 1.1.42.1: download - view: text, markup, annotated - select for diffs
Mon Apr 6 15:18:20 2015 UTC (9 years, 8 months ago) by skrll
Branches: nick-nhusb
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +2 -2 lines
Sync with HEAD

Revision 1.5: download - view: text, markup, annotated - select for diffs
Sun Mar 29 17:38:31 2015 UTC (9 years, 8 months ago) by riastradh
Branches: MAIN
CVS tags: nick-nhusb-base-20150406
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +2 -12 lines
Back this out, per pooka's request.

Revision 1.4: download - view: text, markup, annotated - select for diffs
Sun Mar 29 15:08:03 2015 UTC (9 years, 8 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +12 -2 lines
Use #ifdef _RUMPKERNEL for now to prefer copyout over kcopy in tests.

Gross -- please fix me if you have a better approach.

Revision 1.3: download - view: text, markup, annotated - select for diffs
Sun Mar 29 15:05:34 2015 UTC (9 years, 8 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +8 -8 lines
Back out previous.

It appears to be causing anita install to fail.  Evidently
VM_SPACE_IS_KERNEL_P(vm) is not mutually exclusive with `vm ==
curproc->p_vmspace' -- in particular, proc0's VM space is kernel.

Making this work in rump for tests will require another approach.

Revision 1.2: download - view: text, markup, annotated - select for diffs
Sat Mar 28 16:13:38 2015 UTC (9 years, 8 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +8 -8 lines
Swap kernel/curproc tests in copy*_vmspace so rump can catch EFAULT.

Revision 1.1.4.2: download - view: text, markup, annotated - select for diffs
Thu Mar 11 15:04:18 2010 UTC (14 years, 9 months ago) by yamt
Branches: yamt-nfs-mp
Diff to: previous 1.1.4.1: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.4.1: +327 -0 lines
sync with head

Revision 1.1.4.1
Wed Nov 4 16:54:00 2009 UTC (15 years, 1 month ago) by yamt
Branches: yamt-nfs-mp
FILE REMOVED
Changes since revision 1.1: +0 -327 lines
file subr_copy.c was added on branch yamt-nfs-mp on 2010-03-11 15:04:18 +0000

Revision 1.1: download - view: text, markup, annotated - select for diffs
Wed Nov 4 16:54:00 2009 UTC (15 years, 1 month ago) by pooka
Branches: MAIN
CVS tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, yamt-nfs-mp-base9, yamt-nfs-mp-base11, yamt-nfs-mp-base10, uebayasi-xip-base4, uebayasi-xip-base3, uebayasi-xip-base2, uebayasi-xip-base1, uebayasi-xip-base, uebayasi-xip, tls-maxphys-base, tls-earlyentropy-base, tls-earlyentropy, rmind-uvmplock-nbase, rmind-uvmplock-base, rmind-uvmplock, rmind-smpnet-nbase, rmind-smpnet-base, rmind-smpnet, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, nick-nhusb-base, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-premerge-20091211, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, khorben-n900, jruoho-x86intr-base, jruoho-x86intr, jmcneill-usbmp-pre-base2, jmcneill-usbmp-base9, jmcneill-usbmp-base8, jmcneill-usbmp-base7, jmcneill-usbmp-base6, jmcneill-usbmp-base5, jmcneill-usbmp-base4, jmcneill-usbmp-base3, jmcneill-usbmp-base2, jmcneill-usbmp-base10, jmcneill-usbmp-base, jmcneill-usbmp, jmcneill-audiomp3-base, jmcneill-audiomp3, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Branch point for: yamt-nfs-mp, tls-maxphys, nick-nhusb
Split uiomove() and high-level copy routines out of the crowded
kern_subr and into their own cozy home in subr_copy.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>