Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11223358imu; Thu, 6 Dec 2018 13:39:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/UDoj4oUHUjfj2JbQFFiDrne12JDX+EtY/pIJmst+YPO8zeA0uiSPTxoFRVeUYUrLEDoq3y X-Received: by 2002:a63:e950:: with SMTP id q16mr25458001pgj.138.1544132399281; Thu, 06 Dec 2018 13:39:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544132399; cv=none; d=google.com; s=arc-20160816; b=aA6cw1T0+f3wWFDzrSpnb9Ql//ilYbLj+4gxsJahFC9kL4GU0B+MqwsGF5E9nrdzXF 8x3/xTXCFK2uzyoKEHL+w1uil0uu8FfQTLYTbZN64nMLyok3ql4kce6hKz8GViyfVow2 Ty80jli7oJeunzSBnnN2Vp3jybc5weaf7GGGXR++lqHjsnWxHcs91HP+XOYNKOxx/OnO lRKVYwOuV9GxH7xgzVEAqZ2Eqm1wYsjpnXdgn0cdVuSsPqyY8w4bwwLKYHer+ZgOEXqI Ebtj7US2cWmNs6TPKjt6kycZ98aPnMqrk0i547ttUdNSt8KdzCDS5PY/Mf8N2fCfM7Ff BMbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=yqZBtTRoXwILOEt1ZFfSigJQGM5yxS0rVjeLXGYyMkw=; b=UTSfp6/TDSsXTr8WQn16aihG3brsdrL63+IxFlhwZziARTeabLygG/t2PB8sVmhVSH h3HKdVAkbc4dlLAlhKWkVXMu1H8Zzo/cjfHJuGi1A3B4X29ysB8wC1pY1SMJLRIIXLs+ hgVvWOwyYTILvD8YwU3e3hZVMKgmBMh7Njk/m7wroPbIV+FFT063SuD04n1GaLZ93kHh U0ZJHgIcHhp676WLcpgiwQICXXz6qgn10tvnDpKbEasMh/lSvx8jSFuKrSGPTJWQuvXL /gVfPLxTLNxeMIt0qo44XIPWFf3ahTr1oJWQPSEaRT40KG07bFz/gmmmVb5kEklaPE1B Girg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=c0UunkNy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11si1260333plm.8.2018.12.06.13.39.44; Thu, 06 Dec 2018 13:39:59 -0800 (PST) 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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=c0UunkNy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbeLFVi5 (ORCPT + 99 others); Thu, 6 Dec 2018 16:38:57 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:36086 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbeLFViy (ORCPT ); Thu, 6 Dec 2018 16:38:54 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB6LYMuY154629; Thu, 6 Dec 2018 21:38:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=yqZBtTRoXwILOEt1ZFfSigJQGM5yxS0rVjeLXGYyMkw=; b=c0UunkNybG6brUD5gYI9qdVs+bdUGns4vbTzMiMFN3Axr68+AByP6lc6MpSHZISXuKLr 2KqAsww6pJFFQlj2L8OD0hUVbbPdiH3JPqgmWxZ9/cCiF+p+SjPyskTmp9ycnq+Kq77F 2Dtk92xEYvoOYi5Six7CQS47eMQVgkcehiXaQWKdWg6jnbKIrLVKZ8TIBa2Q1TpApTe4 /gpxUHX0iWFAT44k9mPuLaW0CkA5pRUgoNtmb4ewulSWsOawrRkPppms87ZJV4vjyc2P OAl30TAsf4IVLY/lxGLxVjnhEelEyO3OJNKlxaOyYMURjKq/8JfuwaiV4oju+tK5EijV 3A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2p3jxrtme6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 06 Dec 2018 21:38:26 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB6LcKPd015491 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Dec 2018 21:38:20 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wB6LcKwq021709; Thu, 6 Dec 2018 21:38:20 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 06 Dec 2018 21:38:20 +0000 From: Steve Sistare To: mingo@redhat.com, peterz@infradead.org Cc: subhra.mazumdar@oracle.com, dhaval.giani@oracle.com, daniel.m.jordan@oracle.com, pavel.tatashin@microsoft.com, matt@codeblueprint.co.uk, umgwanakikbuti@gmail.com, riel@redhat.com, jbacik@fb.com, juri.lelli@redhat.com, valentin.schneider@arm.com, vincent.guittot@linaro.org, quentin.perret@arm.com, steven.sistare@oracle.com, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/10] sched/fair: Provide can_migrate_task_llc Date: Thu, 6 Dec 2018 13:28:13 -0800 Message-Id: <1544131696-2888-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544131696-2888-1-git-send-email-steven.sistare@oracle.com> References: <1544131696-2888-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9099 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=996 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812060181 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Define a simpler version of can_migrate_task called can_migrate_task_llc which does not require a struct lb_env argument, and judges whether a migration from one CPU to another within the same LLC should be allowed. Signed-off-by: Steve Sistare --- kernel/sched/fair.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9b7c85b..3804156 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7207,6 +7207,34 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env) } /* + * Return true if task @p can migrate from @rq to @dst_rq in the same LLC. + * No need to test for co-locality, and no need to test task_hot(), as sharing + * LLC provides cache warmth at that level. + */ +static bool +can_migrate_task_llc(struct task_struct *p, struct rq *rq, struct rq *dst_rq) +{ + int dst_cpu = dst_rq->cpu; + + lockdep_assert_held(&rq->lock); + + if (throttled_lb_pair(task_group(p), cpu_of(rq), dst_cpu)) + return false; + + if (!cpumask_test_cpu(dst_cpu, &p->cpus_allowed)) { + schedstat_inc(p->se.statistics.nr_failed_migrations_affine); + return false; + } + + if (task_running(rq, p)) { + schedstat_inc(p->se.statistics.nr_failed_migrations_running); + return false; + } + + return true; +} + +/* * detach_task() -- detach the task for the migration from @src_rq to @dst_cpu. */ static void detach_task(struct task_struct *p, struct rq *src_rq, int dst_cpu) -- 1.8.3.1