mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 23:14:12 +08:00
mdbx: fix cache-aligned size for MDBX_reader.
Change-Id: I1e48dd279106daa629fbcd427ec841828799c8f6
This commit is contained in:
parent
bb5e1b43af
commit
f945e8a062
12
src/bits.h
12
src/bits.h
@ -225,10 +225,10 @@ typedef struct MDBX_reader {
|
|||||||
volatile mdbx_tid_t mr_tid;
|
volatile mdbx_tid_t mr_tid;
|
||||||
|
|
||||||
/* cache line alignment */
|
/* cache line alignment */
|
||||||
uint8_t pad[~(MDBX_CACHELINE_SIZE - 1) &
|
uint8_t pad[MDBX_CACHELINE_SIZE -
|
||||||
(sizeof(txnid_t) + sizeof(mdbx_pid_t) + sizeof(mdbx_tid_t) +
|
(sizeof(txnid_t) + sizeof(mdbx_pid_t) + sizeof(mdbx_tid_t)) %
|
||||||
MDBX_CACHELINE_SIZE - 1)];
|
MDBX_CACHELINE_SIZE];
|
||||||
} MDBX_reader;
|
} __cache_aligned MDBX_reader;
|
||||||
|
|
||||||
/* Information about a single database in the environment. */
|
/* Information about a single database in the environment. */
|
||||||
typedef struct MDBX_db {
|
typedef struct MDBX_db {
|
||||||
@ -347,12 +347,12 @@ typedef struct MDBX_lockinfo {
|
|||||||
/* The number of slots that have been used in the reader table.
|
/* The number of slots that have been used in the reader table.
|
||||||
* This always records the maximum count, it is not decremented
|
* This always records the maximum count, it is not decremented
|
||||||
* when readers release their slots. */
|
* when readers release their slots. */
|
||||||
__cache_aligned volatile unsigned mti_numreaders;
|
volatile unsigned __cache_aligned mti_numreaders;
|
||||||
#ifdef MDBX_OSAL_LOCK
|
#ifdef MDBX_OSAL_LOCK
|
||||||
/* Mutex protecting access to this table. */
|
/* Mutex protecting access to this table. */
|
||||||
MDBX_OSAL_LOCK mti_rmutex;
|
MDBX_OSAL_LOCK mti_rmutex;
|
||||||
#endif
|
#endif
|
||||||
MDBX_reader mti_readers[1];
|
MDBX_reader __cache_aligned mti_readers[1];
|
||||||
} MDBX_lockinfo;
|
} MDBX_lockinfo;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
@ -2208,6 +2208,9 @@ static int mdbx_txn_renew0(MDBX_txn *txn, unsigned flags) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC_ASSERT(sizeof(MDBX_reader) == MDBX_CACHELINE_SIZE);
|
||||||
|
STATIC_ASSERT(
|
||||||
|
offsetof(MDBX_lockinfo, mti_numreaders) % MDBX_CACHELINE_SIZE == 0);
|
||||||
r = &env->me_lck->mti_readers[i];
|
r = &env->me_lck->mti_readers[i];
|
||||||
/* Claim the reader slot, carefully since other code
|
/* Claim the reader slot, carefully since other code
|
||||||
* uses the reader table un-mutexed: First reset the
|
* uses the reader table un-mutexed: First reset the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user