From nobody Mon Feb 9 10:58:14 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=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1603703644; cv=none; d=zohomail.com; s=zohoarc; b=WFC6JPbJfmw/v7LchWBh+NUriXV0+U8DfEkb68sPE02yHWAI75U1qqpuA+lkDrwLrz3Uu40XQ+2DZ9HFMOBVp4vKWy9ljkIefAihBsQVFO7wB7TMz+gGta66Paz01u7TPd/TJNTG/P14pZSa8UCAh4Xo5yh7TnGsLD2qclRFqO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603703644; 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=BtuXFg+GprfOQoW7qcf8PMrXYl8U5hOCU9BdXI7w0yo=; b=kEqFKNKNr0bHZ5BPSJ8fSQQ6FeBBFn0ur5r/lwE5ubWx2CZcFA27fEqDKF4Pb+kGCo5gpZTuZxCSCszBOf2mqHJhqPMchZkUV0VNC563vhR7ENP3tfFcAU1CCMV2+ZC20P0hT5/ta4mRdVNFTVICW5fq5oIDa7+62zrsJuBHI8w= 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=none 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 1603703644784512.321638744401; Mon, 26 Oct 2020 02:14:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.12091.31755 (Exim 4.92) (envelope-from ) id 1kWyZX-0005NX-U7; Mon, 26 Oct 2020 09:13:47 +0000 Received: by outflank-mailman (output) from mailman id 12091.31755; Mon, 26 Oct 2020 09:13:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kWyZX-0005N9-DC; Mon, 26 Oct 2020 09:13:47 +0000 Received: by outflank-mailman (input) for mailman id 12091; Mon, 26 Oct 2020 09:13:45 +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 1kWyZV-0004f1-S3 for xen-devel@lists.xenproject.org; Mon, 26 Oct 2020 09:13:45 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d8c24bb7-8e2d-4583-acb4-5a9f8c6fa148; Mon, 26 Oct 2020 09:13:22 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 29ED6B248; Mon, 26 Oct 2020 09:13:21 +0000 (UTC) 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 1kWyZV-0004f1-S3 for xen-devel@lists.xenproject.org; Mon, 26 Oct 2020 09:13:45 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d8c24bb7-8e2d-4583-acb4-5a9f8c6fa148; Mon, 26 Oct 2020 09:13:22 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 29ED6B248; Mon, 26 Oct 2020 09:13:21 +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: d8c24bb7-8e2d-4583-acb4-5a9f8c6fa148 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=1603703601; h=from:from:reply-to:subject:subject: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=BtuXFg+GprfOQoW7qcf8PMrXYl8U5hOCU9BdXI7w0yo=; b=X6sFx1rS9WEJvX5kbsaQAt19W7YP4+Bqr2R8LLtyKOUIrvJq/MPQG1mnjkxkKFXfAhCpQe ova2WKr80t7vA5to7plnDvHfrbuK8FuCN0noIsDDYfUeD96tFt7Ko5fv3sMkS9tXs6v6xx TLgu8mcIfDHuNxe5UH8ufStdahvCuYc= 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 11/12] xen/hypfs: add scheduling granularity entry to cpupool entries Date: Mon, 26 Oct 2020 10:13:15 +0100 Message-Id: <20201026091316.25680-12-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026091316.25680-1-jgross@suse.com> References: <20201026091316.25680-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 Acked-by: Dario Faggioli --- docs/misc/hypfs-paths.pandoc | 4 +++ xen/common/sched/cpupool.c | 51 +++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 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 8612ee5cf6..8674ac0fdd 100644 --- a/xen/common/sched/cpupool.c +++ b/xen/common/sched/cpupool.c @@ -42,9 +42,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 { @@ -53,7 +54,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; @@ -67,8 +68,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 @@ -1057,6 +1063,43 @@ static struct hypfs_entry *cpupool_dir_findentry(str= uct hypfs_entry_dir *dir, return hypfs_gen_dyndir_entry_id(&cpupool_pooldir, id); } =20 +static int cpupool_gran_read(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr) +{ + const struct hypfs_dyndir_id *data; + struct cpupool *cpupool; + const char *name =3D ""; + + data =3D hypfs_get_dyndata(); + if ( !data ) + return -ENOENT; + + spin_lock(&cpupool_lock); + + cpupool =3D __cpupool_find_by_id(data->id, true); + if ( cpupool ) + name =3D sched_gran_get_name(cpupool->gran); + + spin_unlock(&cpupool_lock); + + if ( !cpupool ) + return -ENOENT; + + return copy_to_guest(uaddr, name, strlen(name) + 1) ? -EFAULT : 0; +} + +static struct hypfs_funcs cpupool_gran_funcs =3D { + .read =3D cpupool_gran_read, + .getsize =3D hypfs_getsize, +}; + +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 struct hypfs_funcs cpupool_dir_funcs =3D { .read =3D cpupool_dir_read, .getsize =3D cpupool_dir_getsize, @@ -1075,6 +1118,8 @@ static int __init cpupool_init(void) =20 #ifdef CONFIG_HYPFS hypfs_add_dir(&hypfs_root, &cpupool_dir, true); + hypfs_string_set_reference(&cpupool_gran, granstr); + hypfs_add_leaf(&cpupool_pooldir, &cpupool_gran, true); #endif =20 cpupool0 =3D cpupool_create(0, 0, &err); --=20 2.26.2