From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id AACF93858D33 for ; Thu, 18 Apr 2024 21:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AACF93858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AACF93858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1032 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713474646; cv=none; b=oSSF0Wp0Z9UUxluZuv3WR7p0Hn3Y0u/xFkmik662jrmexoJ6iay9GTZOaUm5lXegs9nNRDtZts/9QjySZoFH1Ddxj1MAgpoi1TI5KzZ2TRmVajJ/asGLr7y70LZ/9uKxO/z7EER6R6aE0lbnrt8PKaw82XVM2rTVHUDuwziGevE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713474646; c=relaxed/simple; bh=+N9TLwiMbTKRVMOIjtOgVvokMEOJVgFq1pBJfzcZ5BU=; h=DKIM-Signature:Date:Subject:From:To:Message-ID:Mime-Version; b=tRT8YpIDVRepKDDT5axRQBPXX2oI0gvtwTNZgQDoUgdvGxrayevFnuH+9kZVigCkddjBH2X/qLmE1HJ7k3NSSGS9WM7boxyKcizEfECVWm8hPgFmpMpF4LprJLKjAoZgOhOSNt4He/kUo/roqegXXhcAkZsV2agUIJGxyg9yrME= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2a53e810f10so1062930a91.0 for ; Thu, 18 Apr 2024 14:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20230601.gappssmtp.com; s=20230601; t=1713474643; x=1714079443; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=iczJEr9Z6Fictjtce+P/nzGigMXxy+caRMCjgCNTrzY=; b=Jtr2GcaowT7HO2ibXTuVGka2zF6zI3mHL4sGcVbfz5gwE6A/QiNHkjCHA5UnLnPzzD KX6Kfp72o4yoPPJa95fGBh2q3XlZZ8MBbs7mDHlL4swq0aWR2hzAdid41ui478fbEF2+ yBq2KG0KVk86SM1bGlUObqc1CUJqE2E3YnOBNU1YvDkh1y+y1w81PMy94qBuvHDGDhV4 pyt0XCysXkBFrWerE+v05NJbB2mm4nMvGrU42fXZXn6l6dGlqHaYqdH+GdDST83e4Tp+ DmB0KOQt/wchLU+XSG30rabo2Tav4X+/JWCZn03eT8/90Wo2L6lxJljoFz6xArNbVULe 4zyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713474643; x=1714079443; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iczJEr9Z6Fictjtce+P/nzGigMXxy+caRMCjgCNTrzY=; b=VkrzZp1YX3ebr5Nqv44EfVcaZpvMEt4xyxI5yIjKZ4IubQPUYSGo42T7Tl/hG+U4l7 hobEivRN6mqMTcIK+ssU3dINUj6cDxlIqtJhLjJceoOpdqaLBUY9DSk3RBMTMLsiRVvm igftvkxB3H+LZl8l3SkQMua1BjsxXJYrytyY7FKUq4ZYpD1c3DqX4jVmNozHz+VxyYKO UwjTnM+kltenQ1Vj87c5JO4g5Dj/KAgeSW8XsKc7Xk5vROhiYHP7+auRTBlGNCItheaV +bZie/W8SMZ2pfKEJL5Kuv0ah6VjsXtXdx+R5eF4ikDrD5IMFJd+tkgH1xKg1y7CTNrI xuWA== X-Forwarded-Encrypted: i=1; AJvYcCXWRrg+6rjYg4WLye5mTVYWm1nW6mAqDbAw4803mzPbrOWwso7IB3h8wWBiaNFmUt/SEru2xR1RsUKov4JComKWG+/Yo/VSb54T X-Gm-Message-State: AOJu0Yz67JHameAtc3kVhplmAaf/Pbz7wZ6oCl0nZmU0sahjZgx/W/++ dT0BKm4Puw1HuiuFZY3rLnZd9qOaKhos6bZyjW/K1AXJJg2QmwnnYC6jJmyL1fo= X-Google-Smtp-Source: AGHT+IG07iCnwumpBxBg2OdD56RLAS1WuKJjGXK2q79CHMw6+m+DKN5SrCMnWWfCKvhmBdRFS98voA== X-Received: by 2002:a17:90b:909:b0:2a2:f9d:f600 with SMTP id bo9-20020a17090b090900b002a20f9df600mr350437pjb.22.1713474643352; Thu, 18 Apr 2024 14:10:43 -0700 (PDT) Received: from localhost ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id r19-20020a17090aa09300b002a2e6fc09b5sm1907044pjp.29.2024.04.18.14.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 14:10:42 -0700 (PDT) Date: Thu, 18 Apr 2024 14:10:42 -0700 (PDT) X-Google-Original-Date: Thu, 18 Apr 2024 14:10:39 PDT (-0700) Subject: Re: [RFC PATCH 3/3] RISC-V: Implement CPU yielding for busy loops with Zihintpause/Zawrs In-Reply-To: <46e0cfcc-db0f-46fd-8e3f-707fbf656531@rivosinc.com> CC: christoph.muellner@vrull.eu, libc-alpha@sourceware.org, adhemerval.zanella@linaro.org, Darius Rad , Andrew Waterman , philipp.tomsich@vrull.eu, Evan Green , kito.cheng@sifive.com, jeffreyalaw@gmail.com From: Palmer Dabbelt To: Vineet Gupta , ajones@ventanamicro.com, Charlie Jenkins Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 18 Apr 2024 13:36:32 PDT (-0700), Vineet Gupta wrote: > On 4/18/24 13:19, Christoph Müllner wrote: >>> This has the same forward progress/eventual success violation as the >>> code you sent for GCC and Linux does. It doesn't really matter if the >>> user of the reservation is in a builtin, an asm block, or a function. >>> The compiler just doesn't know about those reservation rules and isn't >>> going to generate code that follows them. >> I see. The main issue is that we don't have a valid reservation when >> calling WRS, >> so the whole use of Zawrs instructions is pointless. >> So the only way to move Zawrs forward would be to adjust the locking routines >> (introducing new primitives that have to be implemented for all architectures). > > Not explicitly anyways - the generic fallback will take care of every > arch, except SPARC/x86 which implement atomic_spin_nop wth pause like > semantics, but even they don't need to change at all if we implement new > API atomic_load_and_spin_if_cond_whatever ()  in terms of existing > atomic_spin_nop () Ya, sounds about right. IIRC I just hooked some of the LLL macros when doing the POC/estimates, but it was at least a year ago so I forget exactly how it all fit together. Whatever it is, they end up with basically the same load->cond->lr->beq->{wrs,sc} patterns as a bunch of the Linux routines should have (sort of a test-and-test-and-set type pattern, or how arm64 does the load-and-cmpxchg routines). Adding Charlie and Drew, as we were talking about the Linux side of things recently. > -Vineet