From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D10E3157E82 for ; Wed, 18 Dec 2024 19:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734551787; cv=none; b=coHzw+tV+CxppSH7FO5xB3zmtNhM/eo0ao2g4uMRbPXjml57CbRoyX9o98Gbj991Z5GyovyDfDPpbZd+O+szEkvHXMYjDvb7Hd7FTCN7ur7F+ntzz2yeDm1niOhh2RSfjowA9FwoCpy5okJSUIjZ2KKfe1lvs5KH5SBeUsEug04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734551787; c=relaxed/simple; bh=wAENTcq11V3W0AmiMPMY5/fHVQA7pJkSXpZ+G1/XU/w=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=D5pAftp9aMIaq058+u0ho9sk3QjP1LmaR8HWfiNDK/kAje41Iv+gC4f0wXLeO0Hg0ub/60+cD+6wAbRNyA/PzpB/YuXG6GN7mjaWb1W/tpeX7IUV+cToVU5KuhEFNKrQn9+q+q+UemmUuUEMlhUACJz2p1apumihjOOwBlhpK3I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=K/wtGu0J; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K/wtGu0J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734551784; 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: in-reply-to:in-reply-to:references:references; bh=TVm0N6tx7ZrIGzAZfXHqoeYyPJhA0k1kmacfqN8p870=; b=K/wtGu0J8LWF165VBQOjoNimCpK3t0U8eWX4D+jJ80CcayQ5pVtgzDS5BMKIjavCBsyL7z 7njcbYQmup2OAlx1r+NSXLFLtjNg5apWgzp1KcKby0ewM7OAObmd2XIxHl7FTb49B5+J6M 0wGGiG9j5zQy29TBL7luXWO9Dj+jzJ0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-425-ZjLJ0N5WNtWFTktzDvEd4Q-1; Wed, 18 Dec 2024 14:56:21 -0500 X-MC-Unique: ZjLJ0N5WNtWFTktzDvEd4Q-1 X-Mimecast-MFC-AGG-ID: ZjLJ0N5WNtWFTktzDvEd4Q Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4B4A41955D92; Wed, 18 Dec 2024 19:56:15 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.21]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D7DEF1955F68; Wed, 18 Dec 2024 19:56:10 +0000 (UTC) From: Florian Weimer To: Peter Zijlstra Cc: "Paul E. McKenney" , Daniel Xu , mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, linux-kernel@vger.kernel.org, linux-toolchains@vger.kernel.org Subject: Re: [PATCH] seqlock: Use WRITE_ONCE() when updating sequence In-Reply-To: <20241218171241.GN2354@noisy.programming.kicks-ass.net> (Peter Zijlstra's message of "Wed, 18 Dec 2024 18:12:41 +0100") References: <0eaea03ecc9df536649763cfecda356fc38b6938.1734477414.git.dxu@dxuuu.xyz> <20241218103000.GK11133@noisy.programming.kicks-ass.net> <20241218162325.GH2354@noisy.programming.kicks-ass.net> <20241218162934.GJ12500@noisy.programming.kicks-ass.net> <9b6d585a-c17f-4dd1-9518-b28ac2dfd855@paulmck-laptop> <20241218171241.GN2354@noisy.programming.kicks-ass.net> Date: Wed, 18 Dec 2024 20:56:07 +0100 Message-ID: <87v7vgzrxk.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 * Peter Zijlstra: > +linux-toolchains > > On Wed, Dec 18, 2024 at 08:59:47AM -0800, Paul E. McKenney wrote: > >> > Perhaps something like: (*(volatile unsigned int *)&s->sequence)++; ? >> > I'd have to check what the compiler makes of that. >> > >> > /me mucks about with godbolt for a bit... >> > >> > GCC doesn't optimize that, but Clang does. >> > >> > I would still very much refrain from making this change until both >> > compilers can generate sane code for it. >> >> Is GCC on track to do this, or do we need to encourage them? > > I have no clue; probably wise to offer encouragement. What do you consider sane code? Clang's choice to generate an incl instruction (on x86-64 at least) is a bit surprising. Curiously, the C11 abstract machine has a value-less increment-in-place operation, so it's probably not in violation of the volatile rules. (C doesn't specify x++ in terms of ++x and x += 1.) Thanks, Florian