Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp714780imu; Fri, 9 Nov 2018 05:03:24 -0800 (PST) X-Google-Smtp-Source: AJdET5e6Y9HDg4qdhZXQQXMJqIOAvJ+f90Q6cTpwu6wDVlantKIrMQoXKg6l9jskQxqi0ePstcoc X-Received: by 2002:a62:be18:: with SMTP id l24-v6mr8659185pff.51.1541768604453; Fri, 09 Nov 2018 05:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541768604; cv=none; d=google.com; s=arc-20160816; b=QpmcoFX5VVgd0e1TmaiRjM+D/RC8N+8G54qSWSrG0lrNfKLLdC1tQhZ6fJ+fgTA6uU XqqdcXBnGzQTZ9wpV+jm3aeb9347JTkKwYlDEQ28hCUrgelNygkU+nhJhUWli59GbxBe w8we+SxOUtLdUVF/wzfUpptmJvyzr1mP1y5fAY2OA36x0BCkUzKHGYAJr1ROomHHJ+3/ 2u1XcR1IN4bzx1x0jUQP/NTi2+GJHuHiFa2zhGmpTqS3c7urlL2OIuwwGuhFBQ7IDfAw MUWotgXGEqDoY25cJ0ouJ7yNOojV5eEHGX9gyuPrGR3CXwvPvGTvhP9Zgrl7iP6ahroP AdUQ== 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=JGeudfDQgoHcScKvHR6v0sxtIhwxlNusrsl0oBZQDrg=; b=gFoM0EwhjltKFA6IdvW8s3jKGvPpwnN4FDt4zwtRvcq6A2PPoyaCM0gICC6P9FQ1FR qJFGJAyjHMta4TFgdJldatijXoHVD9nyksbp3svC2PTskBFPHPOppwuha9RmsZd5oBAk MFr9lMSkPHWcb8fzoY7oFjCdW7I1n3UmPxVeF4nHW5Q2w1CyVkT8hbkHXELJOdx4ZApw SAKkFzHxQxBY/YZ7N+zVDczVYnvObtYUrfp87kb20iZunbwkQ8/PQ0heCpY62g8dQ0qp humC6vG8frLNg2pCtiDnIlTtqoUPMoEm91HVC0gLDwXJYntCXwmb1FUTJlJpRmbJSPte 9mzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=as5kQsnW; 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 a34si6473843pgm.427.2018.11.09.05.02.54; Fri, 09 Nov 2018 05:03:24 -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=as5kQsnW; 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 S1728048AbeKIWlI (ORCPT + 99 others); Fri, 9 Nov 2018 17:41:08 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:54488 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbeKIWlI (ORCPT ); Fri, 9 Nov 2018 17:41:08 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA9Cwu80122076; Fri, 9 Nov 2018 13:00:18 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=JGeudfDQgoHcScKvHR6v0sxtIhwxlNusrsl0oBZQDrg=; b=as5kQsnW92nIkbFJxDQUVXzY5WHvo+0HdSI3JbxNjAD0H8TmrXGUlQglYRKdD4auM/Qo BymCAYkhbb/muZ3rS5rzZZ3A9qfFMKbtDO35LxIOQg7Am98Y92b38On0pFxS6g6h/aG4 yZL6gW47VTCkRKfF+e8EXJie8tOF7L3Ab5FGU01IG0Sw+0SiV25wA+dZjoGBEiq/AS/g G5eU7aVmXhIGY3mPPRwWHz6a4sbV8P54JOuDYcUty9L5iMKoQYM9f5xI5FUgG9+iU85U 0MqJkWgTQlkDcBBjE6kc1sPW73fNG0LJZ63yjpB8tk4Bo0mKvr7gJ8E8WG4mMv8rQA40 bA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2nh3mq6x4h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Nov 2018 13:00:18 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA9D0CH6006403 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Nov 2018 13:00:13 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA9D0BMl021756; Fri, 9 Nov 2018 13:00:11 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Nov 2018 05:00:11 -0800 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 v3 07/10] sched/fair: Provide can_migrate_task_llc Date: Fri, 9 Nov 2018 04:50:37 -0800 Message-Id: <1541767840-93588-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541767840-93588-1-git-send-email-steven.sistare@oracle.com> References: <1541767840-93588-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9071 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=967 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811090121 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 453d280..dc6224d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7199,6 +7199,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