Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp491619rdg; Thu, 12 Oct 2023 11:21:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKVIgzvtJS+VVjiWufwDqn1YfQgIWQJmCzpQBA21Fsm2qpJpnACzg9UmlGBawUpfuPcXwr X-Received: by 2002:a17:902:f688:b0:1c6:3228:c2ca with SMTP id l8-20020a170902f68800b001c63228c2camr33086163plg.29.1697134899105; Thu, 12 Oct 2023 11:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697134899; cv=none; d=google.com; s=arc-20160816; b=XZWU6NjeAuebPitjYeDTtKUXLBVuG7r3v0sYVP4OhhP2oHMeDTBCT+ypI/iDL1NY2A v8A77hEAsliWmxGoGpO/2RIJsvIJUvegKGtGY38DtAHf+OrDq/11c8BHCnmpZaApMe5W 1woN/p0xZQ2XPGUpcXrog8HVZ4cy5P4Tk1GLDGzmcaXQrqsBqOgxikZtvkUwZlj+je+c WtHzmxFe17AKkIQpmJoXU6YQa3Qai1Ny2WvtNWhWf7k/SV3FMdDUoSur7VHJi6oIHLzr FUadgy1u/wWs8V1wbc1W+phZsoFankBK81NZn31dmW1AxkV5xfUT2qX3AqotaiJa22zn ryPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=JcB95Amibgw0phr7xM38p2RHGuYQp8QNhqrDp7sB1Mc=; fh=xwHi+adiFTxzYcJSS9Uzr8rVGe/fbmdwPgLEnYitPAw=; b=tQID1iYB12V83D3OcvXilnO+4e11uwW/CUSnSUR5Ji9sqrrVWDG1W43pJom/ytT5f+ DPR78Iik/fD2GC90cPi85SO2JqxyKpKvnaD2u+M86OFgtUjLX57ylbYWirScNEPqqqH8 7oriOcT2t3QOMHh8LlGX0S6sKsMGYS8ZfH9OWQmEvUlQPrwteidq7ju/4fG3b4CUTLnq p/x/6KmfIFxhx4PcZy3bzeIUj/7cxRqbtTH57ywrfeLNcLX1MG8JACW/Mc0YC0zCYHf6 3GZn7qHe8DdSb9DG13Z8t1epHmrc1nma2Ghf4hqcmgrPE+PROcD2k3s6Lr0bnJGRG6US 2LCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Jig4igLW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l8-20020a170903244800b001bf1a9dbcc9si2704267pls.549.2023.10.12.11.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 11:21:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Jig4igLW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5C6ED8239E95; Thu, 12 Oct 2023 11:21:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441922AbjJLSVf (ORCPT + 99 others); Thu, 12 Oct 2023 14:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379624AbjJLSVd (ORCPT ); Thu, 12 Oct 2023 14:21:33 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6635ACA for ; Thu, 12 Oct 2023 11:21:32 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9a645e54806so199207166b.0 for ; Thu, 12 Oct 2023 11:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697134891; x=1697739691; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=JcB95Amibgw0phr7xM38p2RHGuYQp8QNhqrDp7sB1Mc=; b=Jig4igLWh0cJ/gcNOGTdD1TIH9Rqq/xTA1z4zi8nFQ9g9MIR6nHRt6CTaraB+C0NsM LW9mklXOiMTJn+xfwLtgBGXp+LPjEXLQ5+IN9IXamEKjF3uWjCc5BIMtSgiukYeLqxMK Jf7ruHza8IBVHBZb9NrcvefPGZIWCwXiDwhEI4UHrPdE3i9qKvRtUdlEJxE1dLTRIILK UoY6pez8rqPNC9oAhc94ItEeO62C9AWJurlw3mbslLZLiWVWqoDV86ugDwqn43xX+TMA riJSJ57rzUFgS9TMvBQvNuWE8f1wp5X+ykbMaYOi1FbCw+QKuxk62thhvPpfzmIYmN7n AbUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697134891; x=1697739691; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JcB95Amibgw0phr7xM38p2RHGuYQp8QNhqrDp7sB1Mc=; b=BhyT0fLzMiuk2JZxcg9jA9FzbaagudCltlK0ZdHQRZTiw0BQpbzstrQ3+PHfq12Kyw 48HwWp7kVPzET2iiG9tenasJI4t/EIekRlkfTXGB5eyjXhZ3gSja+heBURDiSXENqjem m/em1boAvsKhvvqm2/3lG8OJdKt2Ny+1uPPgHz5vddfJHy3+STnfRfRMvXfAR48iqhjJ VF1DZ0qrlDFjIWU3A7F3pIVcrm1pPTKBrn5m2hYbEAXUfwBJvYhj5iPPQiOlzG1GGQaT pIfaRjcdgi1rUQyQPBUcDKotixEY9J7qArmkV96ge4Zr6rDgQBe6K6KQcRwWF03PDSX6 nIBQ== X-Gm-Message-State: AOJu0Yx7Rk1setpcp35f13XlVi6LbfNoELpGE5PBGW+bqee2+JHYfdVF A8gC2Uu3RK7DAQPOL93Yvlg= X-Received: by 2002:a17:906:2921:b0:9b9:faee:4228 with SMTP id v1-20020a170906292100b009b9faee4228mr16098461ejd.56.1697134890672; Thu, 12 Oct 2023 11:21:30 -0700 (PDT) Received: from gmail.com (1F2EF405.nat.pool.telekom.hu. [31.46.244.5]) by smtp.gmail.com with ESMTPSA id kf24-20020a17090776d800b009b95787eb6dsm11287391ejc.48.2023.10.12.11.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 11:21:30 -0700 (PDT) Sender: Ingo Molnar Date: Thu, 12 Oct 2023 20:21:28 +0200 From: Ingo Molnar To: Oleg Nesterov Cc: Peter Zijlstra , Alexey Gladkov , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , linux-kernel@vger.kernel.org, Linus Torvalds , Thomas Gleixner Subject: Re: [PATCH v2 2/2] seqlock: change __seqprop() to return the function pointer Message-ID: References: <20231012143158.GA16133@redhat.com> <20231012143227.GA16143@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231012143227.GA16143@redhat.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 11:21:38 -0700 (PDT) * Oleg Nesterov wrote: > 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. > +__seqprop_##lockname##_ptr(const seqcount_##lockname##_t *s) \ > { \ > + return (void *)&s->seqcount; /* drop const */ \ > } \ > +static inline seqcount_t *__seqprop_ptr(const seqcount_t *s) > { > + return (void *)s; /* drop const */ > } Okay, so dropping 'const' makes sense in terms of staying bug-compatible with the previous API and not build-breaking the world - but could we perhaps follow this up with fixups of the type misuse and then a removal of the forced type casts from these APIs? Meanwhile I'm applying your patches to tip:locking/core, unless someone objects. Thanks, Ingo