Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1322549pxk; Thu, 10 Sep 2020 12:28:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrclupF+/ZO6gznbyaYiDgSaGDfEuU1/xOeEyOro+wId2zFghGx7fyn6doVrtq/63YXRJi X-Received: by 2002:aa7:d606:: with SMTP id c6mr11251767edr.370.1599766102527; Thu, 10 Sep 2020 12:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599766102; cv=none; d=google.com; s=arc-20160816; b=u3HgdUCmgl3rEm5Kv8fU7E0woPiCD9KmjYjWd2WVerGszzPodTu6SAaf4RfphwdZ58 HvATQWiLqjKfaRcyKyMDzTMcrmhj9j1AhrIHjQCWtaz5lTXWdjT2gLdQh3xwHB2sD3bX 13klIJ0w731cJYvWdWrAUshUY+9pNQL87KvIp5jzR+suvqpyV+A9xksU8BOe/3LmQdih 11WXEhePHyNcs4gzjzorvVt9ooIQ/la7T+FfeQUYsAcE4OBY+hSOwyO5PnRZ17LqIjpp 1g+II021i+wh8n/BnIaF726DjsN/KK8FoOkBX2HgaUhf0jraMMVV6bhUiOONjm3rF29o ZnHA== 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=Nxy1DHpcw4NzFK3ktRgxyoEl9LnzftlIXEEZObm4SdE=; b=Ql5K9+6gsK/zW2r1EM7Jkt17Wcb1ED15POEyZ8O6x4/pgjAmBoIJPw6pa8bX+h6akg O40UUArVhlml7jS76XUa1/Zw1tAGsA9JbXILpQG5KxQRXsxZFEZCqH22RzvQ75dheWJb qD6bKSHMzj+Ogtp/4WLrQFPsZG5iWC7FKvpfZ5cvLe9pi6/352psH+7g4cK8q07l7eHD S0Tr006kDWFL48pBGVZ//jomSFiTsYLlwz42Idf2aPz0HNSTl9OOFDMH7G0vHuPnJsb0 LcnEVAK5Zch2dOJbskkN5yoQHT642SYlUn+CB5XEJg+WMSk6r+sOGLUdkrJSzxr+jC2F Symw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=KMkqAsWF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SRNhO+Y2; 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 ox7si4348055ejb.336.2020.09.10.12.28.00; Thu, 10 Sep 2020 12:28:22 -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=KMkqAsWF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SRNhO+Y2; 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 S1725844AbgIJT1V (ORCPT + 99 others); Thu, 10 Sep 2020 15:27:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731351AbgIJPsR (ORCPT ); Thu, 10 Sep 2020 11:48:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FEA5C06134E; Thu, 10 Sep 2020 08:08:28 -0700 (PDT) Date: Thu, 10 Sep 2020 15:08:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1599750506; 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=Nxy1DHpcw4NzFK3ktRgxyoEl9LnzftlIXEEZObm4SdE=; b=KMkqAsWFJlF3Hvw0ytOBueMi+rAuY1Qidu9TRR1KzAATkOkcjlRIfwNR2Y+GbDLjsr8iR6 Iz0sSpGOqSNIKwCOX7/KLtHviA5WQ7n+DBgfk1KXMr2Qb9puGHuUHAbfEA4d0fFo1KON2H lwnHrV8A2uaXjiLfNDGC/ZmwT3imu/EbiGtjlkwzRBnAE96S3u49AV/prCJvEsJVpIj1Sx fD+/LbZqEnFEg9Ti2Nfzqm8VJjwlLQ3BOhc0F1UK56uDxNNQgt+5T7QYrnZXYLqOb2qawm mBFolJMbWdfXztxGEGNa2AL5FhOHjiepbo7eHIBmbubykxCe6ySEYM/PGKcNpg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1599750506; 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=Nxy1DHpcw4NzFK3ktRgxyoEl9LnzftlIXEEZObm4SdE=; b=SRNhO+Y2qINVHNZLVvIZrwsgDdl3woNvIqAS44dIK8b/kd8qFPwTxtaMVdPwOeVfXixA4B B48I6NsdI9k2IKAA== 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: seqcount latch APIs: Only allow seqcount_latch_t Cc: "Ahmed S. Darwish" , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200827114044.11173-9-a.darwish@linutronix.de> References: <20200827114044.11173-9-a.darwish@linutronix.de> MIME-Version: 1.0 Message-ID: <159975050603.20229.9844172785774718591.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: 0c9794c8b6781eb7dad8e19b78c5d4557790597a Gitweb: https://git.kernel.org/tip/0c9794c8b6781eb7dad8e19b78c5d4557790597a Author: Ahmed S. Darwish AuthorDate: Thu, 27 Aug 2020 13:40:44 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 10 Sep 2020 11:19:30 +02:00 seqlock: seqcount latch APIs: Only allow seqcount_latch_t All latch sequence counter call-sites have now been converted from plain seqcount_t to the new seqcount_latch_t data type. Enforce type-safety by modifying seqlock.h latch APIs to only accept seqcount_latch_t. Signed-off-by: Ahmed S. Darwish Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20200827114044.11173-9-a.darwish@linutronix.de --- include/linux/seqlock.h | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 88b917d..f2a7a46 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -620,7 +620,7 @@ static inline void seqcount_latch_init(seqcount_latch_t *s) /** * raw_read_seqcount_latch() - pick even/odd latch data copy - * @s: Pointer to seqcount_t, seqcount_raw_spinlock_t, or seqcount_latch_t + * @s: Pointer to seqcount_latch_t * * See raw_write_seqcount_latch() for details and a full reader/writer * usage example. @@ -629,17 +629,14 @@ static inline void seqcount_latch_init(seqcount_latch_t *s) * picking which data copy to read. The full counter must then be checked * with read_seqcount_latch_retry(). */ -#define raw_read_seqcount_latch(s) \ -({ \ - /* \ - * Pairs with the first smp_wmb() in raw_write_seqcount_latch(). \ - * Due to the dependent load, a full smp_rmb() is not needed. \ - */ \ - _Generic(*(s), \ - seqcount_t: READ_ONCE(((seqcount_t *)s)->sequence), \ - seqcount_raw_spinlock_t: READ_ONCE(((seqcount_raw_spinlock_t *)s)->seqcount.sequence), \ - seqcount_latch_t: READ_ONCE(((seqcount_latch_t *)s)->seqcount.sequence)); \ -}) +static inline unsigned raw_read_seqcount_latch(const seqcount_latch_t *s) +{ + /* + * Pairs with the first smp_wmb() in raw_write_seqcount_latch(). + * Due to the dependent load, a full smp_rmb() is not needed. + */ + return READ_ONCE(s->seqcount.sequence); +} /** * read_seqcount_latch_retry() - end a seqcount_latch_t read section @@ -656,7 +653,7 @@ read_seqcount_latch_retry(const seqcount_latch_t *s, unsigned start) /** * raw_write_seqcount_latch() - redirect latch readers to even/odd copy - * @s: Pointer to seqcount_t, seqcount_raw_spinlock_t, or seqcount_latch_t + * @s: Pointer to seqcount_latch_t * * The latch technique is a multiversion concurrency control method that allows * queries during non-atomic modifications. If you can guarantee queries never @@ -735,14 +732,11 @@ read_seqcount_latch_retry(const seqcount_latch_t *s, unsigned start) * When data is a dynamic data structure; one should use regular RCU * patterns to manage the lifetimes of the objects within. */ -#define raw_write_seqcount_latch(s) \ -{ \ - smp_wmb(); /* prior stores before incrementing "sequence" */ \ - _Generic(*(s), \ - seqcount_t: ((seqcount_t *)s)->sequence++, \ - seqcount_raw_spinlock_t:((seqcount_raw_spinlock_t *)s)->seqcount.sequence++, \ - seqcount_latch_t: ((seqcount_latch_t *)s)->seqcount.sequence++); \ - smp_wmb(); /* increment "sequence" before following stores */ \ +static inline void raw_write_seqcount_latch(seqcount_latch_t *s) +{ + smp_wmb(); /* prior stores before incrementing "sequence" */ + s->seqcount.sequence++; + smp_wmb(); /* increment "sequence" before following stores */ } /*