Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Feb 2020 22:43:59 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357672 - head/sys/sys
Message-ID:  <202002072243.017MhxsS037776@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Fri Feb  7 22:43:58 2020
New Revision: 357672
URL: https://svnweb.freebsd.org/changeset/base/357672

Log:
  Add zpcpu_{set,add,sub}_protected.
  
  The _protected suffix follows counter(9).

Modified:
  head/sys/sys/pcpu.h

Modified: head/sys/sys/pcpu.h
==============================================================================
--- head/sys/sys/pcpu.h	Fri Feb  7 22:36:37 2020	(r357671)
+++ head/sys/sys/pcpu.h	Fri Feb  7 22:43:58 2020	(r357672)
@@ -256,6 +256,24 @@ extern struct pcpu *cpuid_to_pcpu[];
 	_old;								\
 })
 
+#define zpcpu_set_protected(base, val) ({				\
+	MPASS(curthread->td_critnest > 0);				\
+	__typeof(val) *_ptr = zpcpu_get(base);				\
+	*_ptr = (val);							\
+})
+
+#define zpcpu_add_protected(base, val) ({				\
+	MPASS(curthread->td_critnest > 0);				\
+	__typeof(val) *_ptr = zpcpu_get(base);				\
+	*_ptr += (val);							\
+})
+
+#define zpcpu_sub_protected(base, val) ({				\
+	MPASS(curthread->td_critnest > 0);				\
+	__typeof(val) *_ptr = zpcpu_get(base);				\
+	*_ptr -= (val);							\
+})
+
 /*
  * Machine dependent callouts.  cpu_pcpu_init() is responsible for
  * initializing machine dependent fields of struct pcpu, and



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002072243.017MhxsS037776>