Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1171345ybg; Wed, 29 Jul 2020 07:35:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX+btSM1YQB+0yAgQj5V+EmCoPAmKzYSosJJL9TedQjIrznsB3EbKDyYTcuE1q9iE8KaiJ X-Received: by 2002:aa7:c682:: with SMTP id n2mr2249066edq.248.1596033308653; Wed, 29 Jul 2020 07:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596033308; cv=none; d=google.com; s=arc-20160816; b=cTlv8lozUatU0fLpv6uxCy5b7Wbxj+/5h5MLyVBQG6pT8e64mypwmjL+vcYGsRreFa WnIjDQoGzmHlzpaBpv4WbbiLT8uc5Nk5k2glOhHmaSl60cqVFXc4SfDaEY5hNS5CdIt4 QCs3nfoWYAxtr20hu6em1ZZ0brKhLzc9FlrP/WIeDA+b0pOH4NrWcwcNxEGTiYVyGbsg dXtldIQ3LrQWCy0TDSspWyjN28KWsCQP6Z2GpNYixvbS1Ot0vbTAmbYHz7zx2ZCe2d7c adMG67THZw5SQqgPekkHN0T/zOB1Xa1IQjUNvx6gefF/uNWAFaabPFOgCGpjGwQSTcba QDwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=2W2fiD5gf5zDpWAlZG2fcroDdYpSOcz7Sqwwo4UyE2Y=; b=A2aRZErh3XdiIqSzyrEJSxAA5KEZ6G3qOCTeWqCS6GMz5pGNSBE05k+vYswG/qt60z dj/YWQDMixl0iVMPJvGoD0V/cYJqKbicuJGE8U94avBhctD7xLmyrB2aWQqeiEFpUY0x gAzzsnYJmDaEdbbDVNIR60mfRlnxVB/sRKu5h8F1Zof12QNkz+DhcUUoIzsKwmfRy3T6 pL4Qgoz0z/iy72EOjTaXFkegcwr3/wx2qIrcImXU9gwOyy5SgEY5WNi4Kr+isUmKKPeH xU4oy5xXsqeXBN0VYH0kGE5rutyZZjqH0LKiDDiwu8Wa4iIhRsDlWXPqz/eYOng9I2nK s5TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=oR27WZz6; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ni5si1178771ejb.696.2020.07.29.07.34.46; Wed, 29 Jul 2020 07:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=oR27WZz6; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbgG2Odw (ORCPT + 99 others); Wed, 29 Jul 2020 10:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727076AbgG2Odl (ORCPT ); Wed, 29 Jul 2020 10:33:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7725DC061794; Wed, 29 Jul 2020 07:33:41 -0700 (PDT) Date: Wed, 29 Jul 2020 14:33:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1596033220; h=from:from:sender:sender:reply-to: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=2W2fiD5gf5zDpWAlZG2fcroDdYpSOcz7Sqwwo4UyE2Y=; b=oR27WZz6EzRiX6VctsGmWl3NniJY9x5hPQJbulL0cQR6SV3/VSOzeo4mXm084+B4zfmn9T pmT9ZOGin0Yf8ChPVPDnviL5MIlPnK7KDm3vIKw64FgttqCkL9YJ6b2/rq4o1V2PRGKkKC xxQRfFGY4Jf4NT8Yr/g1iaVQ3o5+t6h7f2AI9Huh5fPloSMpV15MzCrmt/5wAVoOaoZdbb yaUFm17LYsUDN/uSwXurEDq08ZzvvpweQwat7eXjbQkwayjcKrjMnKmx9xNXWqP0Mgqc2V hKvBrYsNzhPFbsN7NREe+f0WafuYfzv/0Zefn2pQotLlcOCt2QGWHJrSu4dnJA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1596033220; h=from:from:sender:sender:reply-to: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=2W2fiD5gf5zDpWAlZG2fcroDdYpSOcz7Sqwwo4UyE2Y=; b=MzM3jRqIec7kTy45/CWz0Msp72xEp6d+T2JaGGIfxjYRsaLB6NEvggZ6SnSyrIem6I258A Y/4GUEah9pQvkeDw== From: "tip-bot2 for Ahmed S. Darwish" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] seqlock: Implement raw_seqcount_begin() in terms of raw_read_seqcount() Cc: "Ahmed S. Darwish" , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200720155530.1173732-7-a.darwish@linutronix.de> References: <20200720155530.1173732-7-a.darwish@linutronix.de> MIME-Version: 1.0 Message-ID: <159603321925.4006.790279186396450025.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/core branch of tip: Commit-ID: 932e46365226324d2cf26d8bdec8b51ceb296948 Gitweb: https://git.kernel.org/tip/932e46365226324d2cf26d8bdec8b51ceb296948 Author: Ahmed S. Darwish AuthorDate: Mon, 20 Jul 2020 17:55:12 +02:00 Committer: Peter Zijlstra CommitterDate: Wed, 29 Jul 2020 16:14:24 +02:00 seqlock: Implement raw_seqcount_begin() in terms of raw_read_seqcount() raw_seqcount_begin() has the same code as raw_read_seqcount(), with the exception of masking the sequence counter's LSB before returning it to the caller. Note, raw_seqcount_begin() masks the counter's LSB before returning it to the caller so that read_seqcount_retry() can fail if the counter is odd -- without the overhead of an extra branching instruction. Signed-off-by: Ahmed S. Darwish Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20200720155530.1173732-7-a.darwish@linutronix.de --- include/linux/seqlock.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 85fb3ac..e885702 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -199,10 +199,11 @@ static inline unsigned raw_read_seqcount(const seqcount_t *s) */ static inline unsigned raw_seqcount_begin(const seqcount_t *s) { - unsigned ret = READ_ONCE(s->sequence); - smp_rmb(); - kcsan_atomic_next(KCSAN_SEQLOCK_REGION_MAX); - return ret & ~1; + /* + * If the counter is odd, let read_seqcount_retry() fail + * by decrementing the counter. + */ + return raw_read_seqcount(s) & ~1; } /**