From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Weinberger Subject: Re: [RFC][PATCH] oom: Be less verbose if the oom_control event fd has listeners Date: Thu, 05 Jun 2014 18:10:17 +0200 Message-ID: <53909669.8000007@nod.at> References: <1401976841-3899-1-git-send-email-richard@nod.at> <1401976841-3899-2-git-send-email-richard@nod.at> <20140605141841.GA23796@redhat.com> <539090F1.7090408@nod.at> <20140605160029.GA28812@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20140605160029.GA28812-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Oleg Nesterov Cc: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, mhocko-AlSwsSmVLrQ@public.gmane.org, bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org, tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org, rientjes-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org, kirill.shutemov-VuQAYsv1563Yd54FQh9/CA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org Am 05.06.2014 18:00, schrieb Oleg Nesterov: > On 06/05, Richard Weinberger wrote: >> >> Am 05.06.2014 16:18, schrieb Oleg Nesterov: >>> 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. >> >> Hmm, in mm/memcontrol.c all list_dev/add are under memcg_oom_lock. > > And? How this lock can help to check list_empty() ? > > list_add/del can come right after mem_cgroup_has_listeners() and change > the value of list_empty() anyway. Ahh, now I can follow your mind. :) Thanks, //richard From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by kanga.kvack.org (Postfix) with ESMTP id 7A45E6B0037 for ; Thu, 5 Jun 2014 12:10:38 -0400 (EDT) Received: by mail-wi0-f180.google.com with SMTP id hi2so3829015wib.7 for ; Thu, 05 Jun 2014 09:10:37 -0700 (PDT) Received: from radon.swed.at (a.ns.miles-group.at. [95.130.255.143]) by mx.google.com with ESMTPS id pf7si12237207wjb.9.2014.06.05.09.10.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Jun 2014 09:10:26 -0700 (PDT) Message-ID: <53909669.8000007@nod.at> Date: Thu, 05 Jun 2014 18:10:17 +0200 From: Richard Weinberger MIME-Version: 1.0 Subject: Re: [RFC][PATCH] oom: Be less verbose if the oom_control event fd has listeners References: <1401976841-3899-1-git-send-email-richard@nod.at> <1401976841-3899-2-git-send-email-richard@nod.at> <20140605141841.GA23796@redhat.com> <539090F1.7090408@nod.at> <20140605160029.GA28812@redhat.com> In-Reply-To: <20140605160029.GA28812@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Oleg Nesterov Cc: hannes@cmpxchg.org, mhocko@suse.cz, bsingharora@gmail.com, kamezawa.hiroyu@jp.fujitsu.com, akpm@linux-foundation.org, vdavydov@parallels.com, tj@kernel.org, handai.szj@taobao.com, rientjes@google.com, rusty@rustcorp.com.au, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Am 05.06.2014 18:00, schrieb Oleg Nesterov: > On 06/05, Richard Weinberger wrote: >> >> Am 05.06.2014 16:18, schrieb Oleg Nesterov: >>> 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. >> >> Hmm, in mm/memcontrol.c all list_dev/add are under memcg_oom_lock. > > And? How this lock can help to check list_empty() ? > > list_add/del can come right after mem_cgroup_has_listeners() and change > the value of list_empty() anyway. Ahh, now I can follow your mind. :) Thanks, //richard -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752440AbaFEQKZ (ORCPT ); Thu, 5 Jun 2014 12:10:25 -0400 Received: from a.ns.miles-group.at ([95.130.255.143]:47835 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750809AbaFEQKX (ORCPT ); Thu, 5 Jun 2014 12:10:23 -0400 Message-ID: <53909669.8000007@nod.at> Date: Thu, 05 Jun 2014 18:10:17 +0200 From: Richard Weinberger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Oleg Nesterov CC: hannes@cmpxchg.org, mhocko@suse.cz, bsingharora@gmail.com, kamezawa.hiroyu@jp.fujitsu.com, akpm@linux-foundation.org, vdavydov@parallels.com, tj@kernel.org, handai.szj@taobao.com, rientjes@google.com, rusty@rustcorp.com.au, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC][PATCH] oom: Be less verbose if the oom_control event fd has listeners References: <1401976841-3899-1-git-send-email-richard@nod.at> <1401976841-3899-2-git-send-email-richard@nod.at> <20140605141841.GA23796@redhat.com> <539090F1.7090408@nod.at> <20140605160029.GA28812@redhat.com> In-Reply-To: <20140605160029.GA28812@redhat.com> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 05.06.2014 18:00, schrieb Oleg Nesterov: > On 06/05, Richard Weinberger wrote: >> >> Am 05.06.2014 16:18, schrieb Oleg Nesterov: >>> 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. >> >> Hmm, in mm/memcontrol.c all list_dev/add are under memcg_oom_lock. > > And? How this lock can help to check list_empty() ? > > list_add/del can come right after mem_cgroup_has_listeners() and change > the value of list_empty() anyway. Ahh, now I can follow your mind. :) Thanks, //richard