Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp499274rdg; Thu, 12 Oct 2023 11:36:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9ZSCGiwXnBjrt2IZ8KzeJNBH7YjuHeGQEGW+soTwOms9/U1dQtcwB/mQuKhSYXZFElXfH X-Received: by 2002:a05:6a20:a121:b0:134:a4e2:4ac8 with SMTP id q33-20020a056a20a12100b00134a4e24ac8mr25568611pzk.39.1697135803383; Thu, 12 Oct 2023 11:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697135803; cv=none; d=google.com; s=arc-20160816; b=pRury2D6/ZwBhjKMFuBZ4tI2+KGuCHcwYIQv/jrNbs9PuUZgD3ChamEurrcAYSOpW2 0X9A5gUVeDtFvfJRI2wkS9NWyQGrw2ZX8c8eO1+HkTserbS5AVVFbN4kZ8hNQP46x15F UqKqV50IVPPHUSHHcfu/xrn7OoMN0M+1Z9+YWDuxbXzdAHhTyQzaVkcOxy12trzjpwuu FG61rCAcRHj6Fc98vE7XRpdRwJL0UK5d9HVfkGuw4Z3kCJgXpYKshwrn1imx3dCCsT+C EE3WcbPtKgrF0X2coco6zzYro+YZxqai0S4Zz6IWxelbR32FUAjvUTg39akC7zhqYpLX 8kqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=L2nIrcLmRRoEjLnrmI7Wbsm+A7PZaXBdayO8FQILJ/I=; fh=kFB9uQyxVvjm2R0ul7wxypzO2CDQ/Wd3RLAPUv0GPQE=; b=G/ZfGRSBzKVkdbl0znj+F0f/MSd2WBstzx9LCNpMKofVGdmA0dIzpNEkZREFiS9YC/ OoJven5MZ69noHJ/o054bPqtr20osXM49ewmw1gcLFnPeTSNP9UKBjA6Rdep46lR+R3t uZGnP6zuyKZq788vkYTjjDbc077xwhIhTVaA2Mc1/rQ09FNNItx415RV+6r0Y6oB75fm 3hoCDjzJaCBMwjOo9hwv5w7PGy3hYDP+DQZeHaTjWyZeq7UowPzXPkqSkLfo0qajXdcM JcSr8kA2Dz4exlbm634SrZ2YqJuzL2OKqSvQl4eUA2zcyLhEjDV7H0H29uTZYlZCIWzR pg7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fMAhcxBE; dkim=neutral (no key) header.i=@linutronix.de header.b=ZbQ8yM0J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id 38-20020a631966000000b0058a09ed5ca2si2770419pgz.313.2023.10.12.11.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 11:36:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fMAhcxBE; dkim=neutral (no key) header.i=@linutronix.de header.b=ZbQ8yM0J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8499E825A0E7; Thu, 12 Oct 2023 11:36:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235800AbjJLSgL (ORCPT + 99 others); Thu, 12 Oct 2023 14:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235787AbjJLSgG (ORCPT ); Thu, 12 Oct 2023 14:36:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB9CFDA; Thu, 12 Oct 2023 11:35:56 -0700 (PDT) Date: Thu, 12 Oct 2023 18:35:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697135755; 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=L2nIrcLmRRoEjLnrmI7Wbsm+A7PZaXBdayO8FQILJ/I=; b=fMAhcxBE9/b3hrvmpSlWE4U3Z/g/aUU99fiadOpPOnxwH8idfeUQgIU8bqzazxrSeFRGNG alf4378AeoG+OcW9NVJGuq1GHLwmWRJxMgzLAfittocF2/0iblL8p0RuFob72caiAgWzTe vljv8HvdmF0P8ai+ks8xDe3Uen3MkR+Rqvjt4n2eaW02JfrravfS1oXYfhW34OLTBAW1qh n9MVEkTbCO32xle2hYumBa4MG5pKASUcwx4zlQVFiwQl9CPP1W3yYx3YGpTzLIN2Mbpdku nMDooxFYl7/osza6cciV7bHmRz77AjznV9QML/dtzP8trnkRuHj1SyvfKLiUdQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697135755; 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=L2nIrcLmRRoEjLnrmI7Wbsm+A7PZaXBdayO8FQILJ/I=; b=ZbQ8yM0JkoLuCuwKcVBbqPLSM1sxlTALMnKV+PBDIm/MFWrHZswaM4q4jOatxxeCiaRcIY YDVCunJsb/Zs9/AA== From: "tip-bot2 for Oleg Nesterov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/seqlock: Change __seqprop() to return the function pointer Cc: Oleg Nesterov , Ingo Molnar , Peter Zijlstra , Waiman Long , Will Deacon , Thomas Gleixner , Linus Torvalds , "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231012143227.GA16143@redhat.com> References: <20231012143227.GA16143@redhat.com> MIME-Version: 1.0 Message-ID: <169713575405.3135.4365014722583581048.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 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 11:36:40 -0700 (PDT) The following commit has been merged into the locking/core branch of tip: Commit-ID: e6115c6f7a0ce3388cc60b69a284facf78b5dbfd Gitweb: https://git.kernel.org/tip/e6115c6f7a0ce3388cc60b69a284facf78b5dbfd Author: Oleg Nesterov AuthorDate: Thu, 12 Oct 2023 16:32:27 +02:00 Committer: Ingo Molnar CommitterDate: Thu, 12 Oct 2023 20:18:21 +02:00 locking/seqlock: Change __seqprop() to return the function pointer This simplifies the macro and makes it easy to add the new seqprop's with 2 or more args. Plus this way we do not lose the type info, the (void*) type cast is no longer needed. And the latter reveals the problem: a lot of seqcount_t helpers pass the "const seqcount_t *s" argument to __seqprop_ptr(seqcount_t *s) but (before this patch) "(void *)(s)" masked the problem. So this patch changes __seqprop_ptr() and __seqprop_##lockname##_ptr() to accept the "const LOCKNAME *s" argument. This is not nice either, they need to drop the constness on return because these helpers are used by both the readers and writers, but at least it is clear what's going on. Signed-off-by: Oleg Nesterov Signed-off-by: Ingo Molnar Cc: Peter Zijlstra Cc: Waiman Long Cc: Will Deacon Cc: Thomas Gleixner Cc: Linus Torvalds Cc: Paul E. McKenney Link: https://lore.kernel.org/r/20231012143227.GA16143@redhat.com --- include/linux/seqlock.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 7e7109d..4b8dcd3 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -200,9 +200,9 @@ typedef struct seqcount_##lockname { \ } seqcount_##lockname##_t; \ \ static __always_inline seqcount_t * \ -__seqprop_##lockname##_ptr(seqcount_##lockname##_t *s) \ +__seqprop_##lockname##_ptr(const seqcount_##lockname##_t *s) \ { \ - return &s->seqcount; \ + return (void *)&s->seqcount; /* drop const */ \ } \ \ static __always_inline unsigned \ @@ -247,9 +247,9 @@ __seqprop_##lockname##_assert(const seqcount_##lockname##_t *s) \ * __seqprop() for seqcount_t */ -static inline seqcount_t *__seqprop_ptr(seqcount_t *s) +static inline seqcount_t *__seqprop_ptr(const seqcount_t *s) { - return s; + return (void *)s; /* drop const */ } static inline unsigned __seqprop_sequence(const seqcount_t *s) @@ -292,19 +292,19 @@ SEQCOUNT_LOCKNAME(mutex, struct mutex, true, mutex) #define SEQCNT_WW_MUTEX_ZERO(name, lock) SEQCOUNT_LOCKNAME_ZERO(name, lock) #define __seqprop_case(s, lockname, prop) \ - seqcount_##lockname##_t: __seqprop_##lockname##_##prop((void *)(s)) + seqcount_##lockname##_t: __seqprop_##lockname##_##prop #define __seqprop(s, prop) _Generic(*(s), \ - seqcount_t: __seqprop_##prop((void *)(s)), \ + seqcount_t: __seqprop_##prop, \ __seqprop_case((s), raw_spinlock, prop), \ __seqprop_case((s), spinlock, prop), \ __seqprop_case((s), rwlock, prop), \ __seqprop_case((s), mutex, prop)) -#define seqprop_ptr(s) __seqprop(s, ptr) -#define seqprop_sequence(s) __seqprop(s, sequence) -#define seqprop_preemptible(s) __seqprop(s, preemptible) -#define seqprop_assert(s) __seqprop(s, assert) +#define seqprop_ptr(s) __seqprop(s, ptr)(s) +#define seqprop_sequence(s) __seqprop(s, sequence)(s) +#define seqprop_preemptible(s) __seqprop(s, preemptible)(s) +#define seqprop_assert(s) __seqprop(s, assert)(s) /** * __read_seqcount_begin() - begin a seqcount_t read section w/o barrier