Re: [RFC][PATCH] oom: Be less verbose if the oom_control event fd has listeners

Oleg Nesterov
2014-06-05T14:18:41Z

On 06/05, Richard Weinberger wrote:
>
> +int mem_cgroup_has_listeners(struct mem_cgroup *memcg)
> +{
> + int ret = 0;
> +
> + if (!memcg)
> + goto out;
> +
> + spin_lock(&memcg_oom_lock);
> + ret = !list_empty(&memcg->oom_notify);
> + spin_unlock(&memcg_oom_lock);
> +
> +out:
> + return ret;
> +}

Do we really need memcg_oom_lock to check list_empty() ? With or without
this lock we can race with list_add/del anyway, and I guess we do not care.

And perhaps the caller should check memcg != NULL. but this is subjective,
I won't argue.

Oleg.