From nobody Mon Feb 9 09:08:54 2026 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; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1607531782; cv=none; d=zohomail.com; s=zohoarc; b=ERyUnqEb/Y1vb2JnZtPLz9zT0ldu6J0AfYoHhpvEJpvXiAIA6bPDorQEqY62gjOx56dZOI+UmgwGvitx+00DvGlja8cPCEk53FEiZTMCTa/qyNGF6r9CdHPeR05Rj4cKCGsp3Tqkm/FSlPR8F0liYqhDlintxJTnCfVqtuhqXq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607531782; h=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=am94U0utN2Ue9jktg4hF/gzv3ykid5UM0GvnBsWgHyU=; b=fEQnHOyflLKnkCxOA5Ns/tLbyTeQjj2I6T6n3IijYNS4U2/DTxybv9AjRhzCWUxc+72TlEOOvIU1QM/dpm9q9L3CSuBu7H7/s9iutbwLBgyUzAV6AMHmkckDI7EwXiLy0REvDJlV9fvMApn3HCL5pEUGBr8Ynmk4SSzuXx7EqfU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607531782002250.73306182405906; Wed, 9 Dec 2020 08:36:22 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.48431.85691 (Exim 4.92) (envelope-from ) id 1kn22f-0003Hj-Bo; Wed, 09 Dec 2020 16:10:13 +0000 Received: by outflank-mailman (output) from mailman id 48431.85691; Wed, 09 Dec 2020 16:10:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn22f-0003HT-8Q; Wed, 09 Dec 2020 16:10:13 +0000 Received: by outflank-mailman (input) for mailman id 48431; Wed, 09 Dec 2020 16:10:11 +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 1kn22d-0002Or-7D for xen-devel@lists.xenproject.org; Wed, 09 Dec 2020 16:10:11 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0f6655d5-55ae-48c3-be13-b6ed1eccfdd3; Wed, 09 Dec 2020 16:10:01 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9A041B278; Wed, 9 Dec 2020 16:10:00 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0f6655d5-55ae-48c3-be13-b6ed1eccfdd3 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607530200; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=am94U0utN2Ue9jktg4hF/gzv3ykid5UM0GvnBsWgHyU=; b=EpPmOjNG0FFXPmBjiSvX6HmVSUhiHTbeOY9WCv7hSTNwt6+60G4OOwKdLUxtBkadZb9Jq2 KPksBVJ2V9xqu9NPhoW9ZqViGv+usvLqXbChx2kF42EwWQ2mOVgqqwmbKi66ZiU+ybwKV/ J2TZebCcU9fwBgnr8c9/6RI4ldDit7A= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Dario Faggioli Subject: [PATCH v3 7/8] xen/cpupool: add scheduling granularity entry to cpupool entries Date: Wed, 9 Dec 2020 17:09:55 +0100 Message-Id: <20201209160956.32456-8-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201209160956.32456-1-jgross@suse.com> References: <20201209160956.32456-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Add a "sched-gran" entry to the per-cpupool hypfs directories. For now make this entry read-only and let it contain one of the strings "cpu", "core" or "socket". Signed-off-by: Juergen Gross --- V2: - added const (Jan Beulich) - modify test in cpupool_gran_read() (Jan Beulich) --- docs/misc/hypfs-paths.pandoc | 4 ++ xen/common/sched/cpupool.c | 72 ++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc index aaca1cdf92..f1ce24d7fe 100644 --- a/docs/misc/hypfs-paths.pandoc +++ b/docs/misc/hypfs-paths.pandoc @@ -184,6 +184,10 @@ A directory of all current cpupools. The individual cpupools. Each entry is a directory with the name being the cpupool-id (e.g. /cpupool/0/). =20 +#### /cpupool/*/sched-gran =3D ("cpu" | "core" | "socket") + +The scheduling granularity of a cpupool. + #### /params/ =20 A directory of runtime parameters. diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c index f293ba0cc4..e2011367bd 100644 --- a/xen/common/sched/cpupool.c +++ b/xen/common/sched/cpupool.c @@ -41,9 +41,10 @@ static DEFINE_SPINLOCK(cpupool_lock); static enum sched_gran __read_mostly opt_sched_granularity =3D SCHED_GRAN_= cpu; static unsigned int __read_mostly sched_granularity =3D 1; =20 +#define SCHED_GRAN_NAME_LEN 8 struct sched_gran_name { enum sched_gran mode; - char name[8]; + char name[SCHED_GRAN_NAME_LEN]; }; =20 static const struct sched_gran_name sg_name[] =3D { @@ -52,7 +53,7 @@ static const struct sched_gran_name sg_name[] =3D { {SCHED_GRAN_socket, "socket"}, }; =20 -static void sched_gran_print(enum sched_gran mode, unsigned int gran) +static const char *sched_gran_get_name(enum sched_gran mode) { const char *name =3D ""; unsigned int i; @@ -66,8 +67,13 @@ static void sched_gran_print(enum sched_gran mode, unsig= ned int gran) } } =20 + return name; +} + +static void sched_gran_print(enum sched_gran mode, unsigned int gran) +{ printk("Scheduling granularity: %s, %u CPU%s per sched-resource\n", - name, gran, gran =3D=3D 1 ? "" : "s"); + sched_gran_get_name(mode), gran, gran =3D=3D 1 ? "" : "s"); } =20 #ifdef CONFIG_HAS_SCHED_GRANULARITY @@ -1014,10 +1020,16 @@ static int cpupool_dir_read(const struct hypfs_entr= y *entry, XEN_GUEST_HANDLE_PARAM(void) uaddr) { int ret =3D 0; - const struct cpupool *c; + struct cpupool *c; + struct hypfs_dyndir_id *data; + + data =3D hypfs_get_dyndata(); =20 list_for_each_entry(c, &cpupool_list, list) { + data->id =3D c->cpupool_id; + data->data =3D c; + ret =3D hypfs_read_dyndir_id_entry(&cpupool_pooldir, c->cpupool_id, list_is_last(&c->list, &cpupool_l= ist), &uaddr); @@ -1080,6 +1092,56 @@ static struct hypfs_entry *cpupool_dir_findentry( return hypfs_gen_dyndir_id_entry(&cpupool_pooldir, id, cpupool); } =20 +static int cpupool_gran_read(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr) +{ + const struct hypfs_dyndir_id *data; + const struct cpupool *cpupool; + const char *gran; + + data =3D hypfs_get_dyndata(); + cpupool =3D data->data; + ASSERT(cpupool); + + gran =3D sched_gran_get_name(cpupool->gran); + + if ( !*gran ) + return -ENOENT; + + return copy_to_guest(uaddr, gran, strlen(gran) + 1) ? -EFAULT : 0; +} + +static unsigned int hypfs_gran_getsize(const struct hypfs_entry *entry) +{ + const struct hypfs_dyndir_id *data; + const struct cpupool *cpupool; + const char *gran; + + data =3D hypfs_get_dyndata(); + cpupool =3D data->data; + ASSERT(cpupool); + + gran =3D sched_gran_get_name(cpupool->gran); + + return strlen(gran) + 1; +} + +static const struct hypfs_funcs cpupool_gran_funcs =3D { + .enter =3D hypfs_node_enter, + .exit =3D hypfs_node_exit, + .read =3D cpupool_gran_read, + .write =3D hypfs_write_deny, + .getsize =3D hypfs_gran_getsize, + .findentry =3D hypfs_leaf_findentry, +}; + +static HYPFS_VARSIZE_INIT(cpupool_gran, XEN_HYPFS_TYPE_STRING, "sched-gran= ", + 0, &cpupool_gran_funcs); +static char granstr[SCHED_GRAN_NAME_LEN] =3D { + [0 ... SCHED_GRAN_NAME_LEN - 2] =3D '?', + [SCHED_GRAN_NAME_LEN - 1] =3D 0 +}; + static const struct hypfs_funcs cpupool_dir_funcs =3D { .enter =3D cpupool_dir_enter, .exit =3D cpupool_dir_exit, @@ -1095,6 +1157,8 @@ static void cpupool_hypfs_init(void) { hypfs_add_dir(&hypfs_root, &cpupool_dir, true); hypfs_add_dyndir(&cpupool_dir, &cpupool_pooldir); + hypfs_string_set_reference(&cpupool_gran, granstr); + hypfs_add_leaf(&cpupool_pooldir, &cpupool_gran, true); } =20 #else /* CONFIG_HYPFS */ --=20 2.26.2