From nobody Mon Nov 10 21:44:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1588181809; cv=none; d=zohomail.com; s=zohoarc; b=FLFL/8adgFfdpL5Y4GHv62EGx7gjbteo4J78nsbUxtSzeNGjXTYudvizJWirZe4T+rnRw1CaSzgFuEtnve9PjtqdPtGOJ+UjrwaZDhQngIDROUBZuyVh8jdK7aQq2JHIyf3ENZsacTW9FlULY+UGABHmzhAHunCqDn3kxyIhsoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588181809; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YlTYpP2lAmqY0oKCVcZWNr5Jn2sk4xml3pytUqyyAhc=; b=iaX9ezqBwFJWa+JXZu6jbxfOZtwF56FFp0KQH5U6jjOtHU5XDtEK7PJIXa4yZ9wHeiFJSXEHavipvykWfcFXrTIUwjVFo1kTFI1k6jQZp/YeUzl/hbd46zsbSjchQtS2ilUkv3eD3E1mEK4FE2N6K0mwJgsanhjBS4DaNj5i9nY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 158818180978534.16392767102718; Wed, 29 Apr 2020 10:36:49 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTqdP-0002AW-Iv; Wed, 29 Apr 2020 17:36:35 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTqdN-00029s-KT for xen-devel@lists.xenproject.org; Wed, 29 Apr 2020 17:36:33 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f68dd874-8a3f-11ea-9980-12813bfff9fa; Wed, 29 Apr 2020 17:36:31 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 265DFAC37; Wed, 29 Apr 2020 17:36:30 +0000 (UTC) X-Inumbo-ID: f68dd874-8a3f-11ea-9980-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de Subject: [PATCH 1/2] xen: credit2: factor cpu to runqueue matching in a function From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Wed, 29 Apr 2020 19:36:30 +0200 Message-ID: <158818178990.24327.6732870355943077303.stgit@Palanthas> In-Reply-To: <158818022727.24327.14309662489731832234.stgit@Palanthas> References: <158818022727.24327.14309662489731832234.stgit@Palanthas> User-Agent: StGit/0.21 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: George Dunlap Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Just move the big if() condition in an inline function. No functional change intended. Signed-off-by: Dario Faggioli --- Cc: George Dunlap --- xen/common/sched/credit2.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index 34f05c3e2a..697c9f917d 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -838,6 +838,20 @@ static inline bool same_core(unsigned int cpua, unsign= ed int cpub) cpu_to_core(cpua) =3D=3D cpu_to_core(cpub); } =20 +static inline bool +cpu_runqueue_match(const struct csched2_runqueue_data *rqd, unsigned int c= pu) +{ + unsigned int peer_cpu =3D rqd->pick_bias; + + BUG_ON(cpu_to_socket(peer_cpu) =3D=3D XEN_INVALID_SOCKET_ID); + + /* OPT_RUNQUEUE_CPU will never find an existing runqueue. */ + return opt_runqueue =3D=3D OPT_RUNQUEUE_ALL || + (opt_runqueue =3D=3D OPT_RUNQUEUE_CORE && same_core(peer_cpu, c= pu)) || + (opt_runqueue =3D=3D OPT_RUNQUEUE_SOCKET && same_socket(peer_cp= u, cpu)) || + (opt_runqueue =3D=3D OPT_RUNQUEUE_NODE && same_node(peer_cpu, c= pu)); +} + static struct csched2_runqueue_data * cpu_add_to_runqueue(struct csched2_private *prv, unsigned int cpu) { @@ -855,21 +869,11 @@ cpu_add_to_runqueue(struct csched2_private *prv, unsi= gned int cpu) rqd_ins =3D &prv->rql; list_for_each_entry ( rqd, &prv->rql, rql ) { - unsigned int peer_cpu; - /* Remember first unused queue index. */ if ( !rqi_unused && rqd->id > rqi ) rqi_unused =3D true; =20 - peer_cpu =3D rqd->pick_bias; - BUG_ON(cpu_to_socket(cpu) =3D=3D XEN_INVALID_SOCKET_ID || - cpu_to_socket(peer_cpu) =3D=3D XEN_INVALID_SOCKET_ID); - - /* OPT_RUNQUEUE_CPU will never find an existing runqueue. */ - if ( opt_runqueue =3D=3D OPT_RUNQUEUE_ALL || - (opt_runqueue =3D=3D OPT_RUNQUEUE_CORE && same_core(peer_cpu,= cpu)) || - (opt_runqueue =3D=3D OPT_RUNQUEUE_SOCKET && same_socket(peer_= cpu, cpu)) || - (opt_runqueue =3D=3D OPT_RUNQUEUE_NODE && same_node(peer_cpu,= cpu)) ) + if ( cpu_runqueue_match(rqd, cpu) ) { rqd_valid =3D true; break; @@ -3744,6 +3748,8 @@ csched2_alloc_pdata(const struct scheduler *ops, int = cpu) struct csched2_pcpu *spc; struct csched2_runqueue_data *rqd; =20 + BUG_ON(cpu_to_socket(cpu) =3D=3D XEN_INVALID_SOCKET_ID); + spc =3D xzalloc(struct csched2_pcpu); if ( spc =3D=3D NULL ) return ERR_PTR(-ENOMEM);