Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528639pxf; Mon, 15 Mar 2021 11:34:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3plDfsbEWDq38gXpCGymI0M6KF2AFhInvF/gy+UfzeHnrRsw906OjC+Fq2TupQxt0lCCm X-Received: by 2002:a05:6402:10c6:: with SMTP id p6mr31524141edu.241.1615833258486; Mon, 15 Mar 2021 11:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833258; cv=none; d=google.com; s=arc-20160816; b=gFjLKtHfTOh3tiRSiQg1lGxAIQGejbAdR8jn1lD58S+r8rw1u7AKXuU4uvuzqqW2EM hvglFGXiZPzjgxfrpU639X9VFxiJkl9wgT0NqsUTxzC9FkTqS5qg65zHRgewf0yiP4D4 0+tX6IcAj1UEnCW/CYM6shh2m065KnBpAFpFHxZw+XKhfHodK25kVxnw05X6N3KG7M3c R5A7MbdEYuOSXEeHyhVFb14KlODrVFUy44Kij8vfo95fsvF+09raWg5Hk9UYm3EB8xyl du0SvmzQfzgeCHx+ZJZVCfnsuN0kw8OmQCsu0l+5+UQ50lofhedOA+x/gdGZaC+9hjVo ATgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0PAu5NnxQsO799xxOmN+0NN00bWFiBegQwcUpvnvUWo=; b=mYAQXmQqkwtxba1C+CbacmYQuMgLQ31HVtA321yT/VVjb2ABJ3FnwQujVidROXN9kg 6ryaW2QVXRYu1kggIfV60zohFugM06B/j6e+ucfE3cQEHb4GSnghPtSzqsyPyC6IUKtQ D3vz2vS9hyCHqGs76awQpPdzNLu78j/YBHFiVK03iSBDt9WjX4v2TiQ/VRlhOLetG/s/ r5uLosPdujNeZ59zOiiuuHZu+nkq73jziD2QwEO+SfNB1CdzQ5vRzC8sV3Gx4U5IwlwC 5DfSIl7Qokdg2l7joAPonBDtQ1cbneGxzyRzVzj3JA2fH2hGgyRX2NsvaRXsHwVp4y8X YPfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=t5KmDIYZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p31si12556122edb.114.2021.03.15.11.33.56; Mon, 15 Mar 2021 11:34:18 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=t5KmDIYZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238833AbhCOOpJ (ORCPT + 99 others); Mon, 15 Mar 2021 10:45:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:51552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234485AbhCOOEL (ORCPT ); Mon, 15 Mar 2021 10:04:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 001AE601FD; Mon, 15 Mar 2021 14:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817048; bh=wTkS8Du1PyKudOn9ERCR7T2hGeUF3cVTnJ+QTC5wg/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5KmDIYZAPE+f6I/X0QygJwbVolhz1dYC+DCnoVM4814XvFCepj2dHxuRUqj4Ncds EtZzonmdrjvhU2NQo4HhuUnLIoF9lWaKjjkmLiwVb1i2MhayfxX3hYdRRaOHSdaBZ8 d9KQK/3L9FDb/qza/9lf8bPD0PKEP7JKyP1RcDQo= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, "Peter Zijlstra (Intel)" , Ingo Molnar , Valentin Schneider Subject: [PATCH 5.11 274/306] sched: Collate affine_move_task() stoppers Date: Mon, 15 Mar 2021 14:55:37 +0100 Message-Id: <20210315135516.922062784@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Peter Zijlstra commit 58b1a45086b5f80f2b2842aa7ed0da51a64a302b upstream. 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) Signed-off-by: Ingo Molnar Reviewed-by: Valentin Schneider Link: https://lkml.kernel.org/r/20210224131355.500108964@infradead.org Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2279,30 +2279,23 @@ static int affine_move_task(struct rq *r 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)) {