Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1724520ybn; Thu, 26 Sep 2019 00:58:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWzBzVxNbwg2zDKXTfZL0IIeeaQHaZeO9PX5oq+HQgTO7fsuLY3U8XT2QRMQcjdwSgDnDU X-Received: by 2002:a17:906:3298:: with SMTP id 24mr1919120ejw.136.1569484683233; Thu, 26 Sep 2019 00:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569484683; cv=none; d=google.com; s=arc-20160816; b=TdY+66g7ImIpOrpAx7RvuKH3unMKeppVSqZwX1rbAhOFOC3lKthINX0KbMVqalNmat 8qcrd/pgoDAXK9fis322wWvkKX0AWTur/Cl6MhG2eeN13/vxdVfITRU+1JG8dMrvzc2H 7CzJ14ju7fD6HlOJj+HKOPls2IRHYpMyiF6/vUGzgKxCgh1mHaWfzcDu3qm7xgaHJM4K 78XD1gF9S8iN0vwwBae9iTX3jVqyAIYOSaiGl+raPs6AtshXT0HCBskM6giCS9DYuuQb YM+1EvLc+tjzXHgzEtjIWdy5ouHErZS2I4m/pAZI81mailu3JgNwS7TaZ+K3Gh6SuA6e ONKw== 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; bh=Y9IvKD+rpc0+7xKrmFBqE+SZPhi+FeqNxAMjbR6IaXk=; b=n3gCuHV5QzWt7IRdm5mORqGy10VHDgq6GyFXnB0kwo5GzJ6fxMqwfJHwGPp4b8owEW wT7HbwaWK/jsXYTH5iocH3tXzf/G0ODmFrLgpuzqKaXO/h8DTh02m0NxMhpoyqjVwV7y WpmbehehyPWHURR0AL/YP04ua5+jIC6+hke0HRdLcXQT7kbQ1Tdj7Oi2+H3DZagUIcjp qMEamWTuWTojtG1r868gb611/rY6ShdkIQi3BVZYBrodhD+vUWA4/iHVvLisjAiIJo9r L2X/fQPX/wXYJgnzS16l/9kPLndvUDz9E5TCRWN8Ig13r3wodN4eENtgTmuWw6i26ra4 yvRQ== 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 o32si937215edb.63.2019.09.26.00.57.40; Thu, 26 Sep 2019 00:58: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 S2440802AbfIXLWA (ORCPT + 99 others); Tue, 24 Sep 2019 07:22:00 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33667 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389615AbfIXLWA (ORCPT ); Tue, 24 Sep 2019 07:22:00 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1iCitH-0004qN-P8; Tue, 24 Sep 2019 13:21:55 +0200 Date: Tue, 24 Sep 2019 13:21:55 +0200 From: Sebastian Andrzej Siewior To: Scott Wood Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Joel Fernandes , Thomas Gleixner , Steven Rostedt , Peter Zijlstra , Juri Lelli , Clark Williams Subject: Re: [PATCH RT v3 3/5] sched: migrate_dis/enable: Use rt_invol_sleep Message-ID: <20190924112155.rxeyksetgqmer3pg@linutronix.de> References: <20190911165729.11178-1-swood@redhat.com> <20190911165729.11178-4-swood@redhat.com> <20190917075943.qsaakyent4dxjkq4@linutronix.de> <779eddcc937941e65659a11b1867c6623a2c8890.camel@redhat.com> <404575720cf24765e66020f15ce75352f08a0ddb.camel@redhat.com> <20190923175233.yub32stn3xcwkaml@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190923175233.yub32stn3xcwkaml@linutronix.de> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-09-23 19:52:33 [+0200], To Scott Wood wrote: I made dis: diff --git a/kernel/cpu.c b/kernel/cpu.c index 885a195dfbe02..25afa2bb1a2cf 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -308,7 +308,9 @@ void pin_current_cpu(void) preempt_lazy_enable(); preempt_enable(); + sleeping_lock_inc(); __read_rt_lock(cpuhp_pin); + sleeping_lock_dec(); preempt_disable(); preempt_lazy_disable(); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e1bdd7f9be054..63a6420d01053 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7388,6 +7388,7 @@ void migrate_enable(void) WARN_ON(smp_processor_id() != task_cpu(p)); if (!cpumask_test_cpu(task_cpu(p), &p->cpus_mask)) { + struct task_struct *self = current; const struct cpumask *cpu_valid_mask = cpu_active_mask; struct migration_arg arg; unsigned int dest_cpu; @@ -7405,7 +7406,21 @@ void migrate_enable(void) unpin_current_cpu(); preempt_lazy_enable(); preempt_enable(); + rt_invol_sleep_inc(); + + raw_spin_lock_irq(&self->pi_lock); + self->saved_state = self->state; + __set_current_state_no_track(TASK_RUNNING); + raw_spin_unlock_irq(&self->pi_lock); + stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg); + + raw_spin_lock_irq(&self->pi_lock); + __set_current_state_no_track(self->saved_state); + self->saved_state = TASK_RUNNING; + raw_spin_unlock_irq(&self->pi_lock); + + rt_invol_sleep_dec(); return; } } I think we need to preserve the current state, otherwise we will lose anything != TASK_RUNNING here. So the spin_lock() would preserve it while waiting but the migrate_enable() will lose it if it needs to change the CPU at the end. I will try to prepare all commits for the next release before I release so you can have a look first and yell if needed. > > -Scott Sebastian