Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3420306pxf; Mon, 29 Mar 2021 01:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIaFNuumeh3t5gz7owEHeMsRqSIZyJUl394oar5I394RGUkENvjxLIlxqZ08AgMSZ+Rcwd X-Received: by 2002:a17:907:e87:: with SMTP id ho7mr26890056ejc.2.1617006737186; Mon, 29 Mar 2021 01:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006737; cv=none; d=google.com; s=arc-20160816; b=tJ6pmOHpgn9L+dbzwtrqd1oDFKUYLsC+zCP76fNdVsbRpiJ4nwdz6rBjJZfIk7tsWj QBxzsbRyY3vP2+1yYm/ZnQObPBsiGA8gXAKMdHSiKSP5Z5tjDpbpBSLw4bbemlwVf7S4 bhxRJwz66JlJcj08WcwDJPpejYhM/J5QKnNgSkqtybevt6/uLuUQeY5Fys1PF+GfweG/ ukAo7gCoMyozm76E6AzPtHb9n1d2uwfeyRqAdH15mUptEgjP9MKuR3rCvzNi3i4qrM+d 3oA7mqghZ5dx9yr9cmAGjnwAhJ9PVu2Vwhatt4AQZUGxr6xvqHjiX/omM0DhOpxmYcHw LTLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aS91pWNui/0sEGbPS02doW+OTJdEiAlVe+J/PCepM/c=; b=aPpB3MQkI/gnGtUNZUnwTEvx0VQlRcBbKR0MHRq4JoWPLN9fIcosP42dfCgryBLG9P f4Fpx1q2FFn1DgbwFDEaimjrD/s2Y4qj8TyldZJDHRv8AdEGcbUOEe+zAq2ew+PtKzZT NY+sentjhU/6QuZlrfnmmHT1Qe1K5vMt7ENGG7DSZzYd84H09UflaJqMhYy6j66lvwZU XRQfpoq3g1RZb0pkMiMVd+wSoWwz53G3wk5aMXgF36Mt/Dmm2SWv5ttKKyxAyPXi75Qu oo0QVKK+sraoMiigIh+vOKFIFDMjk/i1Sp7Sz4kfM5ZBRUfAEOBFCesagLhfXeAvDGel 4wYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="g+/VmUAz"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg8si12979585ejc.657.2021.03.29.01.31.53; Mon, 29 Mar 2021 01:32:17 -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=pass header.i=@linuxfoundation.org header.s=korg header.b="g+/VmUAz"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234463AbhC2I20 (ORCPT + 99 others); Mon, 29 Mar 2021 04:28:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:34116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232615AbhC2IR6 (ORCPT ); Mon, 29 Mar 2021 04:17:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EC73A61477; Mon, 29 Mar 2021 08:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005878; bh=gCSM7zXPV0rFpWt6rmRxAH+zhgyqSS6xO4K+3HZN9OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+/VmUAzLRYEje8UX65FGM9y5YWAbpd2rjzehIl/bNLTN+DJSl+PrHDQngUhP9npv AQFW9BWnI4Sq14lzlhUveMpOCls8xZdv8nT8wNwNGH1OdszOV8KdBQA5SyK5H3swXj zybCI/MeQeuSivDrOIFsSWlUO+XOi32blb2RNTbA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , "Peter Zijlstra (Intel)" , "Erhard F." , Sasha Levin , "Ahmed S. Darwish" Subject: [PATCH 5.10 038/221] u64_stats,lockdep: Fix u64_stats_init() vs lockdep Date: Mon, 29 Mar 2021 09:56:09 +0200 Message-Id: <20210329075630.446838453@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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