OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] cgroup: Avoid a memset by using vzalloc
[PATCH] cgroup: Avoid a memset by using vzalloc [message #41955] Sat, 30 October 2010 21:35 Go to next message
Jesper Juhl is currently offline  Jesper Juhl
Messages: 7
Registered: October 2010
Junior Member
Hi,

We can avoid doing a memset in swap_cgroup_swapon() by using vzalloc().


Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
compile tested only.
page_cgroup.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 5bffada..34970c7 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -450,11 +450,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
length = ((max_pages/SC_PER_PAGE) + 1);
array_size = length * sizeof(void *);

- array = vmalloc(array_size);
+ array = vzalloc(array_size);
if (!array)
goto nomem;

- memset(array, 0, array_size);
ctrl = &swap_cgroup_ctrl[type];
mutex_lock(&swap_cgroup_mutex);
ctrl->length = length;

--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containe rs
Re: [PATCH] cgroup: Avoid a memset by using vzalloc [message #41956 is a reply to message #41955] Mon, 01 November 2010 05:40 Go to previous message
Jesper Juhl is currently offline  Jesper Juhl
Messages: 7
Registered: October 2010
Junior Member
On Sun, 31 Oct 2010, Balbir Singh wrote:

> * MinChan Kim <minchan.kim@gmail.com> [2010-10-31 08:34:01]:
>
> > On Sun, Oct 31, 2010 at 6:35 AM, Jesper Juhl <jj@chaosbits.net> wrote:
> > > Hi,
> > >
> > > We can avoid doing a memset in swap_cgroup_swapon() by using vzalloc().
> > >
> > >
> > > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
> >
> > There are so many placed need vzalloc.
> > Thanks, Jesper.
>
> Yes, please check memcontrol.c as well
>
I will shortly, I'm slowly working my way through a mountain of code
checking for this. I'll get to memcontrol.c

>
> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
>
Thanks.

--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containe rs
Previous Topic: Re: [PATCH v4 11/11] memcg: check memcg dirty limits in page writeback
Next Topic: [PATCH] cgroup: prefer [kv]zalloc over [kv]malloc+memset in memory controller code.
Goto Forum:
  


Current Time: Thu Mar 30 12:10:56 GMT 2023

Total time taken to generate the page: 0.01044 seconds