Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp712267imu; Fri, 9 Nov 2018 05:01:32 -0800 (PST) X-Google-Smtp-Source: AJdET5cusuiAWWku59+t1J1xguCX2Y+U9JXP1VN0iimdU+45Ry8hCE/Snnn61t7TK3zR+DoPJCVs X-Received: by 2002:a62:c6c8:: with SMTP id x69-v6mr8995244pfk.37.1541768492646; Fri, 09 Nov 2018 05:01:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541768492; cv=none; d=google.com; s=arc-20160816; b=Bmbwavy7K8xEkDQVd+ri+yJeyRwhSXapIrwmQY89T+lY7sZQPKQPknQ5CT42SkuZRT xz9tZ7YQnbRSMjYO7C63dgoPS8b/UMnhkoU90o4TOKpDHNZ9dNLhDrN7dUbPcAb7s+FT a6F+1++cW3tGfsdcDBhuIzeY3ugD+BVw71fvRDftRTtVyDU1X13PU23DKtiLRToCpP2x 4DAVYe3P5f6EHxuZ7uEmtqcKSxnFhX6yDWaXyOrJiVhVaX2XaWQS+Be6Yt0a2B/9MniQ Z/EXQcPkHz0PwzTrllU/d3wA9lxftlrmTq/gUmJL9zDRczSwm0b4pjTYsdX6fvLAnEr7 wvFw== 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=OV5A+ekApxd35Q74JtAq3YYXSB88lOepcaos7Ktm+5I=; b=Qle6aIXsnh67dhUqF6QsPUcgbYakk2a1y1CNTQyEHuyhIj4kUMtHSIh8NgHRrpKpMJ IKA4IAtfC6x/WoW65nNX6ioaFtEZ/FT3lq9xfQAWUK8WSWEMwuLbrBY8WkwmUKeYThoR rwIgwODuKa6VQKHxLhPRkuw/2/JsI7aKZdRkmeDOTrsgkzEAwi26RDIs2jmTdzF6MyKu ZtMy9HRx7APg2GCK/4RoSodIGYrylZcX4FumbHbGP0u8dauPIs9vxTTJgygZ87x4M64s fyGLfzfjPBhnkpU65cIT0sDzk/SOe1ayfpb+R8x4QRl9ShbCZc498SMPyzXKS7O+SXjn Vwzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=wXBDysBj; 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 d32-v6si8068240pla.405.2018.11.09.05.01.13; Fri, 09 Nov 2018 05:01:32 -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=wXBDysBj; 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 S1728006AbeKIWlF (ORCPT + 99 others); Fri, 9 Nov 2018 17:41:05 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:42446 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727676AbeKIWlF (ORCPT ); Fri, 9 Nov 2018 17:41:05 -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 wA9Cwvnf068521; Fri, 9 Nov 2018 13:00:09 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=OV5A+ekApxd35Q74JtAq3YYXSB88lOepcaos7Ktm+5I=; b=wXBDysBjUuI5IkKJc6Pvrxf45mwbrPWgrCuP0kpUsYjnztO60hJTNrOGLzBQ1FGF5arf S3O7WQjjUxuA8BBwJ9dK31gnPBN/lhfCOExzdl7DMENaEMUPcZWdo7QVMaxmaeWXwBBi OT2LoiN+55GjgfzJ2Ntk6suWVRS0G5NHVChCxiq7CUIMrNkxEGAJ2N97EMQp9dPHdR4/ AGxXdUa6rNwFyPCphXvtCVG/kaF1XwIk4SWVHHlSaYlFv9RnkO/vN1wDBa9E2ffGkFNt Y4m1W2n/KLZrM4mD4wIMZ67Cr5r9BHiNw+oQkZyso+KNspRB9lzgTvDwLrxWKn07Imj8 Qw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2nh4ar6tuu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Nov 2018 13:00:09 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA9D09jB004325 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Nov 2018 13:00:09 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA9D08Z5031094; Fri, 9 Nov 2018 13:00:08 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:08 -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 03/10] sched/topology: Provide cfs_overload_cpus bitmap Date: Fri, 9 Nov 2018 04:50:33 -0800 Message-Id: <1541767840-93588-4-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=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 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 From: Steve Sistare Define and initialize a sparse bitmap of overloaded CPUs, per last-level-cache scheduling domain, for use by the CFS scheduling class. Save a pointer to cfs_overload_cpus in the rq for efficient access. Signed-off-by: Steve Sistare --- include/linux/sched/topology.h | 1 + kernel/sched/sched.h | 2 ++ kernel/sched/topology.c | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 6b99761..b173a77 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -72,6 +72,7 @@ struct sched_domain_shared { atomic_t ref; atomic_t nr_busy_cpus; int has_idle_cores; + struct sparsemask *cfs_overload_cpus; }; struct sched_domain { diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 618577f..eacf5db 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -81,6 +81,7 @@ struct rq; struct cpuidle_state; +struct sparsemask; /* task_struct::on_rq states: */ #define TASK_ON_RQ_QUEUED 1 @@ -812,6 +813,7 @@ struct rq { struct cfs_rq cfs; struct rt_rq rt; struct dl_rq dl; + struct sparsemask *cfs_overload_cpus; #ifdef CONFIG_FAIR_GROUP_SCHED /* list of leaf cfs_rq on this CPU: */ diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 3e72ce0..6455bde 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -3,6 +3,7 @@ * Scheduler topology setup/handling methods */ #include "sched.h" +#include DEFINE_MUTEX(sched_domains_mutex); @@ -441,6 +442,7 @@ static void update_top_cache_domain(int cpu) static void cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu) { + struct sparsemask *cfs_overload_cpus; struct rq *rq = cpu_rq(cpu); struct sched_domain *tmp; @@ -482,6 +484,10 @@ static void update_top_cache_domain(int cpu) dirty_sched_domain_sysctl(cpu); destroy_sched_domains(tmp); + sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES); + cfs_overload_cpus = (sd ? sd->shared->cfs_overload_cpus : NULL); + rcu_assign_pointer(rq->cfs_overload_cpus, cfs_overload_cpus); + update_top_cache_domain(cpu); } @@ -1619,9 +1625,19 @@ static void __sdt_free(const struct cpumask *cpu_map) } } +#define ZALLOC_MASK(maskp, nelems, node) \ + (!*(maskp) && !zalloc_sparsemask_node(maskp, nelems, \ + SPARSEMASK_DENSITY_DEFAULT, \ + GFP_KERNEL, node)) \ + static int sd_llc_alloc(struct sched_domain *sd) { - /* Allocate sd->shared data here. Empty for now. */ + struct sched_domain_shared *sds = sd->shared; + struct cpumask *span = sched_domain_span(sd); + int nid = cpu_to_node(cpumask_first(span)); + + if (ZALLOC_MASK(&sds->cfs_overload_cpus, nr_cpu_ids, nid)) + return 1; return 0; } @@ -1633,7 +1649,8 @@ static void sd_llc_free(struct sched_domain *sd) if (!sds) return; - /* Free data here. Empty for now. */ + free_sparsemask(sds->cfs_overload_cpus); + sds->cfs_overload_cpus = NULL; } static int sd_llc_alloc_all(const struct cpumask *cpu_map, struct s_data *d) -- 1.8.3.1