From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A392C433E0 for ; Mon, 1 Mar 2021 10:20:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1368164DBD for ; Mon, 1 Mar 2021 10:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234001AbhCAKUW (ORCPT ); Mon, 1 Mar 2021 05:20:22 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:58324 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232597AbhCAKRA (ORCPT ); Mon, 1 Mar 2021 05:17:00 -0500 Date: Mon, 01 Mar 2021 10:16:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1614593778; 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=KMrXWNyrqFlsBGFgNmfCWTvreIv3xAEl2vTQkeBNekE=; b=wH1vRmpKHcMs+2G8YYKF9Xz+wrMiLTAwmDWI92R5SrGVAVorNp3yDW+UZO43ZrOH5YLuaf lIwfHd4TGBpAOOSyumkD6cCRnw5b34X+76PUfJj5XomLN/72TbgDs+qeiHdITBW5LPwbi3 rQudBL90AefjRJOkM9TzdppBqQ5x1+RQvFhhh8V620zI/dixqM6LZjSf1eaEkea+uCLyu+ N8vCpbRoOGWDNzJkfjYLMFtMu+3qt2dMChyFdzdjpgeP27gxUPfFfdDSrzyRoLn/Yu3Ul5 t66onROt70Jk3GdYied2QEqctvVe1WqwqYtxg6AoSc6D166EZLGPCAJK4uNXig== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1614593778; 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=KMrXWNyrqFlsBGFgNmfCWTvreIv3xAEl2vTQkeBNekE=; b=1vHKcX6SSL5+NjTXRsIetq5+MFK3M/fNDy1ylPoUIJd1jjHiE+A+Mir/Q3e54g6+fHLTWy 4llgORIbN7TpVgCA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched: Collate affine_move_task() stoppers Cc: stable@kernel.org, "Peter Zijlstra (Intel)" , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210224131355.500108964@infradead.org> References: <20210224131355.500108964@infradead.org> MIME-Version: 1.0 Message-ID: <161459377735.20312.8945439217409912206.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: dbf983c0a5c37da2d476564792bd84e0e8f067fc Gitweb: https://git.kernel.org/tip/dbf983c0a5c37da2d476564792bd84e0e8f067fc Author: Peter Zijlstra AuthorDate: Wed, 24 Feb 2021 11:15:23 +01:00 Committer: Peter Zijlstra CommitterDate: Mon, 01 Mar 2021 11:02:14 +01:00 sched: Collate affine_move_task() stoppers The SCA_MIGRATE_ENABLE and task_running() cases are almost identical, collapse them to avoid further duplication. Fixes: 6d337eab041d ("sched: Fix migrate_disable() vs set_cpus_allowed_ptr()") Cc: stable@kernel.org Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Link: https://lkml.kernel.org/r/20210224131355.500108964@infradead.org --- kernel/sched/core.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 088e8f4..84b657f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2239,30 +2239,23 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag return -EINVAL; } - if (flags & SCA_MIGRATE_ENABLE) { - - refcount_inc(&pending->refs); /* pending->{arg,stop_work} */ - p->migration_flags &= ~MDF_PUSH; - task_rq_unlock(rq, p, rf); - - stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop, - &pending->arg, &pending->stop_work); - - return 0; - } - if (task_running(rq, p) || p->state == TASK_WAKING) { /* - * Lessen races (and headaches) by delegating - * is_migration_disabled(p) checks to the stopper, which will - * run on the same CPU as said p. + * MIGRATE_ENABLE gets here because 'p == current', but for + * anything else we cannot do is_migration_disabled(), punt + * and have the stopper function handle it all race-free. */ + refcount_inc(&pending->refs); /* pending->{arg,stop_work} */ + if (flags & SCA_MIGRATE_ENABLE) + p->migration_flags &= ~MDF_PUSH; task_rq_unlock(rq, p, rf); stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop, &pending->arg, &pending->stop_work); + if (flags & SCA_MIGRATE_ENABLE) + return 0; } else { if (!is_migration_disabled(p)) {