From patchwork Fri Oct 28 06:42:09 2022 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: 12114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp659295wru; Thu, 27 Oct 2022 23:45:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4vnOtVXxfwYh92wVrx8b3oLLe1OMYXQRgM1V8aGsZQHawbJc0JaUhyoN8/2uqxUgfdu6DS X-Received: by 2002:a17:902:a606:b0:178:57e4:a0c1 with SMTP id u6-20020a170902a60600b0017857e4a0c1mr52981529plq.83.1666939522061; Thu, 27 Oct 2022 23:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666939522; cv=none; d=google.com; s=arc-20160816; b=okltslcwvClpP3SbFzai48xEJiXbiLLm9Y4Y6b9rTHUxjdA+TdzUwdFjhbO0FsGccN xXQ8afLEz32MWyNXXIPG1Hae3UtBlHXF2UWdOma9y5JOHoXq1YldLZS12RaD63ZOBai/ 3JBBpqB7185SulcsxDBW8OKAso31Zfe5VgxuT1R0aC7pBtePv+kln4mNaDj++3sF2bae HJzwBLgvL8+8qbqt75OzczJ82dqaOvKFegiA7uSJiqNdJMrRbfmxbP9x22zcZF2hJ7S/ fbOXvYGL1Nnmm3a8KeCLh+m3BFchkZcaBP5xyHUf8N5Sb10Rx8iIh0gKR/NkqIza8UE9 MFzw== 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=oVGJkT4iKEULGX5K8Wk145BS8aZjYc/x4p+MSpuBY2E=; b=QQhGraIPTVZSq855QP9ZfM+U/im93ZMa9zCw64gxTTY1TDTaA5YjESfoWa2fpFQvdU yTQdQCKm1LjAg+/kYw8e2kelJV3MUeYMEc1LJi+zE1HWEJ30u1tZ3eNPJeiVtXlOmwVS nA0zwdtE0/YsU0OQQQHW09KQxx6P/SyJjIJr2IYgDOAwuVGOXqgVWBLasxFqa2YeFFwG 0Mi1QQ31d3ha7Yu7XZbsVu1tlU3Gtkh2xQwkbmIab9668FtTrI/Fgn+wbp97TtMNVt1X IFpoFmKEjvuQYPEnxqWNH2q1bkc6qJ682qqdNH4IjlBVt4/yLZHMIlyMpH8SZ76boveG j2rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=k4bPGUAd; dkim=neutral (no key) header.i=@linutronix.de; 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 cj25-20020a056a00299900b005639db953adsi4256259pfb.68.2022.10.27.23.45.08; Thu, 27 Oct 2022 23:45:22 -0700 (PDT) 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=k4bPGUAd; dkim=neutral (no key) header.i=@linutronix.de; 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 S230026AbiJ1GnU (ORCPT + 99 others); Fri, 28 Oct 2022 02:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiJ1GmO (ORCPT ); Fri, 28 Oct 2022 02:42:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9815615A97C; Thu, 27 Oct 2022 23:42:12 -0700 (PDT) Date: Fri, 28 Oct 2022 06:42:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666939331; 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=oVGJkT4iKEULGX5K8Wk145BS8aZjYc/x4p+MSpuBY2E=; b=k4bPGUAdiWGbCjgvPGrSSVm7XQGETT9gUXBkmgLlvHWso94PEsLyZzAsDh2BiUtDe9CeG/ njvVK+BMENjAKP+XB2luBkhpEJPw1OLB9vlEwgZiKOvaIBcMpy4RCdW9YR5FDvV3Ay35Fh YRTaG26gETjkyh55q2VaxwEWIBYeBHfISRcowwQWZNx6XqAeeg5+YE7TIvP10BNM7bv7t7 TanOkWHgUJbVHnUc15/fxBAgBq5ogsZ9etnyZ6YXQiq6EsPp2lehuJHYyQ7aDZfpHOT4FW szwA3S356yhqwnSBHRvVu0xy3hRCAAt6pAKz+DrJRiuucM0E606t67ak29KYjw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666939331; 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=oVGJkT4iKEULGX5K8Wk145BS8aZjYc/x4p+MSpuBY2E=; b=2h0VVEM/KgEDWN+z4J8xFQ2M8MRqCBdJQ7a2nH7NSugogvmHz3cvn0R9sYg38/te5c+2DR OCtK2RRCgZ+p36AQ== 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/core] sched: Always clear user_cpus_ptr in do_set_cpus_allowed() Cc: Peter Zijlstra , Waiman Long , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220922180041.1768141-6-longman@redhat.com> References: <20220922180041.1768141-6-longman@redhat.com> MIME-Version: 1.0 Message-ID: <166693932997.29415.5377039389023064362.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?1747912776699796422?= X-GMAIL-MSGID: =?utf-8?q?1747912776699796422?= The following commit has been merged into the sched/core branch of tip: Commit-ID: 851a723e45d1c4c8f6f7b0d2cfbc5f53690bb4e9 Gitweb: https://git.kernel.org/tip/851a723e45d1c4c8f6f7b0d2cfbc5f53690bb4e9 Author: Waiman Long AuthorDate: Thu, 22 Sep 2022 14:00:41 -04:00 Committer: Peter Zijlstra CommitterDate: Thu, 27 Oct 2022 11:01:22 +02:00 sched: Always clear user_cpus_ptr in do_set_cpus_allowed() The do_set_cpus_allowed() function is used by either kthread_bind() or select_fallback_rq(). In both cases the user affinity (if any) should be destroyed too. Suggested-by: Peter Zijlstra Signed-off-by: Waiman Long Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220922180041.1768141-6-longman@redhat.com --- kernel/sched/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 283bdbd..87c9cdf 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2593,14 +2593,20 @@ __do_set_cpus_allowed(struct task_struct *p, struct affinity_context *ctx) set_next_task(rq, p); } +/* + * Used for kthread_bind() and select_fallback_rq(), in both cases the user + * affinity (if any) should be destroyed too. + */ void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask) { struct affinity_context ac = { .new_mask = new_mask, - .flags = 0, + .user_mask = NULL, + .flags = SCA_USER, /* clear the user requested mask */ }; __do_set_cpus_allowed(p, &ac); + kfree(ac.user_mask); } int dup_user_cpus_ptr(struct task_struct *dst, struct task_struct *src,