Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 19 Jul 2015 00:38:44 +0200 (CEST) Received: from static.88-198-24-112.clients.your-server.de ([88.198.24.112]:39552 "EHLO nbd.name" rhost-flags-OK-OK-OK-FAIL) by eddie.linux-mips.org with ESMTP id S27009935AbbGRWimtOHYH (ORCPT ); Sun, 19 Jul 2015 00:38:42 +0200 Received: by nf-2.local (Postfix, from userid 501) id 82DAAF1F93B7; Sun, 19 Jul 2015 00:38:41 +0200 (CEST) From: Felix Fietkau To: linux-mips@linux-mips.org Cc: ralf@linux-mips.org Subject: [PATCH] MIPS: kernel: fix sched_getaffinity with MT FPAFF enabled Date: Sun, 19 Jul 2015 00:38:41 +0200 Message-Id: <1437259121-81263-1-git-send-email-nbd@openwrt.org> X-Mailer: git-send-email 2.2.2 Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 48344 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: nbd@openwrt.org Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips p->thread.user_cpus_allowed is zero-initialized and is only filled on the first sched_setaffinity call. To avoid adding overhead in the task initialization codepath, simply OR the returned mask in sched_getaffinity with p->cpus_allowed. Cc: stable@vger.kernel.org Signed-off-by: Felix Fietkau --- arch/mips/kernel/mips-mt-fpaff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/mips-mt-fpaff.c b/arch/mips/kernel/mips-mt-fpaff.c index 3e4491a..789d7bf 100644 --- a/arch/mips/kernel/mips-mt-fpaff.c +++ b/arch/mips/kernel/mips-mt-fpaff.c @@ -154,7 +154,7 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long __user *user_mask_ptr) { unsigned int real_len; - cpumask_t mask; + cpumask_t allowed, mask; int retval; struct task_struct *p; @@ -173,7 +173,8 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, if (retval) goto out_unlock; - cpumask_and(&mask, &p->thread.user_cpus_allowed, cpu_possible_mask); + cpumask_or(&allowed, &p->thread.user_cpus_allowed, &p->cpus_allowed); + cpumask_and(&mask, &allowed, cpu_active_mask); out_unlock: read_unlock(&tasklist_lock); -- 2.2.2