The NetBSD Project

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

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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.14 / (download) - annotate - [select for diffs], Sat Apr 9 23:38:33 2022 UTC (9 months, 4 weeks ago) by riastradh
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10, bouyer-sunxi-drm-base, bouyer-sunxi-drm, HEAD
Changes since 1.13: +4 -4 lines
Diff to previous 1.13 (colored)

sys: Use membar_release/acquire around reference drop.

This just goes through my recent reference count membar audit and
changes membar_exit to membar_release and membar_enter to
membar_acquire -- this should make everything cheaper on most CPUs
without hurting correctness, because membar_acquire is generally
cheaper than membar_enter.

Revision 1.13 / (download) - annotate - [select for diffs], Sat Mar 12 15:32:32 2022 UTC (10 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.12: +4 -2 lines
Diff to previous 1.12 (colored)

sys: Membar audit around reference count releases.

If two threads are using an object that is freed when the reference
count goes to zero, we need to ensure that all memory operations
related to the object happen before freeing the object.

Using an atomic_dec_uint_nv(&refcnt) == 0 ensures that only one
thread takes responsibility for freeing, but it's not enough to
ensure that the other thread's memory operations happen before the
freeing.

Consider:

	  Thread A			  Thread B
	obj->foo = 42;			obj->baz = 73;
	mumble(&obj->bar);		grumble(&obj->quux);
	/* membar_exit(); */		/* membar_exit(); */
	atomic_dec -- not last		atomic_dec -- last
					/* membar_enter(); */
					KASSERT(invariant(obj->foo,
					    obj->bar));
					free_stuff(obj);

The memory barriers ensure that

	obj->foo = 42;
	mumble(&obj->bar);

in thread A happens before

	KASSERT(invariant(obj->foo, obj->bar));
	free_stuff(obj);

in thread B.  Without them, this ordering is not guaranteed.

So in general it is necessary to do

	membar_exit();
	if (atomic_dec_uint_nv(&obj->refcnt) != 0)
		return;
	membar_enter();

to release a reference, for the `last one out hit the lights' style
of reference counting.  (This is in contrast to the style where one
thread blocks new references and then waits under a lock for existing
ones to drain with a condvar -- no membar needed thanks to mutex(9).)

I searched for atomic_dec to find all these.  Obviously we ought to
have a better abstraction for this because there's so much copypasta.
This is a stop-gap measure to fix actual bugs until we have that.  It
would be nice if an abstraction could gracefully handle the different
styles of reference counting in use -- some years ago I drafted an
API for this, but making it cover everything got a little out of hand
(particularly with struct vnode::v_usecount) and I ended up setting
it aside to work on psref/localcount instead for better scalability.

I got bored of adding #ifdef __HAVE_ATOMIC_AS_MEMBAR everywhere, so I
only put it on things that look performance-critical on 5sec review.
We should really adopt membar_enter_preatomic/membar_exit_postatomic
or something (except they are applicable only to atomic r/m/w, not to
atomic_load/store_*, making the naming annoying) and get rid of all
the ifdefs.

Revision 1.11.28.1 / (download) - annotate - [select for diffs], Mon Apr 13 08:05:04 2020 UTC (2 years, 9 months ago) by martin
Branch: phil-wifi
Changes since 1.11: +8 -8 lines
Diff to previous 1.11 (colored) next main 1.12 (colored)

Mostly merge changes from HEAD upto 20200411

Revision 1.12 / (download) - annotate - [select for diffs], Fri Jul 26 05:39:55 2019 UTC (3 years, 6 months ago) by msaitoh
Branch: 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, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, netbsd-9-base, 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, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, ad-namecache-base3, ad-namecache-base2, ad-namecache-base1, ad-namecache-base, ad-namecache
Changes since 1.11: +8 -8 lines
Diff to previous 1.11 (colored)

 Set kcpuset's bit correctly to avoid undefined behavior. Found by KUBSan.

Revision 1.7.2.2 / (download) - annotate - [select for diffs], Wed Aug 20 00:04:29 2014 UTC (8 years, 5 months ago) by tls
Branch: tls-maxphys
Changes since 1.7.2.1: +95 -14 lines
Diff to previous 1.7.2.1 (colored) next main 1.8 (colored)

Rebase to HEAD as of a few days ago.

Revision 1.10.2.1 / (download) - annotate - [select for diffs], Sun Aug 10 06:55:58 2014 UTC (8 years, 6 months ago) by tls
Branch: tls-earlyentropy
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored) next main 1.11 (colored)

Rebase.

Revision 1.3.2.4 / (download) - annotate - [select for diffs], Thu May 22 11:41:03 2014 UTC (8 years, 8 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.3.2.3: +94 -13 lines
Diff to previous 1.3.2.3 (colored) to branchpoint 1.3 (colored) next main 1.4 (colored)

sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")

Revision 1.11 / (download) - annotate - [select for diffs], Mon May 19 20:39:23 2014 UTC (8 years, 8 months ago) by rmind
Branch: MAIN
CVS Tags: tls-maxphys-base-20171202, tls-maxphys-base, tls-earlyentropy-base, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20190609, 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-merge-20190127, pgoyette-compat-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, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, 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, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606, nick-nhusb-base-20150406, nick-nhusb-base, nick-nhusb, netbsd-8-base, 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, 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, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, jdolecek-ncq-base, jdolecek-ncq, isaki-audio2-base, isaki-audio2, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: phil-wifi
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

Constify kcpuset_countset() and cpu_index() parameters.

Revision 1.8.2.2 / (download) - annotate - [select for diffs], Sun May 18 17:46:07 2014 UTC (8 years, 8 months ago) by rmind
Branch: rmind-smpnet
Changes since 1.8.2.1: +4 -4 lines
Diff to previous 1.8.2.1 (colored) to branchpoint 1.8 (colored) next main 1.9 (colored)

sync with head

Revision 1.10 / (download) - annotate - [select for diffs], Fri Oct 25 11:35:55 2013 UTC (9 years, 3 months ago) by martin
Branch: MAIN
CVS Tags: yamt-pagecache-base9, rmind-smpnet-nbase, rmind-smpnet-base, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3
Branch point for: tls-earlyentropy
Changes since 1.9: +4 -4 lines
Diff to previous 1.9 (colored)

Turn a few __unused into __diagused

Revision 1.8.2.1 / (download) - annotate - [select for diffs], Wed Aug 28 23:59:35 2013 UTC (9 years, 5 months ago) by rmind
Branch: rmind-smpnet
Changes since 1.8: +92 -11 lines
Diff to previous 1.8 (colored)

sync with head

Revision 1.8.8.1 / (download) - annotate - [select for diffs], Tue Jul 23 21:07:36 2013 UTC (9 years, 6 months ago) by riastradh
Branch: riastradh-drm2
Changes since 1.8: +92 -11 lines
Diff to previous 1.8 (colored) next main 1.9 (colored)

sync with HEAD

Revision 1.9 / (download) - annotate - [select for diffs], Wed Jul 17 22:36:26 2013 UTC (9 years, 6 months ago) by matt
Branch: MAIN
CVS Tags: riastradh-drm2-base2, riastradh-drm2-base1
Changes since 1.8: +92 -11 lines
Diff to previous 1.8 (colored)

Some constification.
Add kcpuset_clone, kcpuset_insersection, kcpuset_remove,
kcpuset_ffs, kcpuset_ffs_intersecting,
kcpuset_atomicly_merge, kcpuset_atomicly_intersect, kcpuset_atomicly_remove

Revision 1.7.2.1 / (download) - annotate - [select for diffs], Tue Nov 20 03:02:43 2012 UTC (10 years, 2 months ago) by tls
Branch: tls-maxphys
Changes since 1.7: +3 -3 lines
Diff to previous 1.7 (colored)

Resync to 2012-11-19 00:00:00 UTC

Revision 1.3.2.3 / (download) - annotate - [select for diffs], Tue Oct 30 17:22:33 2012 UTC (10 years, 3 months ago) by yamt
Branch: yamt-pagecache
CVS Tags: yamt-pagecache-tag8
Changes since 1.3.2.2: +11 -2 lines
Diff to previous 1.3.2.2 (colored) to branchpoint 1.3 (colored)

sync with head

Revision 1.8 / (download) - annotate - [select for diffs], Sun Sep 16 22:09:33 2012 UTC (10 years, 4 months ago) by rmind
Branch: MAIN
CVS Tags: yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, riastradh-drm2-base, khorben-n900, agc-symver-base, agc-symver
Branch point for: rmind-smpnet, riastradh-drm2
Changes since 1.7: +3 -3 lines
Diff to previous 1.7 (colored)

Rename kcpuset_copybits() to kcpuset_export_u32() and thus be more specific
about the interface.

Revision 1.7 / (download) - annotate - [select for diffs], Mon Aug 20 22:01:29 2012 UTC (10 years, 5 months ago) by rmind
Branch: MAIN
Branch point for: tls-maxphys
Changes since 1.6: +3 -3 lines
Diff to previous 1.6 (colored)

kcpuset_copybits: fix potential endianness problem.  Spotted by matt@.

Revision 1.4.2.2 / (download) - annotate - [select for diffs], Tue Jun 12 19:00:25 2012 UTC (10 years, 7 months ago) by riz
Branch: netbsd-6
CVS Tags: 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, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus
Changes since 1.4.2.1: +11 -2 lines
Diff to previous 1.4.2.1 (colored) to branchpoint 1.4 (colored) next main 1.5 (colored)

Pull up following revision(s) (requested by rmind in ticket #314):
	sys/arch/xen/x86/cpu.c: revision 1.92
	sys/kern/subr_kcpuset.c: revision 1.6
	sys/sys/kcpuset.h: revision 1.6
	sys/arch/xen/x86/x86_xpmap.c: revision 1.44
Few fixes for Xen:
- cpu_load_pmap: use atomic kcpuset(9) operations; fixes rare crashes.
- Add kcpuset_copybits(9) and replace xen_kcpuset2bits().  Avoids incorrect
  ncpu problem in early boot.  Also, micro-optimises xen_mcast_invlpg() and
  xen_mcast_tlbflush() routines.
Tested by chs@.

Revision 1.6 / (download) - annotate - [select for diffs], Wed Jun 6 22:22:41 2012 UTC (10 years, 8 months ago) by rmind
Branch: MAIN
Changes since 1.5: +11 -2 lines
Diff to previous 1.5 (colored)

Few fixes for Xen:
- cpu_load_pmap: use atomic kcpuset(9) operations; fixes rare crashes.
- Add kcpuset_copybits(9) and replace xen_kcpuset2bits().  Avoids incorrect
  ncpu problem in early boot.  Also, micro-optimises xen_mcast_invlpg() and
  xen_mcast_tlbflush() routines.

Tested by chs@.

Revision 1.3.2.2 / (download) - annotate - [select for diffs], Wed May 23 10:08:11 2012 UTC (10 years, 8 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.3.2.1: +19 -12 lines
Diff to previous 1.3.2.1 (colored) to branchpoint 1.3 (colored)

sync with head.

Revision 1.4.2.1 / (download) - annotate - [select for diffs], Wed May 9 03:22:54 2012 UTC (10 years, 9 months ago) by riz
Branch: netbsd-6
Changes since 1.4: +19 -12 lines
Diff to previous 1.4 (colored)

Pull up following revision(s) (requested by rmind in ticket #202):
	sys/arch/x86/include/cpuvar.h: revision 1.46
	sys/arch/xen/include/xenpmap.h: revision 1.34
	sys/arch/i386/include/param.h: revision 1.77
	sys/arch/x86/x86/pmap_tlb.c: revision 1.5
	sys/arch/x86/x86/pmap_tlb.c: revision 1.6
	sys/arch/i386/i386/genassym.cf: revision 1.92
	sys/arch/xen/x86/cpu.c: revision 1.91
	sys/arch/x86/x86/pmap.c: revision 1.177
	sys/arch/xen/x86/xen_pmap.c: revision 1.21
	sys/arch/x86/acpi/acpi_wakeup.c: revision 1.31
	sys/kern/subr_kcpuset.c: revision 1.5
	sys/arch/amd64/include/param.h: revision 1.18
	sys/sys/kcpuset.h: revision 1.5
	sys/arch/x86/x86/mtrr_i686.c: revision 1.26
	sys/arch/x86/x86/mtrr_i686.c: revision 1.27
	sys/arch/xen/x86/x86_xpmap.c: revision 1.43
	sys/arch/x86/x86/cpu.c: revision 1.98
	sys/arch/amd64/amd64/mptramp.S: revision 1.14
	sys/kern/sys_sched.c: revision 1.42
	sys/arch/amd64/amd64/genassym.cf: revision 1.50
	sys/arch/i386/i386/mptramp.S: revision 1.24
	sys/arch/x86/include/pmap.h: revision 1.52
	sys/arch/x86/include/cpu.h: revision 1.50
- Convert x86 MD code, mainly pmap(9) e.g. TLB shootdown code, to use
  kcpuset(9) and thus replace hardcoded CPU bitmasks.  This removes the
  limitation of maximum CPUs.
- Support up to 256 CPUs on amd64 architecture by default.
Bug fixes, improvements, completion of Xen part and testing on 64-core
AMD Opteron(tm) Processor 6282 SE (also, as Xen HVM domU with 128 CPUs)
by Manuel Bouyer.
- pmap_tlb_shootdown: do not overwrite tp_cpumask with pm_cpus, but merge
  like pm_kernel_cpus.  Remove unecessary intersection with kcpuset_running.
  Do not reset tp_userpmap if pmap_kernel().
- Remove pmap_tlb_mailbox_t wrapping, which is pointless after recent changes.
- pmap_tlb_invalidate, pmap_tlb_intr: constify for packet structure.
i686_mtrr_init_first: handle the case when there are no variable-size MTRR
registers available (i686_mtrr_vcnt == 0).

Revision 1.3.6.2 / (download) - annotate - [select for diffs], Sun Apr 29 23:05:05 2012 UTC (10 years, 9 months ago) by mrg
Branch: jmcneill-usbmp
Changes since 1.3.6.1: +19 -12 lines
Diff to previous 1.3.6.1 (colored) to branchpoint 1.3 (colored) next main 1.4 (colored)

sync to latest -current.

Revision 1.5 / (download) - annotate - [select for diffs], Fri Apr 20 22:23:25 2012 UTC (10 years, 9 months ago) by rmind
Branch: MAIN
CVS Tags: yamt-pagecache-base5, jmcneill-usbmp-base9, jmcneill-usbmp-base10
Changes since 1.4: +19 -12 lines
Diff to previous 1.4 (colored)

- Convert x86 MD code, mainly pmap(9) e.g. TLB shootdown code, to use
  kcpuset(9) and thus replace hardcoded CPU bitmasks.  This removes the
  limitation of maximum CPUs.

- Support up to 256 CPUs on amd64 architecture by default.

Bug fixes, improvements, completion of Xen part and testing on 64-core
AMD Opteron(tm) Processor 6282 SE (also, as Xen HVM domU with 128 CPUs)
by Manuel Bouyer.

Revision 1.3.2.1 / (download) - annotate - [select for diffs], Tue Apr 17 00:08:28 2012 UTC (10 years, 9 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.3: +43 -15 lines
Diff to previous 1.3 (colored)

sync with head

Revision 1.3.6.1 / (download) - annotate - [select for diffs], Sat Feb 18 07:35:32 2012 UTC (10 years, 11 months ago) by mrg
Branch: jmcneill-usbmp
Changes since 1.3: +43 -15 lines
Diff to previous 1.3 (colored)

merge to -current.

Revision 1.4 / (download) - annotate - [select for diffs], Sun Jan 29 19:08:26 2012 UTC (11 years ago) by rmind
Branch: MAIN
CVS Tags: yamt-pagecache-base4, netbsd-6-base, jmcneill-usbmp-base8, jmcneill-usbmp-base7, jmcneill-usbmp-base6, jmcneill-usbmp-base5, jmcneill-usbmp-base4, jmcneill-usbmp-base3, jmcneill-usbmp-base2
Branch point for: netbsd-6
Changes since 1.3: +43 -15 lines
Diff to previous 1.3 (colored)

- Add kcpuset_isotherset() and kcpuset_countset().
- Fix KC_NFIELDS_EARLY.  Make kcpuset_isset() return bool.

Revision 1.3 / (download) - annotate - [select for diffs], Sun Aug 7 21:38:32 2011 UTC (11 years, 6 months ago) by rmind
Branch: MAIN
CVS Tags: yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, jmcneill-usbmp-pre-base2, jmcneill-usbmp-base, jmcneill-audiomp3-base, jmcneill-audiomp3
Branch point for: yamt-pagecache, jmcneill-usbmp
Changes since 1.2: +43 -10 lines
Diff to previous 1.2 (colored)

- Add an argument to kcpuset_create() for zeroing.
- Add kcpuset_atomic_set(), kcpuset_atomic_clear() and kcpuset_merge().

Revision 1.2 / (download) - annotate - [select for diffs], Sun Aug 7 21:13:05 2011 UTC (11 years, 6 months ago) by rmind
Branch: MAIN
Changes since 1.1: +6 -7 lines
Diff to previous 1.1 (colored)

Remove LW_AFFINITY flag and fix some bugs affinity mask handling.

Revision 1.1 / (download) - annotate - [select for diffs], Sun Aug 7 13:33:01 2011 UTC (11 years, 6 months ago) by rmind
Branch: MAIN

Add kcpuset(9) - a reworked dynamic CPU set implementation for kernel.
Suitable for use during the early boot.  MD and other implementations
should be replaced with this interface.

Discussed on: tech-kern@

This form allows you to request diff's 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.




CVSweb <webmaster@jp.NetBSD.org>