From: Mathieu Desnoyers Date: Tue, 25 Apr 2023 15:26:59 +0000 (-0400) Subject: rseq.h: implement mm_cid and node_id APIs X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=d2fa6d3043eaa421335e624178527122d098811c;p=librseq.git rseq.h: implement mm_cid and node_id APIs Signed-off-by: Mathieu Desnoyers Change-Id: Ic82b240e654702416936d612a03d8675f9fb869c --- diff --git a/include/rseq/rseq.h b/include/rseq/rseq.h index 8b86dbb..53376ae 100644 --- a/include/rseq/rseq.h +++ b/include/rseq/rseq.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -208,19 +209,45 @@ static inline uint32_t rseq_current_cpu(void) return cpu; } +static inline bool rseq_node_id_available(void) +{ + return (int) rseq_feature_size >= (int) rseq_offsetofend(struct rseq_abi, node_id); +} + +/* + * Current NUMA node number. + */ +static inline uint32_t rseq_current_node_id(void) +{ + assert(rseq_node_id_available()); + return RSEQ_READ_ONCE(rseq_get_abi()->node_id); +} + +static inline bool rseq_mm_cid_available(void) +{ + return (int) rseq_feature_size >= (int) rseq_offsetofend(struct rseq_abi, mm_cid); +} + +static inline uint32_t rseq_current_mm_cid(void) +{ + return RSEQ_READ_ONCE(rseq_get_abi()->mm_cid); +} + static inline void rseq_clear_rseq_cs(void) { - RSEQ_WRITE_ONCE(rseq_get_abi()->rseq_cs.arch.ptr, 0); + RSEQ_WRITE_ONCE(rseq_get_abi()->rseq_cs, 0); } /* * rseq_prepare_unload() should be invoked by each thread executing a rseq * critical section at least once between their last critical section and - * library unload of the library defining the rseq critical section - * (struct rseq_ab_cs). This also applies to use of rseq in code generated by - * JIT: rseq_prepare_unload() should be invoked at least once by each - * thread executing a rseq critical section before reclaim of the memory - * holding the struct rseq_abi_cs. + * library unload of the library defining the rseq critical section (struct + * rseq_cs) or the code referred to by the struct rseq_cs start_ip and + * post_commit_offset fields. This also applies to use of rseq in code + * generated by JIT: rseq_prepare_unload() should be invoked at least once by + * each thread executing a rseq critical section before reclaim of the memory + * holding the struct rseq_cs or reclaim of the code pointed to by struct + * rseq_cs start_ip and post_commit_offset fields. */ static inline void rseq_prepare_unload(void) {