From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51417C43461 for ; Mon, 19 Apr 2021 07:53:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E28361165 for ; Mon, 19 Apr 2021 07:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238016AbhDSHxm (ORCPT ); Mon, 19 Apr 2021 03:53:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47402 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238023AbhDSHxk (ORCPT ); Mon, 19 Apr 2021 03:53:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618818791; 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=x2ufc3mqMrnhfTRRARV/wYF3P8xOeNxsUa5+ZAlFuFg=; b=Z79mL9Pu6P4jGZupmIiqupHoKSZpRsh9hw2hCIkCh/OYwyqyt5mLBg7EiqVTrLz9etFXrf C+dpCpNpe8wCDoQn7Y4TwfS8vzHQO01btMEw6YxR5LuAQn0mk5vQ1gMS0hSQQrLKf/2xaw CmOmU2e0a95fO2i8bhW/4BPPKs8cRXk= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-407-3hi_gbhBP8aDLYrlfmoytQ-1; Mon, 19 Apr 2021 03:53:09 -0400 X-MC-Unique: 3hi_gbhBP8aDLYrlfmoytQ-1 Received: by mail-ej1-f69.google.com with SMTP id d11-20020a170906370bb029037c87968c04so3338293ejc.17 for ; Mon, 19 Apr 2021 00:53:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=x2ufc3mqMrnhfTRRARV/wYF3P8xOeNxsUa5+ZAlFuFg=; b=HVo7zOYSwkrMkx6G0xDZKk6A2O4r1c7mdpXcCOxBLb0l7vQW7nLI9SvcHCVU0akNYV wl4oeqXnpvCp3l5JYWWCtzxOpwSkIZY+TRoF1kyoHZb9dnDZ7QYIhHpQJsRB/VwDxCOj WE78eoFI44IFJXSGcNkMEXO+zUHw34GXpEEaAxS+tegz4HH5q0sbq70m0Fdgd5txBQ2+ 02pgyjfw1DSdlKB2M56quCW+b7+xa5LEdB2DAhAu8d89/SvdbQ85f9QlInQOFro0uVU9 aJhW1+ElfBOK899MCwq7ASCKmaNMIPNcuhTPQ0sdqjiBIeE5yd5WcoQjFw0yuMsDUoDr aXDQ== X-Gm-Message-State: AOAM5339bbXpnZrU7iXlcZ3fdGj58ws14hXlUgYf1JqTXP8S6yeKvrPp 9zlO1F0tE439XxCmiC399AXa7xBeMOX2WdGtW13fXOIiOSpS/jYm+jkzaNVVsR2NpoCA1sCgxm7 lhGY/9jxOHvdSrG1QkqlPWezqL+M= X-Received: by 2002:a17:906:a286:: with SMTP id i6mr20596336ejz.135.1618818788208; Mon, 19 Apr 2021 00:53:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7jBzHFRvwixkLhHkF8GQ7d8wupO6F8D5LBz7CIhnhdlBLvGmXmwH0kDpoLoDDNSWxHAxmYA== X-Received: by 2002:a17:906:a286:: with SMTP id i6mr20596322ejz.135.1618818788003; Mon, 19 Apr 2021 00:53:08 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:63a7:c72e:ea0e:6045? ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id mj7sm9712114ejb.39.2021.04.19.00.53.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Apr 2021 00:53:07 -0700 (PDT) Subject: Re: [PATCH 00/13] [RFC] Rust support To: Peter Zijlstra Cc: Wedson Almeida Filho , ojeda@kernel.org, Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210414184604.23473-1-ojeda@kernel.org> From: Paolo Bonzini Message-ID: <7287eac3-f492-bab1-9ea8-b89ceceed560@redhat.com> Date: Mon, 19 Apr 2021 09:53:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: rust-for-linux@vger.kernel.org On 19/04/21 09:32, Peter Zijlstra wrote: > On Sat, Apr 17, 2021 at 04:51:58PM +0200, Paolo Bonzini wrote: >> On 16/04/21 09:09, Peter Zijlstra wrote: >>> Well, the obvious example would be seqlocks. C11 can't do them >> >> Sure it can. C11 requires annotating with (the equivalent of) READ_ONCE all >> reads of seqlock-protected fields, but the memory model supports seqlocks >> just fine. > > How does that help? > > IIRC there's two problems, one on each side the lock. On the write side > we have: > > seq++; > smp_wmb(); > X = r; > Y = r; > smp_wmb(); > seq++; > > Which C11 simply cannot do right because it does't have wmb. It has atomic_thread_fence(memory_order_release), and atomic_thread_fence(memory_order_acquire) on the read side. > You end up > having to use seq_cst for the first wmb or make both X and Y (on top of > the last seq) a store-release, both options are sub-optimal. seq_cst (except for the fence which is just smp_mb) is a pile of manure, no doubt about that. :) Paolo