Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1172672ybg; Wed, 29 Jul 2020 07:36:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSTVNBIMP48O3mc4/IgsDwmP/CXwnkrk4OjXDz3GlGvwdlLImekYHUYIWlqQABAjKFZZoG X-Received: by 2002:a50:da05:: with SMTP id z5mr13632859edj.207.1596033417644; Wed, 29 Jul 2020 07:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596033417; cv=none; d=google.com; s=arc-20160816; b=lCQzR0Xqa8hqygnQuBNCp/R88mAQugGnwBkaeIxKzicvIelrjosysjr3x5SXjNrmfo HSsFas/yOFubpFOBCFocOB5KGs2QRpeGbqqGBq8Fd7W7ii0VwaZNpgJiExgiFrIjdMJe BsJn3eiUEZreTpIy9rQxTMrh0ladfMCWsZ1hSYZoURYJUjAwz50EKfOigSagk0tFO/09 RNwZKu9IIm62eZTJ4n17zI1C5tc/+3Y5Hf7kKajU8oFFfcsZ6XCKJDaNH8SmH2OuJ+u7 6U5bqlFcWSoIt7nPQmcVckIV41dnmxus47bzQbmnMo9B/02562QSJrgQZjfaPbIDh/fb dhtA== 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=iojurnLlFuOH+G6spO2lXW1oO32Pn7dx0k9FOweQP24=; b=woshXw5d7YMvCIVmN6P+d8xdEJETZR72PpaIhlHq3b3dRpkqRYcGAUOfIREqLz5V3o r1nZ51cLSJy5PHE254RmNce+NXnQVCs/tb9o4ETjsF31mxIaPM1Jsho/KCy2khGR7p1z 6ht4snQKHNwh3GzGliTpJF5gDe6TjD2Bgob8CsJmb9nRpU5vlrl83kvVREsyZJg7+fWF ShUUBNY+zKIvCvRfIA73wcLT8oTlG6UBecyh89gm8FzwYel8bfWncoDLOK2yh6ZPxj/S sjfZL242Sbq2IFdPjU7BzFaW9UTTKvzSQWaukRLv8oaOkLBEDX7QMJgieg8xGMyuR7qv G8jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=RFNMBsMg; dkim=neutral (no key) header.i=@vger.kernel.org; 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 k4si1407757eds.446.2020.07.29.07.36.35; Wed, 29 Jul 2020 07:36:57 -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=RFNMBsMg; dkim=neutral (no key) header.i=@vger.kernel.org; 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 S1728068AbgG2OfN (ORCPT + 99 others); Wed, 29 Jul 2020 10:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbgG2Od3 (ORCPT ); Wed, 29 Jul 2020 10:33:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AAB8C0619D2; Wed, 29 Jul 2020 07:33:29 -0700 (PDT) Date: Wed, 29 Jul 2020 14:33:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1596033207; 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=iojurnLlFuOH+G6spO2lXW1oO32Pn7dx0k9FOweQP24=; b=RFNMBsMgSNWftxKHxtKzicwxze/lCTBt2rwN9h+WZMVVanbelzc6NkMLGMMqT+U4GWYo3q jpX9yjDXnLEFFbqYDXWjb7Qnht5wBuACskHzoT+cZSb5VJtaHYn6EC14D3QEnOkeryDYcy Y0pmne+Q1N4O00gWYrIlBfDnVGGzSiDouJPve2CtW/Y11YvzXrVcaCijUmPOICC8j+ogPj DJKEVeAtVRmbh+mRRe5i8FHUkpaLkOqrorr+K/10ZopWm8wL1yDhHIrpnVOmMcd/P1yJgh q8yTBd702sTzQiqBVsdbeRQSH3XrBmef+FodBaE3alaC8sUR9N5TP+8Raj/ZbQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1596033207; 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=iojurnLlFuOH+G6spO2lXW1oO32Pn7dx0k9FOweQP24=; b=Ns2JRnNb9x3BkWBgTZNVz/SfeVHbK+jnglJRdshDjCwYpv7JRBOktjwsWHRgRk7swjoNca e+6ZsZ77nhKq/JAg== 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] hrtimer: Use sequence counter with associated raw spinlock Cc: "Ahmed S. Darwish" , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200720155530.1173732-25-a.darwish@linutronix.de> References: <20200720155530.1173732-25-a.darwish@linutronix.de> MIME-Version: 1.0 Message-ID: <159603320717.4006.4556629002081823174.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: af5a06b582ec3d7b0160b4faaa65f73d8dcf989f Gitweb: https://git.kernel.org/tip/af5a06b582ec3d7b0160b4faaa65f73d8dcf989f Author: Ahmed S. Darwish AuthorDate: Mon, 20 Jul 2020 17:55:30 +02:00 Committer: Peter Zijlstra CommitterDate: Wed, 29 Jul 2020 16:14:29 +02:00 hrtimer: Use sequence counter with associated raw spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_raw_spinlock_t data type, which allows to associate a raw spinlock with the sequence counter. This enables lockdep to verify that the raw spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20200720155530.1173732-25-a.darwish@linutronix.de --- include/linux/hrtimer.h | 2 +- kernel/time/hrtimer.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 15c8ac3..25993b8 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -159,7 +159,7 @@ struct hrtimer_clock_base { struct hrtimer_cpu_base *cpu_base; unsigned int index; clockid_t clockid; - seqcount_t seq; + seqcount_raw_spinlock_t seq; struct hrtimer *running; struct timerqueue_head active; ktime_t (*get_time)(void); diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index d89da1c..c403851 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -135,7 +135,11 @@ static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = { * timer->base->cpu_base */ static struct hrtimer_cpu_base migration_cpu_base = { - .clock_base = { { .cpu_base = &migration_cpu_base, }, }, + .clock_base = { { + .cpu_base = &migration_cpu_base, + .seq = SEQCNT_RAW_SPINLOCK_ZERO(migration_cpu_base.seq, + &migration_cpu_base.lock), + }, }, }; #define migration_base migration_cpu_base.clock_base[0] @@ -1998,8 +2002,11 @@ int hrtimers_prepare_cpu(unsigned int cpu) int i; for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { - cpu_base->clock_base[i].cpu_base = cpu_base; - timerqueue_init_head(&cpu_base->clock_base[i].active); + struct hrtimer_clock_base *clock_b = &cpu_base->clock_base[i]; + + clock_b->cpu_base = cpu_base; + seqcount_raw_spinlock_init(&clock_b->seq, &cpu_base->lock); + timerqueue_init_head(&clock_b->active); } cpu_base->cpu = cpu;