Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7763BC636CC for ; Mon, 13 Feb 2023 14:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjBMO5h (ORCPT ); Mon, 13 Feb 2023 09:57:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbjBMO5f (ORCPT ); Mon, 13 Feb 2023 09:57:35 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA1A1DBB3 for ; Mon, 13 Feb 2023 06:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=tS3mHsBN2NLtArYoIbCiPJ9tTTfl7+rSUB/A4Ag/Xsk=; b=TtgvJa/PVbyB6rspkal84TtGNg JqOO8BBnM8FYMVbE7h+AlifZ182qcK9LMOKa6FhUGGJqwubUVSFkFdBEXYg/H8O7OMvGqC2NGiMNc WbKN9PdhypvmHoJv+OR2d4SBrT738W1iZ59r59MUMTU7X6VK+zrN++boCkBfjWVuDmIOlE8SiT3F+ XTx4ujvmI2b2yXgKjS3NKNvj9D79v1iNN3Md73jiDJUVyeqfSmm7MdsUvSVhy5U432fhJ4BkfeYYI RaQVjE6/1SGqdmfT9xi/EfS6J9rbnrkFuZ+KHaW+GuyTHk1d/ep17/L1iIlLAhDtKMrjmpGTgFhHM MY+Eba6A==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRaFu-005rM3-G7; Mon, 13 Feb 2023 14:56:35 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A4DF3300033; Mon, 13 Feb 2023 15:56:32 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 817E8202682CD; Mon, 13 Feb 2023 15:56:32 +0100 (CET) Date: Mon, 13 Feb 2023 15:56:32 +0100 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Will Deacon , Phil Auld , Tejun Heo , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/core: Fix a missed update of user_cpus_ptr Message-ID: References: <20230203181849.221943-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230203181849.221943-1-longman@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2023 at 01:18:49PM -0500, Waiman Long wrote: > 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 > --- > 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 30d9752e2ca5..91255f791df3 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) && Indeed. Thanks!