From patchwork Fri Jun 23 10:54:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9806251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D5DF760329 for ; Fri, 23 Jun 2017 10:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7207285EE for ; Fri, 23 Jun 2017 10:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC00928616; Fri, 23 Jun 2017 10:57:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3654B285EE for ; Fri, 23 Jun 2017 10:57:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dOMEr-0006C2-KA; Fri, 23 Jun 2017 10:54:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dOMEq-0006BX-EH for xen-devel@lists.xenproject.org; Fri, 23 Jun 2017 10:54:56 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id AD/88-19466-F73FC495; Fri, 23 Jun 2017 10:54:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleJIrShJLcpLzFFi42K5GHrdWbf+s0+ kwY/3bBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a36fPYCqYLVmx8cY+tgfEabxcjF4eQwAxG iUtb3zKDOCwCa1glGqY9ZOli5OSQELjEKjHvqiuEHScxd9p1pi5GDiC7UuLtEhmQsJCAisTN7 auYIAZ9Y5R4N3kmI0hCWEBP4sjRH+wQdoDEthtLwWayCRhIvNmxlxXEFhFQkri3ajITiM0sEC ox590ZNhCbRUBVYsqmZrBeXgEHid1r94D1cgo4SUxYtZMJYrGjRMv/F8wgtqiAnMTKyy2sEPW CEidnPmEBuZNZQFNi/S59iPHyEtvfzmGewCgyC0nVLISqWUiqFjAyr2LUKE4tKkst0jU000sq ykzPKMlNzMzRNTQw1ctNLS5OTE/NSUwq1kvOz93ECAx+BiDYwXj+tOchRkkOJiVR3tgzPpFCf En5KZUZicUZ8UWlOanFhxg1ODgEJpydO51JiiUvPy9VSYL390egOsGi1PTUirTMHGB8wpRKcP AoifBu/wCU5i0uSMwtzkyHSJ1iNOa4cmXdFyaOKQe2f2ESApskJc6b8AmoVACkNKM0D24QLG1 cYpSVEuZlBDpTiKcgtSg3swRV/hWjOAejkjBvMcgUnsy8Erh9r4BOYQI6ZcYasFNKEhFSUg2M yieuh01T1X+kaiez9/7Hs8tPqn5neb2dQ//ckctRj1T+b+RZ7CFcpCVX5PluufJTkZTW1a3XE ptdDx31UD1zpvE2x9ynH85LsEg3RW7Yon3K45VjzUxbEYbufRN+XtjyPuavwIoP3S+k9WNtjl xdcqaX4dLerRKPXNcone500jooYXssgm8pqxJLcUaioRZzUXEiAF6jpfMWAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1498215294!84978841!1 X-Originating-IP: [209.85.215.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29900 invoked from network); 23 Jun 2017 10:54:55 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Jun 2017 10:54:55 -0000 Received: by mail-lf0-f67.google.com with SMTP id n136so5818917lfn.2 for ; Fri, 23 Jun 2017 03:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=BE/OvLIMhp6uWDKHFqyJEnLqbYIXlga+pNOrpj7ZSZY=; b=Q8UmvMhBTLms1Dn325PVtxe+uwMBTtTgtvbeay9sOGaAJAVaMYKnPc+9OgSiP4r5NW ZBregL4G2Az/QShhln1CpkV/ucJSsYpq8joMFnvbfulc2f1U89e2gkU/+hYNvzehSX0Y nraEVQHJL+JTNB0ZQ/gdA/VWCHYMOIU5yxJpnjnCwXTj4bY951W3VG3/nDtcoeRRt9WB YEjEGkGK8SfeJyL+jNh9lFc6E9lt7OH9pou0d4HevE4AZnx23iJQt5XOfoHz3URnpTOg VjSkV5OxslPvSOSgf7b6fo6CIwjXl/F8ojQgyLzK2pq8O4IZwy/ViV+Ox4ttHNX1ZL6w rRRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=BE/OvLIMhp6uWDKHFqyJEnLqbYIXlga+pNOrpj7ZSZY=; b=P1Btm2w2Mxf8nbww+T0cE7fyDLyhWQRq1Llm9MUVk7wxdgUmL4uUz/x05pQYRXYIO/ wntyUactBeEHTblZqo+4Snh0DE+6m9IR8JVjhBNaxrgQ9yS3sImKpAh/ZRXG5RevCcah +lPDRgfjMhlQbhzxBhf7MSGEW7RSp5S5vq9CxCfVXbqgAPFLFWcEGKo6mCMkoerK/CLk PA/BC6Yz49rUXfCagW5EAn7fVpdJyXHd45DmGYkKUqxOshaHf2pzoopnN1drrJGgq8fE LxwUklfs4z7Em51RHtKO8FM6YL3/vw62Q+h/okIraf6v28Z7xyJ3EGk8/GX+foUD70zb KXvg== X-Gm-Message-State: AKS2vOwFsbXYUIZGeRjjDvyPViWF+gGBhL6Q5emYdEAT1koKJqD5NPXE x0NDkoKE7oYCMEv0 X-Received: by 10.28.57.197 with SMTP id g188mr4899421wma.13.1498215293936; Fri, 23 Jun 2017 03:54:53 -0700 (PDT) Received: from [192.168.0.31] ([80.66.223.81]) by smtp.gmail.com with ESMTPSA id 199sm2030778wmu.0.2017.06.23.03.54.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2017 03:54:53 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 23 Jun 2017 12:54:52 +0200 Message-ID: <149821529221.5914.8902703747874745281.stgit@Solace> In-Reply-To: <149821475587.5914.12193327340105859241.stgit@Solace> References: <149821475587.5914.12193327340105859241.stgit@Solace> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH 1/6] xen: credit2: allocate runqueue data structure dynamically X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of keeping an NR_CPUS big array of csched2_runqueue_data elements, directly inside the csched2_private structure, allocate it dynamically. This has two positive effects: - reduces the size of csched2_private sensibly, which is especially good in case there are more instance of Credit2 (in different cpupools), and is also good from the point of view of fitting the struct into CPU caches; - we can use nr_cpu_ids as array size, which may be sensibly smaller than NR_CPUS Signed-off-by: Dario Faggioli Acked-by: George Dunlap --- Cc: George Dunlap Cc: Anshul Makkar --- xen/common/sched_credit2.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 126417c..10d9488 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -385,7 +385,7 @@ struct csched2_private { int runq_map[NR_CPUS]; cpumask_t active_queues; /* Queues which may have active cpus */ - struct csched2_runqueue_data rqd[NR_CPUS]; + struct csched2_runqueue_data *rqd; unsigned int load_precision_shift; unsigned int load_window_shift; @@ -3099,9 +3099,11 @@ csched2_init(struct scheduler *ops) printk(XENLOG_INFO "load tracking window length %llu ns\n", 1ULL << opt_load_window_shift); - /* Basically no CPU information is available at this point; just + /* + * Basically no CPU information is available at this point; just * set up basic structures, and a callback when the CPU info is - * available. */ + * available. + */ prv = xzalloc(struct csched2_private); if ( prv == NULL ) @@ -3111,7 +3113,13 @@ csched2_init(struct scheduler *ops) rwlock_init(&prv->lock); INIT_LIST_HEAD(&prv->sdom); - /* But un-initialize all runqueues */ + /* Allocate all runqueues and mark them as un-initialized */ + prv->rqd = xzalloc_array(struct csched2_runqueue_data, nr_cpu_ids); + if ( !prv->rqd ) + { + xfree(prv); + return -ENOMEM; + } for ( i = 0; i < nr_cpu_ids; i++ ) { prv->runq_map[i] = -1;