Skip to content

Commit 4faf17d

Browse files
committed
erts: Remove erts_staging_bp_index
It should always be erts_active_bp_index ^ 1. Avoid tiny race when we had to change two atomics. We only call erts_staging_bp_ix() when we change trace settings.
1 parent 8544482 commit 4faf17d

4 files changed

Lines changed: 4 additions & 8 deletions

File tree

erts/emulator/beam/beam_bp.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ static void bp_hash_dealloc(bp_trace_hash_t *hash);
175175
void
176176
erts_bp_init(void) {
177177
erts_atomic32_init_nob(&erts_active_bp_index, 0);
178-
erts_atomic32_init_nob(&erts_staging_bp_index, 1);
179178
erts_mtx_init(&erts_dirty_bp_ix_mtx, "dirty_break_point_index", NIL,
180179
ERTS_LOCK_FLAGS_PROPERTY_STATIC | ERTS_LOCK_FLAGS_CATEGORY_DEBUG);
181180
}
@@ -510,11 +509,10 @@ consolidate_bp_data_session(GenericBp* g)
510509
void
511510
erts_commit_staged_bp(void)
512511
{
513-
ErtsBpIndex staging = erts_staging_bp_ix();
514-
ErtsBpIndex active = erts_active_bp_ix();
512+
const ErtsBpIndex new_active = erts_active_bp_ix() ^ 1;
515513

516-
erts_atomic32_set_nob(&erts_active_bp_index, staging);
517-
erts_atomic32_set_nob(&erts_staging_bp_index, active);
514+
ASSERT(new_active < 2);
515+
erts_atomic32_set_nob(&erts_active_bp_index, new_active);
518516
}
519517

520518
void

erts/emulator/beam/beam_bp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ ERTS_GLB_INLINE ErtsBpIndex erts_active_bp_ix(void)
217217

218218
ERTS_GLB_INLINE ErtsBpIndex erts_staging_bp_ix(void)
219219
{
220-
return erts_atomic32_read_nob(&erts_staging_bp_index);
220+
return erts_atomic32_read_nob(&erts_active_bp_index) ^ 1;
221221
}
222222

223223
ERTS_GLB_INLINE

erts/emulator/beam/erl_trace.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#endif
6565

6666
erts_atomic32_t erts_active_bp_index;
67-
erts_atomic32_t erts_staging_bp_index;
6867

6968
/* Pseudo export entries. Never filled in with data, only used to
7069
yield unique pointers of the correct type. */

erts/emulator/beam/erl_trace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ typedef struct
6767
#define ERTS_NUM_BP_IX 2
6868
typedef Uint32 ErtsBpIndex;
6969
extern erts_atomic32_t erts_active_bp_index;
70-
extern erts_atomic32_t erts_staging_bp_index;
7170

7271
struct trace_pattern_flags {
7372
unsigned int breakpoint : 1; /* Set if any other is set */

0 commit comments

Comments
 (0)