lkml.org 
[lkml]   [2021]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: cma: support sysfs
On Wed, Feb 03, 2021 at 07:50:01AM -0800, Minchan Kim wrote:
> +++ b/mm/Makefile
> @@ -106,6 +106,7 @@ obj-$(CONFIG_ZSMALLOC) += zsmalloc.o
> obj-$(CONFIG_Z3FOLD) += z3fold.o
> obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o
> obj-$(CONFIG_CMA) += cma.o
> +obj-$(CONFIG_SYSFS) += cma_sysfs.o

ehh ... if we have a kernel build with CMA=n, SYSFS=y, we'll get
cma_sysfs built in with no cma to report on.

> +static ssize_t cma_alloc_attempt_show(struct kobject *kobj,
> + struct kobj_attribute *attr, char *buf)
> +{
> + unsigned long val;
> + struct cma_stat *stat = container_of(kobj, struct cma_stat, kobj);
> +
> + val = stat->alloc_attempt;
> +
> + return sysfs_emit(buf, "%lu\n", val);

Why not more simply:

{
struct cma_stat *stat = container_of(kobj, struct cma_stat, kobj);
return sysfs_emit(buf, "%lu\n", stat->alloc_attempt);
}

> + for (i = 0; i < cma_area_count; i++) {
> + cma = &cma_areas[i];
> + stat = kzalloc(sizeof(*stat), GFP_KERNEL);
> + if (!stat)
> + goto out;

How many cma areas are there going to be? do we really want to allocate
their stat individually?

\
 
 \ /
  Last update: 2021-02-05 03:57    [W:0.147 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site