~lttng/urcu/trunk

« back to all changes in this revision

Viewing changes to src/rculfhash.c

  • Committer: Mathieu Desnoyers
  • Author(s): Wang Jing
  • Date: 2023-09-06 13:20:24 UTC
  • Revision ID: git-v1:dc46a9c324ae94d89da41ea9a3f97503115df88e
Add LoongArch support

This commit completes LoongArch support.

LoongArch supports byte and short atomic operations,
and defines UATOMIC_HAS_ATOMIC_BYTE and UATOMIC_HAS_ATOMIC_SHORT.

Signed-off-by: Wang Jing <wangjing@loongson.cn>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I335e654939bfc90994275f2a4fad550c95f3eba4

Show diffs side-by-side

added added

removed removed

Lines of Context:
347
347
                    unsigned long start, unsigned long len);
348
348
};
349
349
 
350
 
enum nr_cpus_mask_state {
351
 
        NR_CPUS_MASK_INIT_FAILED = -2,
352
 
        NR_CPUS_MASK_UNINITIALIZED = -1,
353
 
};
354
 
 
355
350
static struct urcu_workqueue *cds_lfht_workqueue;
356
351
 
357
352
/*
629
624
                urcu_die(ret);
630
625
}
631
626
 
632
 
static long nr_cpus_mask = NR_CPUS_MASK_UNINITIALIZED;
 
627
static long nr_cpus_mask = -1;
633
628
static long split_count_mask = -1;
634
629
static int split_count_order = -1;
635
630
 
639
634
 
640
635
        maxcpus = get_possible_cpus_array_len();
641
636
        if (maxcpus <= 0) {
642
 
                nr_cpus_mask = NR_CPUS_MASK_INIT_FAILED;
 
637
                nr_cpus_mask = -2;
643
638
                return;
644
639
        }
645
640
        /*
653
648
static
654
649
void alloc_split_items_count(struct cds_lfht *ht)
655
650
{
656
 
        if (nr_cpus_mask == NR_CPUS_MASK_UNINITIALIZED) {
 
651
        if (nr_cpus_mask == -1) {
657
652
                ht_init_nr_cpus_mask();
658
653
                if (nr_cpus_mask < 0)
659
654
                        split_count_mask = DEFAULT_SPLIT_COUNT_MASK;
1158
1153
                struct cds_lfht_node *node)
1159
1154
{
1160
1155
        struct cds_lfht_node *bucket, *next;
1161
 
        uintptr_t *node_next;
 
1156
        struct cds_lfht_node **node_next;
1162
1157
 
1163
1158
        if (!node)      /* Return -ENOENT if asked to delete NULL node */
1164
1159
                return -ENOENT;
1190
1185
         * NOTE: The node_next variable is present to avoid breaking
1191
1186
         * strict-aliasing rules.
1192
1187
         */
1193
 
        node_next = (uintptr_t*)&node->next;
 
1188
        node_next = &node->next;
1194
1189
        uatomic_or_mo(node_next, REMOVED_FLAG, CMM_RELEASE);
1195
1190
 
1196
1191
        /* We performed the (logical) deletion. */
1246
1241
        unsigned long thread, nr_threads;
1247
1242
        sigset_t newmask, oldmask;
1248
1243
 
1249
 
        urcu_posix_assert(nr_cpus_mask != NR_CPUS_MASK_UNINITIALIZED);
 
1244
        urcu_posix_assert(nr_cpus_mask != -1);
1250
1245
        if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD)
1251
1246
                goto fallback;
1252
1247
 
1431
1426
        for (j = size + start; j < size + start + len; j++) {
1432
1427
                struct cds_lfht_node *fini_bucket = bucket_at(ht, j);
1433
1428
                struct cds_lfht_node *parent_bucket = bucket_at(ht, j - size);
1434
 
                uintptr_t *fini_bucket_next;
 
1429
                struct cds_lfht_node **fini_bucket_next;
1435
1430
 
1436
1431
                urcu_posix_assert(j >= size && j < (size << 1));
1437
1432
                dbg_printf("remove entry: order %lu index %lu hash %lu\n",
1441
1436
                 * NOTE: The fini_bucket_next variable is present to
1442
1437
                 * avoid breaking strict-aliasing rules.
1443
1438
                 */
1444
 
                fini_bucket_next = (uintptr_t*)&fini_bucket->next;
 
1439
                fini_bucket_next = &fini_bucket->next;
1445
1440
                uatomic_or(fini_bucket_next, REMOVED_FLAG);
1446
1441
                _cds_lfht_gc_bucket(parent_bucket, fini_bucket);
1447
1442
        }