From patchwork Wed Feb 15 10:33:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 57471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp116011wrn; Wed, 15 Feb 2023 02:40:30 -0800 (PST) X-Google-Smtp-Source: AK7set+14lwfmbn19lfAIDVSAND/Nyy0da1VI/zb9pl1izz6GTg43xg2Z3qS9gd4OA3h6I1brSM2 X-Received: by 2002:a05:6402:b15:b0:4ac:b7ba:3d58 with SMTP id bm21-20020a0564020b1500b004acb7ba3d58mr1280982edb.12.1676457630171; Wed, 15 Feb 2023 02:40:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676457630; cv=none; d=google.com; s=arc-20160816; b=kyO4XX28jAN9dFA533zxKUMx4a848aOwwOiXkW4q1YIi7Pygxs0Zx/QBW+ZyKgJe+h uhnP4bDrT/IzRX4yNVW4fL5qJ2GY2CuUW5MLEhfRlmGhe+MfFWjUsfQZ4AJBE1mM21gR NA7vt1jLXhL4q+Wts2qXXeBkEhoU7fKm/yZOJ1KjHoLu/g7SAhUot3VNHr6T1GyrYEMS nqVKLR5ba9cw005+VnaC7oAOfSJfdJEB44OWemYuXk40fv10JMstGK1chUGl3Vu/H9EU w+TxqWUGmt0fWmfdfaEinDL/uNNrVzs2U6hpSm+6GFlcLc4UHLmem6i4grPKUClN1Fwk 2hQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=f+EuqJvbhyQpxyfggv0E0bEdlA6kg9fC8C03DEZDIa4=; b=QZuIL563r2q+U0SPeKB7R2gGLgxlGxj/ejCUo29s8IkjxPg6BdV/Izom57pomhSDw1 KUfiZWgUqhF3GJt/FYymRlLVa2amTrI3fWCmvh+CZAFe4CnZbid833vkIjNUMkNldDGi IhTczoCuVSc/8gyDQc3D3wL+s4aCULPFVJNiw12m8UHO3axcR4mfxBmfxMmQJONRyzVr r3GaKDQmvxfvP6gWVkjvcHXl+zUM9YVf2JPSuVA5sKY3KRf/fYzTHyCOZPlj1Tq7ZVV3 q6rrlJod1Lbr+JoNZWclDop0n8A1J9hrRu74eRqAyqisqhJDJjucG4b1jESbd8jhNwVI VeNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wVVvjktf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=YL33ux51; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020aa7d4c8000000b004acbe7b3479si12051057edr.653.2023.02.15.02.40.06; Wed, 15 Feb 2023 02:40:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wVVvjktf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=YL33ux51; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233903AbjBOKdK (ORCPT + 99 others); Wed, 15 Feb 2023 05:33:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233709AbjBOKdJ (ORCPT ); Wed, 15 Feb 2023 05:33:09 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE9E40F2; Wed, 15 Feb 2023 02:33:06 -0800 (PST) Date: Wed, 15 Feb 2023 10:33:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1676457183; 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=f+EuqJvbhyQpxyfggv0E0bEdlA6kg9fC8C03DEZDIa4=; b=wVVvjktf/TCDpvKOfCNsImh/AjGHL4abGkMwlz9k6mwWyOMuuNRDJqCt3sFlklMtlXd0iY r5z0wGrFTUg8oiOTXVKvbnNzEk/xCqqAH6Uo5i2y47froFQEDIKxKT3owwVoQ2MkkpyBbU enOB0bNDEfJCmCdpYTRZMsqEZ/t2OScn0+noR2TW8c7i0aIaNhjPdC9B36OlHXeVyrjSoT 6vUZLZvQGAB+g4el3BmWs4mNecC9c1VpsOck+ZlN/Ca6r1BU18Hf6nBB8g5JoItWB7tBwG uF64TlypGDm8D1tLTJ2FZksGxb23PZUXRb1dYxaqlhjsc4KL1VDjNdmGKxmBvw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1676457183; 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=f+EuqJvbhyQpxyfggv0E0bEdlA6kg9fC8C03DEZDIa4=; b=YL33ux51roOUiyXbqYoBxSyzMykqhJTZiLB3ylPoKMjeLs+V1drE/19Bk3f16ghtAL/2p2 9F9AAajdYdtxVIAA== From: "tip-bot2 for Waiman Long" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/core: Fix a missed update of user_cpus_ptr Cc: Waiman Long , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230203181849.221943-1-longman@redhat.com> References: <20230203181849.221943-1-longman@redhat.com> MIME-Version: 1.0 Message-ID: <167645718309.4906.12679309805756202231.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756835123759244101?= X-GMAIL-MSGID: =?utf-8?q?1757893235782842203?= The following commit has been merged into the sched/urgent branch of tip: Commit-ID: df14b7f9efcda35e59bb6f50351aac25c50f6e24 Gitweb: https://git.kernel.org/tip/df14b7f9efcda35e59bb6f50351aac25c50f6e24 Author: Waiman Long AuthorDate: Fri, 03 Feb 2023 13:18:49 -05:00 Committer: Peter Zijlstra CommitterDate: Mon, 13 Feb 2023 16:36:14 +01:00 sched/core: Fix a missed update of user_cpus_ptr Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask"), a successful call to sched_setaffinity() should always save the user requested cpu affinity mask in a task's user_cpus_ptr. However, when the given cpu mask is the same as the current one, user_cpus_ptr is not updated. Fix this by saving the user mask in this case too. Fixes: 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask") Signed-off-by: Waiman Long Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230203181849.221943-1-longman@redhat.com --- kernel/sched/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e838feb..2a4918a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p, } if (!(ctx->flags & SCA_MIGRATE_ENABLE)) { - if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) + if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) { + if (ctx->flags & SCA_USER) + swap(p->user_cpus_ptr, ctx->user_mask); goto out; + } if (WARN_ON_ONCE(p == current && is_migration_disabled(p) &&