From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76A1DC433E0 for ; Wed, 17 Mar 2021 00:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 396FE64FD9 for ; Wed, 17 Mar 2021 00:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbhCQA5t (ORCPT ); Tue, 16 Mar 2021 20:57:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:33420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbhCQA4W (ORCPT ); Tue, 16 Mar 2021 20:56:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85CDD64F9C; Wed, 17 Mar 2021 00:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615942582; bh=gCSM7zXPV0rFpWt6rmRxAH+zhgyqSS6xO4K+3HZN9OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L6fFwkcUzmDubFhWJ/VqmOsrYaKy+Jm6XtJHNKnTh5/E8v3siO3bFOjGGj2pDH712 Gn+L31qpIzqBRcOv4O+t1EpebdFCcHVv+IrhJ0wOUGEPNabOCaKsWrfgJ+nOxolBir q95qud5sbYmAjn6/4bq2xE2ogzkNzHOCyhOsbH4iwigC1iEbT0YMolvChqvz76mAW1 Qf8OFHWLpeUbzv/fNSYCAOYUkc+f2gywh9axeIcBS7u75n73HOmcIiOgtIhoEYZXom Sl2ZfLv4HgBtMbPDOsj4d/qJQYBtw3upPXn6v9odElryu/xtLLMQ00tWd2U2UxbVud B4wuLfvR4LZRw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Zijlstra , Jakub Kicinski , "Ahmed S. Darwish" , "Erhard F." , Sasha Levin Subject: [PATCH AUTOSEL 5.11 38/61] u64_stats,lockdep: Fix u64_stats_init() vs lockdep Date: Tue, 16 Mar 2021 20:55:12 -0400 Message-Id: <20210317005536.724046-38-sashal@kernel.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210317005536.724046-1-sashal@kernel.org> References: <20210317005536.724046-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit d5b0e0677bfd5efd17c5bbb00156931f0d41cb85 ] Jakub reported that: static struct net_device *rtl8139_init_board(struct pci_dev *pdev) { ... u64_stats_init(&tp->rx_stats.syncp); u64_stats_init(&tp->tx_stats.syncp); ... } results in lockdep getting confused between the RX and TX stats lock. This is because u64_stats_init() is an inline calling seqcount_init(), which is a macro using a static variable to generate a lockdep class. By wrapping that in an inline, we negate the effect of the macro and fold the static key variable, hence the confusion. Fix by also making u64_stats_init() a macro for the case where it matters, leaving the other case an inline for argument validation etc. Reported-by: Jakub Kicinski Debugged-by: "Ahmed S. Darwish" Signed-off-by: Peter Zijlstra (Intel) Tested-by: "Erhard F." Link: https://lkml.kernel.org/r/YEXicy6+9MksdLZh@hirez.programming.kicks-ass.net Signed-off-by: Sasha Levin --- include/linux/u64_stats_sync.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h index c6abb79501b3..e81856c0ba13 100644 --- a/include/linux/u64_stats_sync.h +++ b/include/linux/u64_stats_sync.h @@ -115,12 +115,13 @@ static inline void u64_stats_inc(u64_stats_t *p) } #endif +#if BITS_PER_LONG == 32 && defined(CONFIG_SMP) +#define u64_stats_init(syncp) seqcount_init(&(syncp)->seq) +#else static inline void u64_stats_init(struct u64_stats_sync *syncp) { -#if BITS_PER_LONG == 32 && defined(CONFIG_SMP) - seqcount_init(&syncp->seq); -#endif } +#endif static inline void u64_stats_update_begin(struct u64_stats_sync *syncp) { -- 2.30.1