Commit 1e7284b7 authored by Amit Singh Tomar's avatar Amit Singh Tomar Committed by Zeng Heng
Browse files

fs/resctrl: Remove the limit on the number of CLOSID

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8T2RT

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/log/?h=mpam/snapshot/v6.7-rc2



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

At the moment, number of resource control group (user can create) is
limited to 32. Remove the limit.

ffs() returns '1' for bit 0, hence the existing code subtracts 1 from
the index to get the CLOSID value. find_first_bit() returns the bit
number which does not need adjusting.

Signed-off-by: default avatarAmit Singh Tomar <amitsinght@marvell.com>
[ morse: fixed the off-by-one in the allocator and the wrong
  not-found value. Removed the limit. ]
Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent 56ab8692
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ static bool mpam_resctrl_hide_cdp(enum resctrl_res_level rid)
 */
u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored)
{
	return min((u32)mpam_partid_max + 1, (u32)RESCTRL_MAX_CLOSID);
	return mpam_partid_max + 1;
}

u32 resctrl_arch_system_num_rmid_idx(void)
+13 −12
Original line number Diff line number Diff line
@@ -123,8 +123,8 @@ static bool resctrl_is_mbm_event(int e)
}

/*
 * Trivial allocator for CLOSIDs. Since h/w only supports a small number,
 * we can keep a bitmap of free CLOSIDs in a single integer.
 * Trivial allocator for CLOSIDs. Use BITMAP APIs to manipulate a bitmap
 * of free CLOSIDs.
 *
 * Using a global CLOSID across all resources has some advantages and
 * some drawbacks:
@@ -137,7 +137,7 @@ static bool resctrl_is_mbm_event(int e)
 * - Our choices on how to configure each resource become progressively more
 *   limited as the number of resources grows.
 */
static unsigned long closid_free_map;
static unsigned long *closid_free_map;
static int closid_free_map_len;

int closids_supported(void)
@@ -148,16 +148,17 @@ int closids_supported(void)
static void closid_init(void)
{
	struct resctrl_schema *s;
	u32 rdt_min_closid = 32;
	u32 rdt_min_closid = ~0;

	/* Compute rdt_min_closid across all resources */
	list_for_each_entry(s, &resctrl_schema_all, list)
		rdt_min_closid = min(rdt_min_closid, s->num_closid);

	closid_free_map = BIT_MASK(rdt_min_closid) - 1;
	closid_free_map = bitmap_alloc(rdt_min_closid, GFP_KERNEL);
	bitmap_fill(closid_free_map, rdt_min_closid);

	/* RESCTRL_RESERVED_CLOSID is always reserved for the default group */
	__clear_bit(RESCTRL_RESERVED_CLOSID, &closid_free_map);
	__clear_bit(RESCTRL_RESERVED_CLOSID, closid_free_map);
	closid_free_map_len = rdt_min_closid;
}

@@ -174,12 +175,12 @@ static int closid_alloc(void)
			return cleanest_closid;
		closid = cleanest_closid;
	} else {
		closid = ffs(closid_free_map);
		if (closid == 0)
		closid = find_first_bit(closid_free_map, closid_free_map_len);
		if (closid == closid_free_map_len)
			return -ENOSPC;
		closid--;
	}
	__clear_bit(closid, &closid_free_map);

	__clear_bit(closid, closid_free_map);

	return closid;
}
@@ -188,7 +189,7 @@ void closid_free(int closid)
{
	lockdep_assert_held(&rdtgroup_mutex);

	__set_bit(closid, &closid_free_map);
	__set_bit(closid, closid_free_map);
}

/**
@@ -202,7 +203,7 @@ bool closid_allocated(unsigned int closid)
{
	lockdep_assert_held(&rdtgroup_mutex);

	return !test_bit(closid, &closid_free_map);
	return !test_bit(closid, closid_free_map);
}

/**
+0 −5
Original line number Diff line number Diff line
@@ -30,11 +30,6 @@ int proc_resctrl_show(struct seq_file *m,
/* max value for struct rdt_domain's mbps_val */
#define MBA_MAX_MBPS   U32_MAX

/*
 * Resctrl uses a u32 as a closid bitmap. The maximum closid is 32.
 */
#define RESCTRL_MAX_CLOSID		32

/*
 * Resctrl uses u32 to hold the user-space config. The maximum bitmap size is
 * 32.