Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp786659imm; Thu, 5 Jul 2018 08:52:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdzbbRKBUSgg3GXJAHr/yXo2dHWXXAnBQnbUWg+YKhiQjf/+ABGyoJvFkgR8f7hgdT5bvPd X-Received: by 2002:a63:4c21:: with SMTP id z33-v6mr6112847pga.383.1530805954311; Thu, 05 Jul 2018 08:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530805954; cv=none; d=google.com; s=arc-20160816; b=QforCCb9j0hdYCRwRLpapcsViXf9w46Ad3Jf52Q6KQBssIM40S7ifb12gjZNwo8UAo whaQgle7xNyA04a7GFcbFhkN4ctHFhQkYZMXgQLtn/g28wzP+S8/Mlqw3QMn50jrG7Rr qDq0WA3nOp0DTtADsHe2SbrERB3j5fkciK0RrKs2t1sBzQWkdNpq56SMgFENo/HjdXTV wA5KPepF92ns6gH2wuwe/GKy1b6DgOLXyGx0bpcZPbHxJObz7J/zFkaMNwe1CgvmZGEt NpwH3mYi5l5YPVz0P+ZCGgZU7MjKGh+085wavCQx8g8hUWnwE3tBTcN1e/Qa06W7Wyd9 j/tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=c4qtYtfKgofnraNa8NZVfM35xnY0btrQs3MmJigNy7E=; b=cpvnvbMARKDA3gjyw408HfBH1fpZwGduiWng7gA71C7LhllbMy731qArDF9yinPVTX RB7+f7NTTLvbDnubjggUprxPuI5xl1BpxtFP0bM1sJNYWDaA+8MQkfacPZgtpIK5H9Ro iUpP+0qHhA//+vww3K6RMeKL8ckI27thwREO37o7qjjyczMkptJQ/BRJbuDU8Vpftt64 b6Ffe0wyqSozsKacMCS+sUnDojTwV2Tm5HSmDZu+hV/LoLj+PxAsW58OYvfJPXhWur6r V1SGigwwh/0dicAS5v+405LR1LwQtMcGpPmHtR2DrleXsjuk0ZlPbBitvSZJnrFPBoeg Tp8Q== 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 bi1-v6si6114386plb.126.2018.07.05.08.52.20; Thu, 05 Jul 2018 08:52:34 -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 S1754032AbeGEPum (ORCPT + 99 others); Thu, 5 Jul 2018 11:50:42 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:50994 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753859AbeGEPul (ORCPT ); Thu, 5 Jul 2018 11:50:41 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1fb6Wg-0006Pd-Ub; Thu, 05 Jul 2018 17:50:35 +0200 Date: Thu, 5 Jul 2018 17:50:34 +0200 From: Sebastian Andrzej Siewior To: Joe Korty Cc: Julia Cartwright , tglx@linutronix.de, rostedt@goodmis.org, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RT] sched/migrate_disable: fallback to preempt_disable() instead barrier() Message-ID: <20180705155034.s6q2lsqc3o7srzwp@linutronix.de> References: <20180704173519.GA24614@zipoli.concurrent-rt.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180704173519.GA24614@zipoli.concurrent-rt.com> User-Agent: NeoMutt/20180512 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org migrate_disable() does nothing !SMP && !RT. This is bad for two reasons: - The futex code relies on the fact migrate_disable() is part of spin_lock(). There is a workaround for the !in_atomic() case in migrate_disable() which work-arounds the different ordering (non-atomic lock and atomic unlock). - we have a few instances where preempt_disable() is replaced with migrate_disable(). For both cases it is bad if migrate_disable() ends up as barrier() instead of preempt_disable(). Let migrate_disable() fallback to preempt_disable(). Cc: stable-rt@vger.kernel.org Reported-by: joe.korty@concurrent-rt.com Signed-off-by: Sebastian Andrzej Siewior --- include/linux/preempt.h | 4 ++-- kernel/sched/core.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/preempt.h b/include/linux/preempt.h index 043e431a7e8e..d46688d521e6 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h @@ -241,8 +241,8 @@ static inline int __migrate_disabled(struct task_struct *p) } #else -#define migrate_disable() barrier() -#define migrate_enable() barrier() +#define migrate_disable() preempt_disable() +#define migrate_enable() preempt_enable() static inline int __migrate_disabled(struct task_struct *p) { return 0; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ac3fb8495bd5..626a62218518 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7326,6 +7326,7 @@ void migrate_disable(void) #endif p->migrate_disable++; + preempt_disable(); } EXPORT_SYMBOL(migrate_disable); @@ -7349,6 +7350,7 @@ void migrate_enable(void) WARN_ON_ONCE(p->migrate_disable <= 0); p->migrate_disable--; + preempt_enable(); } EXPORT_SYMBOL(migrate_enable); #endif -- 2.18.0