Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp693615imm; Sat, 26 May 2018 08:49:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxALKgfsHJlvV+3zBCgk9oCCKvs3/NUhoUImKHA/RT7jhwD4b29IjTtJTYsJAUbDQzcX5J X-Received: by 2002:a65:6007:: with SMTP id m7-v6mr1585118pgu.92.1527349742683; Sat, 26 May 2018 08:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527349742; cv=none; d=google.com; s=arc-20160816; b=tZL9+0bxLo44uCWMqCxEzXVb/voCECCvgK43Uv29l9eU7PbhNJ2qbAjfVBu1KhwwwH Th6AdiZQgpT5nYlHjky+wNemwgGg4dMa0XbvtDkgxSr90YuB07hbAgUNAGL7kiRLsZE1 7qIVEucdhu8f7/vNBbJ9XyvJvrsQn7TkNRN+yGgZYUq/zc+OpCxrvs49qJrAZQj+2+2S msvj0T3G1cWdQaGNckLQwELGldpQZXdoUruOBUHxUoicFY1XMnYU2dlGvpKpePygu9KW lmIiMlfWZUlZS/8+Bps/VJGuJJgWzGj2uXBqL0jGnPr1PKGNBaxNIoUQZJAWMQqNQIFJ b3ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=fMUVTb5vPvrZZqlGM/BKGIj9/GKqy+Wkp1h+b9cM00M=; b=GiLRoniFt2EQfRLTvdFl/FNuZ4/IYJGldNd6izx2WfZPnUha6zzo8G6S9b7/6jnoDZ shvJOs/QYxi13akbVo+w9IwLZUYRbkkGhZG9pcY+7QUZzvqgS+8zQjvS9nONSHGami9o XCKkNYt7XcsXmtmd+daNhWKy9cLS48NBKHyez0r0K2oZ3qWvQ8dZ9eTmaKlW+8q4CjLk 7LuF4MzhvSfd6DvaBJMFBepAaRlVR9u0h1ztmJ4RIpSGPSnCbRbhdAQUFj6mpn2MyQgK V0pT7FwhfUKWDpjclIvgjHfHY+WxrO6+5lRRULmmgz41TVLj0aLGu2CQ6YJEhDR6fiKG 7DYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az8-v6si26207596plb.347.2018.05.26.08.48.48; Sat, 26 May 2018 08:49:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032118AbeEZPsI (ORCPT + 99 others); Sat, 26 May 2018 11:48:08 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.154.211]:41983 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031908AbeEZPsH (ORCPT ); Sat, 26 May 2018 11:48:07 -0400 Received: from mipsdag01.mipstec.com (mail1.mips.com [12.201.5.31]) by mx1403.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=NO); Sat, 26 May 2018 15:47:48 +0000 Received: from mipsdag02.mipstec.com (10.20.40.47) by mipsdag01.mipstec.com (10.20.40.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Sat, 26 May 2018 08:46:59 -0700 Received: from pburton-laptop.ba.imgtec.org (10.20.78.205) by mipsdag02.mipstec.com (10.20.40.47) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sat, 26 May 2018 08:46:59 -0700 From: Paul Burton To: CC: Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Paul Burton Subject: [PATCH 2/2] sched: Warn if we fail to migrate a task Date: Sat, 26 May 2018 08:46:48 -0700 Message-ID: <20180526154648.11635-3-paul.burton@mips.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180526154648.11635-1-paul.burton@mips.com> References: <20180526154648.11635-1-paul.burton@mips.com> MIME-Version: 1.0 Content-Type: text/plain X-BESS-ID: 1527349614-321459-6793-23952-3 X-BESS-VER: 2018.6-r1805181819 X-BESS-Apparent-Source-IP: 12.201.5.31 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.193394 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __set_cpus_allowed_ptr() makes use of stop_one_cpu() to call migration_cpu_stop() in order to perform migration of a task away from the CPU it's currently running on. If all is as expected then this shouldn't fail, but as the preceding patch shows it's possible for this assumption to be broken fairly subtly. Add a warning to ensure that if stop_one_cpu() returns an error (-ENOENT is the only one it can currently return) then we warn about it in the kernel log, since this isn't expected to happen. I considered propogating the error upwards, but this would require a change to the return values allowed from the sched_setaffinity() syscall and would require that user programs handle errors other than those caused by their own bad input to the syscall. So for now this patch simply warns, which is an improvement over the silent error & incorrect scheduling we had before. Signed-off-by: Paul Burton Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org --- kernel/sched/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2380bc228dd0..cda3affd45b7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1127,7 +1127,8 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, struct migration_arg arg = { p, dest_cpu }; /* Need help from migration thread: drop lock and wait. */ task_rq_unlock(rq, p, &rf); - stop_one_cpu(cpu_of(rq), migration_cpu_stop, &arg); + ret = stop_one_cpu(cpu_of(rq), migration_cpu_stop, &arg); + WARN_ON(ret); tlb_migrate_finish(p->mm); return 0; } else if (task_on_rq_queued(p)) { -- 2.17.0