From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261978AbUK3Ejb (ORCPT ); Mon, 29 Nov 2004 23:39:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261979AbUK3Ejb (ORCPT ); Mon, 29 Nov 2004 23:39:31 -0500 Received: from ozlabs.org ([203.10.76.45]:57317 "EHLO ozlabs.org") by vger.kernel.org with ESMTP id S261978AbUK3Ej1 (ORCPT ); Mon, 29 Nov 2004 23:39:27 -0500 Subject: [PATCH] sys_sched_setaffinity() on UP should fail for non-zero CPUs. From: Rusty Russell To: lkml - Kernel Mailing List Cc: Andrew Morton Content-Type: text/plain Date: Tue, 30 Nov 2004 15:39:24 +1100 Message-Id: <1101789564.14565.23.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Name: Return EINVAL for invalid sched_setaffinity on UP Status: Tested on 2.6.10-rc2-bk13 Signed-off-by: Rusty Russell I was a little surprised that sys_sched_setaffinity for CPU 1 didn't fail on my UP box. With CONFIG_SMP it would have. Index: linux-2.6.10-rc2-bk13-Misc/include/linux/sched.h =================================================================== --- linux-2.6.10-rc2-bk13-Misc.orig/include/linux/sched.h 2004-11-16 15:30:07.000000000 +1100 +++ linux-2.6.10-rc2-bk13-Misc/include/linux/sched.h 2004-11-30 14:09:38.000000000 +1100 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -708,6 +709,8 @@ #else static inline int set_cpus_allowed(task_t *p, cpumask_t new_mask) { + if (!cpus_intersects(new_mask, cpu_online_map)) + return -EINVAL; return 0; } #endif -- A bad analogy is like a leaky screwdriver -- Richard Braakman