Commit 366a2fd2 authored by Wang ShaoBo's avatar Wang ShaoBo Committed by Yu Liao
Browse files

arm64/mpam: mark partid non-exclusive if self-owned

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7SVKK



--------------------------------

MPAM manages RMID in a matrix using PARTID as columns and PMG as rows.

 ------------row---------------------->
|
|  RMID  0     1     2     3   ... 255
|        256   257   258   259 ... 511
|        512   513   514   515 ... 767
v        768   769   770   771 ... 1023

Each time mon_groups is created, a new PARTID will be consumed until all
PARTID are exhausted and PMG still has remaining. As a result, RMID
greater than 255 cannot be used. mon_groups in the same resource group
should reuse PARTID to avoid rmid waste.

Fix it by adding 'exclusive' parameter to rmid_remap_bmp_find_step_entry()
  1) Allocate non-exclusive rmid for rmid_alloc()
  2) Allocate exclusive rmid when 'partid = old_reqpartid' for
     resctrl_group_rmid_write(). Otherwise, allocate non-exclusive rmid.

Signed-off-by: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
parent 2e7a3cda
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -919,7 +919,7 @@ static int is_rmid_remap_bmp_full(unsigned long *bmp)
			bitmap_full(bmp, rmid_remap_matrix.rows));
}

static int rmid_remap_bmp_find_step_entry(int partid)
static int rmid_remap_bmp_find_step_entry(int partid, bool exclusive)
{
	int x, y;
	unsigned long **bmp;
@@ -931,7 +931,7 @@ static int rmid_remap_bmp_find_step_entry(int partid)
	/* step entry should be non-occupied and aligned */
	bmp = __rmid_remap_bmp(partid);
	if (bmp)
		return (is_rmid_remap_bmp_occ(*bmp) ||
		return ((exclusive && is_rmid_remap_bmp_occ(*bmp)) ||
			!__step_align(partid)) ? -ENOSPC : partid;

	for_each_rmid_transform_point_from(bmp, x, y, 0) {
@@ -1024,7 +1024,7 @@ static int rmid_to_partid_pmg(int rmid, int *partid, int *pmg)
	return 0;
}

static int __rmid_alloc(int partid, int pmg)
static int __rmid_alloc(int partid, int pmg, bool exclusive)
{
	int x, y, step, ret, rmid;
	bool checkpmg = false;
@@ -1034,7 +1034,7 @@ static int __rmid_alloc(int partid, int pmg)
		checkpmg = true;

	/* traverse from first non-occupied and step-aligned entry */
	ret = rmid_remap_bmp_find_step_entry(partid);
	ret = rmid_remap_bmp_find_step_entry(partid, exclusive);
	if (ret < 0)
		goto out;
	partid = ret;
@@ -1084,7 +1084,7 @@ static int __rmid_alloc(int partid, int pmg)

int rmid_alloc(int partid)
{
	return __rmid_alloc(partid, -1);
	return __rmid_alloc(partid, -1, false);
}

void rmid_free(int rmid)
@@ -1914,6 +1914,7 @@ static ssize_t resctrl_group_rmid_write(struct kernfs_open_file *of,
	struct rdtgroup *rdtgrp;
	int ret = 0;
	int partid;
	bool exclusive;
	int pmg;
	int rmid;
	int old_rmid;
@@ -1954,15 +1955,16 @@ static ssize_t resctrl_group_rmid_write(struct kernfs_open_file *of,
		goto unlock;
	}

	ret = __rmid_alloc(partid, pmg);
	old_rmid = rdtgrp->mon.rmid;
	old_reqpartid = rdtgrp->closid.reqpartid;

	exclusive = (partid == old_reqpartid) ? false : true;
	ret = __rmid_alloc(partid, pmg, exclusive);
	if (ret < 0) {
		rdt_last_cmd_puts("set rmid failed\n");
		goto unlock;
	}

	old_rmid = rdtgrp->mon.rmid;
	old_reqpartid = rdtgrp->closid.reqpartid;

	/*
	 * we use intpartid as group control, use reqpartid for config
	 * synchronization and monitor, only update the reqpartid