Lines Matching full:counter
21 static void __init init_id(atomic64_t *const counter, const u32 random_32bits) in init_id() argument
39 atomic64_cmpxchg(counter, COUNTER_PRE_INIT, init); in init_id()
46 atomic64_t counter = ATOMIC64_INIT(COUNTER_PRE_INIT); in test_init_min() local
48 init_id(&counter, 0); in test_init_min()
49 KUNIT_EXPECT_EQ(test, atomic64_read(&counter), 1ULL + U32_MAX); in test_init_min()
54 atomic64_t counter = ATOMIC64_INIT(COUNTER_PRE_INIT); in test_init_max() local
56 init_id(&counter, ~0); in test_init_max()
57 KUNIT_EXPECT_EQ(test, atomic64_read(&counter), 1 + (2ULL * U32_MAX)); in test_init_max()
63 atomic64_t counter = ATOMIC64_INIT(COUNTER_PRE_INIT); in test_init_once() local
65 init_id(&counter, 0); in test_init_once()
66 KUNIT_EXPECT_EQ(test, atomic64_read(&counter), first_init); in test_init_once()
68 init_id(&counter, ~0); in test_init_once()
70 test, atomic64_read(&counter), first_init, in test_init_once()
82 * It's not worth it to try to hide the monotonic counter because it can still
83 * be inferred (with N counter ranges), and if we are allowed to read the inode
90 static u64 get_id_range(size_t number_of_ids, atomic64_t *const counter, in get_id_range() argument
113 id = atomic64_fetch_add(step, counter); in get_id_range()
124 atomic64_t counter; in test_range1_rand0() local
128 atomic64_set(&counter, init); in test_range1_rand0()
129 KUNIT_EXPECT_EQ(test, get_id_range(1, &counter, 0), init); in test_range1_rand0()
131 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range1_rand0()
137 atomic64_t counter; in test_range1_rand1() local
141 atomic64_set(&counter, init); in test_range1_rand1()
142 KUNIT_EXPECT_EQ(test, get_id_range(1, &counter, 1), init); in test_range1_rand1()
144 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range1_rand1()
150 atomic64_t counter; in test_range1_rand15() local
154 atomic64_set(&counter, init); in test_range1_rand15()
155 KUNIT_EXPECT_EQ(test, get_id_range(1, &counter, 15), init); in test_range1_rand15()
157 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range1_rand15()
163 atomic64_t counter; in test_range1_rand16() local
167 atomic64_set(&counter, init); in test_range1_rand16()
168 KUNIT_EXPECT_EQ(test, get_id_range(1, &counter, 16), init); in test_range1_rand16()
170 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range1_rand16()
176 atomic64_t counter; in test_range2_rand0() local
180 atomic64_set(&counter, init); in test_range2_rand0()
181 KUNIT_EXPECT_EQ(test, get_id_range(2, &counter, 0), init); in test_range2_rand0()
183 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range2_rand0()
189 atomic64_t counter; in test_range2_rand1() local
193 atomic64_set(&counter, init); in test_range2_rand1()
194 KUNIT_EXPECT_EQ(test, get_id_range(2, &counter, 1), init); in test_range2_rand1()
196 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range2_rand1()
202 atomic64_t counter; in test_range2_rand2() local
206 atomic64_set(&counter, init); in test_range2_rand2()
207 KUNIT_EXPECT_EQ(test, get_id_range(2, &counter, 2), init); in test_range2_rand2()
209 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range2_rand2()
215 atomic64_t counter; in test_range2_rand15() local
219 atomic64_set(&counter, init); in test_range2_rand15()
220 KUNIT_EXPECT_EQ(test, get_id_range(2, &counter, 15), init); in test_range2_rand15()
222 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range2_rand15()
228 atomic64_t counter; in test_range2_rand16() local
232 atomic64_set(&counter, init); in test_range2_rand16()
233 KUNIT_EXPECT_EQ(test, get_id_range(2, &counter, 16), init); in test_range2_rand16()
235 test, get_id_range(get_random_u8(), &counter, get_random_u8()), in test_range2_rand16()