[Devel] [PATCH] mm: high order allocation detector

Vasily Averin vvs at virtuozzo.com
Tue Aug 31 16:49:26 MSK 2021


Nikita,
you can find my comments below.
Could you please next time add suffux RH7 or RH8
to get something like [PATCH RH7] or [PATCH RH8] -- it's required to underatdn who should handle this patch: 
me (aka vz7 maintanance) or khorenko@ (Vz8 developemt)

Thank you,
	Vasily Averin

On 8/31/21 2:28 PM, Nikita Yushchenko wrote:
> +static ssize_t hoad_control_show(struct kobject *kobj,
> +		struct kobj_attribute *attr, char *buf)
> +{
> +	char *p = buf;
> +	int order;
> +	struct hoad_order_info *hoi;
> +	int counter;
> +	long d;
> +	unsigned int msecs;
> +
> +	rcu_read_lock();
> +	for (order = 1; order < MAX_ORDER; order++) {
> +		hoi = rcu_dereference(hoad_table[order]);
> +		if (hoi) {
> +			counter = atomic_read(&hoi->counter);
> +			msecs = counter ?
> +				jiffies_to_msecs(jiffies - hoi->since_jiffies) :
> +				0;
> +			p += sprintf(p, "order %u: %u/%u in %u/%u msecs\n",
> +					order, counter, hoi->max_allocs,
> +					msecs, jiffies_to_msecs(hoi->interval));
> +		}
> +	}
> +	rcu_read_unlock();
> +	if (hoad_uevent_order) {
> +		p += sprintf(p, "event generation suspended");
> +		d = (long)(hoad_resume_jiffies - jiffies);
> +		if (d > 0) {
> +			p += sprintf(p, ", resume in ");
> +			msecs = jiffies_to_msecs(d);
> +			if (msecs >= 1000 * 60 * 60 * 2)
> +				p += sprintf(p, "%u hours",
> +						msecs / (1000 * 60 * 60));
> +			else if (msecs > 1000 * 60 * 2)
> +				p += sprintf(p, "%u minutes",
> +						msecs / (1000 * 60));
> +			else
> +				p += sprintf(p, "%u seconds",
> +						(msecs + 999) / 1000);
> +		}
> +		*p++ = '\n';
> +	}
> +
> +	return p - buf;
Do we have any guarantee that buf will not be overflowed?

> +static int hoad_init(void)
> +{
> +	int ret;
> +
> +	/* To be able to generate uevents, need a kobject with kset defined.
> +	 *
> +	 * To avoid extra depth inside sysfs, create a kset and use it's
> +	 * internal kobject, by setting it's 'kset' field to itself.
> +	 */
> +	struct kset *kset = kset = kset_create_and_add("hoad", NULL, mm_kobj);

extra ' = kset' ?



More information about the Devel mailing list