Commit 65479800 authored by Lu Jialin's avatar Lu Jialin
Browse files

psi: add struct psi_group_ext

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8BCV4



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

Change struct psi_group directly will causes the kabi broken.
Therefore, add a new struct psi_group_ext for new variables, which
will be added in the next patch of pressure.stat.

Signed-off-by: default avatarLu Jialin <lujialin4@huawei.com>
parent 119ce5e0
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -231,6 +231,14 @@ struct psi_group {
	u64 polling_until;
};

#ifdef CONFIG_PSI_FINE_GRAINED
struct psi_group_ext {
	struct psi_group psi;
};
#else
struct psi_group_ext { };
#endif /* CONFIG_PSI_FINE_GRAINED */

#else /* CONFIG_PSI */

struct psi_group { };
+10 −0
Original line number Diff line number Diff line
@@ -663,6 +663,16 @@ config PSI_CGROUP_V1

         Say N if unsure.

config PSI_FINE_GRAINED
	bool "Support fine grained psi under cgroup v1 and system"
	default n
	depends on PSI
	help
	  If set, fine grained pressure stall information tracking will
	  be used for cgroup v1 and system, such as memory reclaim,
	  memory compact and so on.
	  Say N if unsure.

endmenu # "CPU/Task time and stats accounting"

config CPU_ISOLATION
+37 −0
Original line number Diff line number Diff line
@@ -192,6 +192,24 @@ struct psi_group psi_system = {
	.pcpu = &system_group_pcpu,
};

#ifdef CONFIG_PSI_FINE_GRAINED
/* System-level fine grained pressure and stall tracking */
struct psi_group_ext psi_stat_system = { };

struct psi_group_ext *to_psi_group_ext(struct psi_group *psi)
{
	if (psi == &psi_system)
		return &psi_stat_system;
	else
		return container_of(psi, struct psi_group_ext, psi);
}
#else
static inline struct psi_group_ext *to_psi_group_ext(struct psi_group *psi)
{
	return NULL;
}
#endif

static void psi_avgs_work(struct work_struct *work);

static void poll_timer_fn(struct timer_list *t);
@@ -1027,16 +1045,31 @@ void psi_memstall_leave(unsigned long *flags)
#ifdef CONFIG_CGROUPS
int psi_cgroup_alloc(struct cgroup *cgroup)
{
#ifdef CONFIG_PSI_FINE_GRAINED
	struct psi_group_ext *psi_ext;
#endif

	if (static_branch_likely(&psi_disabled))
		return 0;

#ifdef CONFIG_PSI_FINE_GRAINED
	psi_ext = kzalloc(sizeof(struct psi_group_ext), GFP_KERNEL);
	if (!psi_ext)
		return -ENOMEM;
	cgroup->psi = &psi_ext->psi;
#else
	cgroup->psi = kzalloc(sizeof(struct psi_group), GFP_KERNEL);
	if (!cgroup->psi)
		return -ENOMEM;

#endif
	cgroup->psi->pcpu = alloc_percpu(struct psi_group_cpu);
	if (!cgroup->psi->pcpu) {
#ifdef CONFIG_PSI_FINE_GRAINED
		kfree(psi_ext);
#else
		kfree(cgroup->psi);
#endif
		return -ENOMEM;
	}
	group_init(cgroup->psi);
@@ -1052,7 +1085,11 @@ void psi_cgroup_free(struct cgroup *cgroup)
	free_percpu(cgroup->psi->pcpu);
	/* All triggers must be removed by now */
	WARN_ONCE(cgroup->psi->poll_states, "psi: trigger leak\n");
#ifdef CONFIG_PSI_FINE_GRAINED
	kfree(to_psi_group_ext(cgroup->psi));
#else
	kfree(cgroup->psi);
#endif
}

/**