From: Li Zefan <lizf@cn.fujitsu.com>
To: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: linux-mm@kvack.org, Hugh Dickins <hugh@veritas.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Sudhir Kumar <skumar@linux.vnet.ibm.com>,
YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
Herbert Poetzl <herbert@13thfloor.at>,
Paul Menage <menage@google.com>,
linux-kernel@vger.kernel.org,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
Nick Piggin <nickpiggin@yahoo.com.au>,
David Rientjes <rientjes@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Pavel Emelianov <xemul@openvz.org>,
Dhaval Giani <dhaval@linux.vnet.ibm.com>,
Rik Van Riel <riel@redhat.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [mm] [PATCH 2/4] Add the soft limit interface v2
Date: Tue, 19 Feb 2008 15:42:28 +0800 [thread overview]
Message-ID: <47BA8864.7080803@cn.fujitsu.com> (raw)
In-Reply-To: <47BA8665.3080302@cn.fujitsu.com>
Li Zefan a??e??:
> Balbir Singh wrote:
>> A new configuration file called soft_limit_in_bytes is added. The parsing
>> and configuration rules remain the same as for the limit_in_bytes user
>> interface.
>>
>> A global list of all memory cgroups over their soft limit is maintained.
>> This list is then used to reclaim memory on global pressure. A cgroup is
>> removed from the list when the cgroup is deleted.
>>
>> The global list is protected with a read-write spinlock.
>>
>
> You are not using read-write spinlock..
>
Ah, the spinlock is changed to r/w spinlock in [PATCH 3/4].
>> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
>> ---
>>
>> mm/memcontrol.c | 33 ++++++++++++++++++++++++++++++++-
>> 1 file changed, 32 insertions(+), 1 deletion(-)
>>
>> diff -puN mm/memcontrol.c~memory-controller-add-soft-limit-interface mm/memcontrol.c
>> --- linux-2.6.25-rc2/mm/memcontrol.c~memory-controller-add-soft-limit-interface 2008-02-19 12:31:49.000000000 +0530
>> +++ linux-2.6.25-rc2-balbir/mm/memcontrol.c 2008-02-19 12:31:49.000000000 +0530
>> @@ -35,6 +35,10 @@
>>
>> struct cgroup_subsys mem_cgroup_subsys;
>> static const int MEM_CGROUP_RECLAIM_RETRIES = 5;
>> +static spinlock_t mem_cgroup_sl_list_lock; /* spin lock that protects */
>> + /* the list of cgroups over*/
>> + /* their soft limit */
>> +static struct list_head mem_cgroup_sl_exceeded_list;
>>
>> /*
>> * Statistics for memory cgroup.
>> @@ -136,6 +140,10 @@ struct mem_cgroup {
>> * statistics.
>> */
>> struct mem_cgroup_stat stat;
>> + /*
>> + * List of all mem_cgroup's that exceed their soft limit
>> + */
>> + struct list_head sl_exceeded_list;
>> };
>>
>> /*
>> @@ -679,6 +687,18 @@ retry:
>> goto retry;
>> }
>>
>> + /*
>> + * If we exceed our soft limit, we get added to the list of
>> + * cgroups over their soft limit
>> + */
>> + if (!res_counter_check_under_limit(&mem->res, RES_SOFT_LIMIT)) {
>> + spin_lock_irqsave(&mem_cgroup_sl_list_lock, flags);
>> + if (list_empty(&mem->sl_exceeded_list))
>> + list_add_tail(&mem->sl_exceeded_list,
>> + &mem_cgroup_sl_exceeded_list);
>> + spin_unlock_irqrestore(&mem_cgroup_sl_list_lock, flags);
>> + }
>> +
>> mz = page_cgroup_zoneinfo(pc);
>> spin_lock_irqsave(&mz->lru_lock, flags);
>> /* Update statistics vector */
>> @@ -736,13 +756,14 @@ void mem_cgroup_uncharge(struct page_cgr
>> if (atomic_dec_and_test(&pc->ref_cnt)) {
>> page = pc->page;
>> mz = page_cgroup_zoneinfo(pc);
>> + mem = pc->mem_cgroup;
>> /*
>> * get page->cgroup and clear it under lock.
>> * force_empty can drop page->cgroup without checking refcnt.
>> */
>> unlock_page_cgroup(page);
>> +
>> if (clear_page_cgroup(page, pc) == pc) {
>> - mem = pc->mem_cgroup;
>> css_put(&mem->css);
>> res_counter_uncharge(&mem->res, PAGE_SIZE);
>> spin_lock_irqsave(&mz->lru_lock, flags);
>> @@ -1046,6 +1067,12 @@ static struct cftype mem_cgroup_files[]
>> .name = "stat",
>> .open = mem_control_stat_open,
>> },
>> + {
>> + .name = "soft_limit_in_bytes",
>> + .private = RES_SOFT_LIMIT,
>> + .write = mem_cgroup_write,
>> + .read = mem_cgroup_read,
>> + },
>> };
>>
>> static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *mem, int node)
>> @@ -1097,6 +1124,9 @@ mem_cgroup_create(struct cgroup_subsys *
>> if (unlikely((cont->parent) == NULL)) {
>> mem = &init_mem_cgroup;
>> init_mm.mem_cgroup = mem;
>> + INIT_LIST_HEAD(&mem->sl_exceeded_list);
>> + spin_lock_init(&mem_cgroup_sl_list_lock);
>> + INIT_LIST_HEAD(&mem_cgroup_sl_exceeded_list);
>> } else
>> mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL);
>>
>> @@ -1104,6 +1134,7 @@ mem_cgroup_create(struct cgroup_subsys *
>> return NULL;
>>
>> res_counter_init(&mem->res);
>> + INIT_LIST_HEAD(&mem->sl_exceeded_list);
>>
>
> mem->sl_exceeded_list initialized twice ?
>
>> memset(&mem->info, 0, sizeof(mem->info));
>>
>> _
>>
> --
--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-02-19 7:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-19 7:02 [mm][PATCH 0/4] Add soft limits to the memory controller v2 Balbir Singh
2008-02-19 7:02 ` [mm] [PATCH 1/4] Modify resource counters to add soft limit support v2 Balbir Singh
2008-02-19 7:02 ` [mm] [PATCH 2/4] Add the soft limit interface v2 Balbir Singh
2008-02-19 7:33 ` Li Zefan
2008-02-19 7:42 ` Li Zefan [this message]
2008-02-19 8:36 ` Balbir Singh
2008-02-19 8:38 ` Balbir Singh
2008-02-19 7:03 ` [mm] [PATCH 3/4] Reclaim from groups over their soft limit under memory pressure v2 Balbir Singh
2008-02-19 7:03 ` [mm] [PATCH 4/4] Add soft limit documentation v2 Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47BA8864.7080803@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=Lee.Schermerhorn@hp.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=dhaval@linux.vnet.ibm.com \
--cc=ebiederm@xmission.com \
--cc=herbert@13thfloor.at \
--cc=hugh@veritas.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=menage@google.com \
--cc=nickpiggin@yahoo.com.au \
--cc=riel@redhat.com \
--cc=rientjes@google.com \
--cc=skumar@linux.vnet.ibm.com \
--cc=xemul@openvz.org \
--cc=yamamoto@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).