Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp413598ybl; Fri, 23 Aug 2019 02:49:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwn7seEhIrzJE0c9OS9ORLU2c21Y6CZfV2i7a20aNo8WPNz28UfcTsDiF+rBmq46K/AB9zE X-Received: by 2002:a17:902:aa93:: with SMTP id d19mr3817980plr.148.1566553743529; Fri, 23 Aug 2019 02:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566553743; cv=none; d=google.com; s=arc-20160816; b=fIStoN/eIl/q27p8BmaKT2QqB8JvvkmVcGaAGybcgjNLRdaspqoOVyTGDRo2Nl4+yZ gocMje8hfjOf1dVWp059CceYcMoGhovX+F9E6wRXBaF5eb8dtVnb3VIuiul+vWuS96ys 8p6Sa7Mkz8dHvpgafAY/dNQohNQ24K/AEFczsu8FbbB+QL3CbiBVeQbnrJAdDv6DYmai 6B1CZBWIQtAOw88EWiaakS9b9CVL6ob/96OiP1KXC727fOXiDgWxz6V0Vf/xTmS4OP+n leS4i2dsXD4IFxWyDfYhSXYNFplfe6qI5ODM5dGAGXf4PZ+fMQ6nkiHsDe/JofEqOdMJ HUng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:from:date; bh=gDcgv7mODUCKZ8xYbGSNC/zzUnWxRkHNrgGeXvUDXsQ=; b=BOeidxPGCS+P49+I0ggqkByRr3IxoxLeaP3LcMk85XGgFihtLMzLyLROFtqO0QQBU9 v2Db4IyxdVjbgpiXfbLcfrj+UevEv2BaDPrkPrP5W0jAxYY2PSi9YV5l6aT2gMlN3zTv VS+psoKePujOZiQRKEIcbnhtDBgbDWvilPErYkP3Tv3j0qnga07GV7zzW+XbJHtKrf1S aaYaDN4h55+qS5C4jSlY4eHruXCNsPujArDlJGtQICVBMAjaYs+H85W8gCRRcZwZQk2O R7N8S4smzg0cKIn/6gn+/5qjaj97NRCsaVEBv3dRUBl1geFLNLjUN3/7FFlwXDjW/qrI rWdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si1514493pgr.310.2019.08.23.02.48.46; Fri, 23 Aug 2019 02:49:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389513AbfHWCMW (ORCPT + 99 others); Thu, 22 Aug 2019 22:12:22 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33714 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389305AbfHWCMS (ORCPT ); Thu, 22 Aug 2019 22:12:18 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i0z3n-0000wR-I0; Fri, 23 Aug 2019 04:12:15 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 40F451C07E4; Fri, 23 Aug 2019 04:12:15 +0200 (CEST) Date: Fri, 23 Aug 2019 02:12:15 -0000 From: tip-bot2 for Julien Grall Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] hrtimer: Don't take expiry_lock when timer is currently migrated Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Julien Grall In-Reply-To: <20190821092409.13225-4-julien.grall@arm.com> References: <20190821092409.13225-4-julien.grall@arm.com> MIME-Version: 1.0 Message-ID: <156652633520.11649.15892124550118329976.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 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 timers/core branch of tip: Commit-ID: 68b2c8c1e421096f4b46ac2ac502d25ca067a2a6 Gitweb: https://git.kernel.org/tip/68b2c8c1e421096f4b46ac2ac502d25ca067a2a6 Author: Julien Grall AuthorDate: Wed, 21 Aug 2019 10:24:09 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 21 Aug 2019 16:10:01 +02:00 hrtimer: Don't take expiry_lock when timer is currently migrated migration_base is used as a placeholder when an hrtimer is migrated to a different CPU. In the case that hrtimer_cancel_wait_running() hits a timer which is currently migrated it would pointlessly acquire the expiry lock of the migration base, which is even not initialized. Surely it could be initialized, but there is absolutely no point in acquiring this lock because the timer is guaranteed not to run it's callback for which the caller waits to finish on that base. So it would just do the inc/lock/dec/unlock dance for nothing. As the base switch is short and non-preemptible, there is no issue when the wait function returns immediately. The timer base and base->cpu_base cannot be NULL in the code path which is invoking that, so just replace those checks with a check whether base is migration base. [ tglx: Updated from RT patch. Massaged changelog. Added comment. ] Signed-off-by: Julien Grall Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20190821092409.13225-4-julien.grall@arm.com --- kernel/time/hrtimer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index f48864e..ebbd0fb 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1217,7 +1217,11 @@ void hrtimer_cancel_wait_running(const struct hrtimer *timer) /* Lockless read. Prevent the compiler from reloading it below */ struct hrtimer_clock_base *base = READ_ONCE(timer->base); - if (!timer->is_soft || !base || !base->cpu_base) { + /* + * Just relax if the timer expires in hard interrupt context or if + * it is currently on the migration base. + */ + if (!timer->is_soft || base == &migration_base) cpu_relax(); return; }