From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D9B3345B12; Fri, 11 Oct 2024 10:36:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AEBE04028B; Fri, 11 Oct 2024 10:36:05 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id AE437400D5 for ; Fri, 11 Oct 2024 10:36:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728635763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nTLHWP6eW2FFwfrCa4tsqpBiWrUzRSLuioLVpJdy4I0=; b=hcTAWlVapQqtp+gH4TZdpUrrfrFNamaanZ0wPgCryskZCGMRv1cIpgJZNcMzKeXfnkKKwo nS9YwRhIXLVwr9GY2GzPcnFWwck66j0NVifgZ1eTUyZiMv9tytE1hvk2IoFQWIJn15V1j2 NHEIyzrsjGBCnz2kEnMpxwfKBJ9ygz0= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-5ekT9mU7OjaAGgJ2vaONrA-1; Fri, 11 Oct 2024 04:36:01 -0400 X-MC-Unique: 5ekT9mU7OjaAGgJ2vaONrA-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-53997e2fe14so1761651e87.2 for ; Fri, 11 Oct 2024 01:36:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728635760; x=1729240560; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nTLHWP6eW2FFwfrCa4tsqpBiWrUzRSLuioLVpJdy4I0=; b=e7AfZtZt1/h3azv1Ap+ED2tKRfE/I+QYcmGFNvCqlAEoquKR53H90QWZFB95UIMkPC Xouu/QKmc4LZ+HeJR0mnoBPCW3EdkA1qLZomkPWg4FgcfBoZqFn92CYALSXHMwIapBBA BppY9j429RL//0V7oXUQsBINYe8dMwdN53C8CAaLmgCgynfRHOeYZZaVs99tDEiEwoLF DvbPpMGprZ1RhsedMQMv+N3VH/2ZmufSeB1S6Q4NZBIWRLQ4/a2MXpV3RYqXaTklu1qQ S7SOSs6FvcQSmBnlfbNI6Bfx/l6RwiF5PKebZgdQfdZOb2reJ1R72ycstiVNBUUn0TNn CJ/w== X-Forwarded-Encrypted: i=1; AJvYcCWk24olzy78VxzX+D9Qu74m+1hcNUsHHenOpKkO46+muzqj+QB+Wc73Irj6HM7cldioHRE=@dpdk.org X-Gm-Message-State: AOJu0Yy5U5d6vQOHOkQ6pPGJN/CyBHFAh4+1ht09M/jLIG4GbD/oP0GC TPzGQC6exlCAw3MiWvSaM57RWEWX/fn9iBJVVYP02LN87QF/Uq9A7IRoPGmrcHqqpx/wa1R2oGt 1OIAkM7LGFsrfzZ0MMRd3F89snMgVQBY5GC676yutq23vE/9mTa8FjiwT5ckfzHj8GwiX4nFjyg uYuUwOlvlMqydZM80= X-Received: by 2002:a05:6512:281b:b0:539:93e8:7eca with SMTP id 2adb3069b0e04-539da4e2d33mr947656e87.35.1728635760287; Fri, 11 Oct 2024 01:36:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlA65xEEe2rj7pZCErbRX71DBsVS4J2tRGs4LGcRw8ZXK4RULMdp3MY6IHs1boBerWuc7hWORKyXedqu2+CTc= X-Received: by 2002:a05:6512:281b:b0:539:93e8:7eca with SMTP id 2adb3069b0e04-539da4e2d33mr947631e87.35.1728635759814; Fri, 11 Oct 2024 01:35:59 -0700 (PDT) MIME-Version: 1.0 References: <20240920062437.738706-2-mattias.ronnblom@ericsson.com> <20240920104754.739033-1-mattias.ronnblom@ericsson.com> <20240920104754.739033-7-mattias.ronnblom@ericsson.com> In-Reply-To: From: David Marchand Date: Fri, 11 Oct 2024 10:35:46 +0200 Message-ID: Subject: Re: [PATCH v12 6/7] eal: add unit tests for atomic bit access functions To: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= Cc: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= , dev@dpdk.org, Heng Wang , Stephen Hemminger , Tyler Retzlaff , =?UTF-8?Q?Morten_Br=C3=B8rup?= , Jack Bond-Preston , Chengwen Feng X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Oct 10, 2024 at 1:56=E2=80=AFPM Mattias R=C3=B6nnblom wrote: > > On 2024-10-10 12:45, David Marchand wrote: > > On Fri, Sep 20, 2024 at 12:57=E2=80=AFPM Mattias R=C3=B6nnblom > > wrote: > >> + static int = \ > >> + run_parallel_test_and_modify ## size(void *arg) \ > >> + { = \ > >> + struct parallel_test_and_set_lcore ## size *lcore =3D = arg; \ > >> + uint64_t deadline =3D rte_get_timer_cycles() + = \ > >> + PARALLEL_TEST_RUNTIME * rte_get_timer_hz(); = \ > >> + do { = \ > >> + bool old_value; = \ > >> + bool new_value =3D rte_rand() & 1; = \ > >> + bool use_assign =3D rte_rand() & 1; = \ > >> + = \ > >> + if (use_assign) = \ > >> + old_value =3D rte_bit_atomic_test_and_= assign( \ > >> + lcore->word, lcore->bit, new_v= alue, \ > >> + rte_memory_order_relaxed); = \ > >> + else = \ > >> + old_value =3D new_value ? = \ > >> + rte_bit_atomic_test_and_set( = \ > >> + lcore->word, lcore->bi= t, \ > >> + rte_memory_order_relax= ed) : \ > >> + rte_bit_atomic_test_and_clear(= \ > >> + lcore->word, lcore->bi= t, \ > >> + rte_memory_order_relax= ed); \ > >> + if (old_value !=3D new_value) = \ > >> + lcore->flips++; = \ > >> + } while (rte_get_timer_cycles() < deadline); = \ > >> + = \ > >> + return 0; = \ > >> + } = \ > >> + = \ > >> + static int = \ > >> + test_bit_atomic_parallel_test_and_modify ## size(void) = \ > >> + { = \ > >> + unsigned int worker_lcore_id; = \ > >> + uint ## size ## _t word =3D 0; = \ > >> + unsigned int bit =3D rte_rand_max(size); = \ > >> + struct parallel_test_and_set_lcore ## size lmain =3D {= \ > >> + .word =3D &word, = \ > >> + .bit =3D bit = \ > >> + }; = \ > >> + struct parallel_test_and_set_lcore ## size lworker =3D= { \ > >> + .word =3D &word, = \ > >> + .bit =3D bit = \ > >> + }; = \ > >> + = \ > >> + if (rte_lcore_count() < 2) { = \ > >> + printf("Need multiple cores to run parallel te= st.\n"); \ > >> + return TEST_SKIPPED; = \ > >> + } = \ > >> + = \ > >> + worker_lcore_id =3D rte_get_next_lcore(-1, 1, 0); = \ > >> + = \ > >> + int rc =3D rte_eal_remote_launch(run_parallel_test_and= _modify ## size, \ > >> + &lworker, worker_lcore_= id); \ > >> + TEST_ASSERT(rc =3D=3D 0, "Worker thread launch failed"= ); \ > >> + = \ > >> + run_parallel_test_and_modify ## size(&lmain); = \ > >> + = \ > >> + rte_eal_mp_wait_lcore(); = \ > >> + = \ > >> + uint64_t total_flips =3D lmain.flips + lworker.flips; = \ > >> + bool expected_value =3D total_flips % 2; = \ > >> + = \ > >> + TEST_ASSERT(expected_value =3D=3D rte_bit_test(&word, = bit), \ > >> + "After %"PRId64" flips, the bit value " = \ > >> + "should be %d", total_flips, expected_valu= e); \ > >> + = \ > >> + uint64_t expected_word =3D 0; = \ > >> + rte_bit_assign(&expected_word, bit, expected_value); = \ > >> + = \ > >> + TEST_ASSERT(expected_word =3D=3D word, "Untouched bits= have " \ > >> + "changed value"); = \ > >> + = \ > >> + return TEST_SUCCESS; = \ > >> + } > >> + > >> +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(32) > >> +GEN_TEST_BIT_PARALLEL_TEST_AND_MODIFY(64) > > > > It appears this test failed once in the CI for an unrelated series > > (uAPI kernel header import): > > https://lab.dpdk.org/results/dashboard/testruns/logs/1385993/ > > > > + TestCase [ 0] : test_bit_access32 succeeded > > + TestCase [ 1] : test_bit_access64 succeeded > > + TestCase [ 2] : test_bit_access32 succeeded > > + TestCase [ 3] : test_bit_access64 succeeded > > + TestCase [ 4] : test_bit_v_access32 succeeded > > + TestCase [ 5] : test_bit_v_access64 succeeded > > + TestCase [ 6] : test_bit_atomic_access32 succeeded > > + TestCase [ 7] : test_bit_atomic_access64 succeeded > > + TestCase [ 8] : test_bit_atomic_v_access32 succeeded > > + TestCase [ 9] : test_bit_atomic_v_access64 succeeded > > + TestCase [10] : test_bit_atomic_parallel_assign32 succeeded > > + TestCase [11] : test_bit_atomic_parallel_assign64 succeeded > > + TestCase [12] : test_bit_atomic_parallel_test_and_modify32 failed > > + TestCase [13] : test_bit_atomic_parallel_test_and_modify64 succeede= d > > + TestCase [14] : test_bit_atomic_parallel_flip32 succeeded > > + TestCase [15] : test_bit_atomic_parallel_flip64 succeeded > > + TestCase [16] : test_bit_relaxed_set succeeded > > + TestCase [17] : test_bit_relaxed_clear succeeded > > + TestCase [18] : test_bit_relaxed_test_set_clear succeeded > > > > EAL: Test assert test_bit_atomic_parallel_test_and_modify32 line 236 > > failed: After 1070523 flips, the bit value should be 1 > > > > I've been unable to reproduce this on my Raptor Lake x86_64 with GCC > 12.3 (CI machine used GCC 12.2). > > I'll try if I have better luck on some other systems. Could it have to do with how UNH tests in containers? (with physical cores that may not be isolated/dedicated to a process). This morning, I see at least two similar errors, on the same part of the te= st: https://patchwork.dpdk.org/project/dpdk/patch/20241010203209.63911-1-nandin= ipersad361@gmail.com/ EAL: Test assert test_bit_atomic_parallel_test_and_modify32 line 236 failed: After 1719375 flips, the bit value should be 1 https://patchwork.dpdk.org/project/dpdk/patch/20241010194148.1877659-18-rja= rry@redhat.com/ EAL: Test assert test_bit_atomic_parallel_test_and_modify32 line 236 failed: After 1199935 flips, the bit value should be 1 --=20 David Marchand