lkml.org 
[lkml]   [2012]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC v2] Add mempressure cgroup
On Mon, Dec 10, 2012 at 01:23:09PM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Monday 10 December 2012 10:58:38 Anton Vorontsov wrote:
>
> > +static void consume_memory(void)
> > +{
> > + unsigned int i = 0;
> > + unsigned int j = 0;
> > +
> > + puts("consuming memory...");
> > +
> > + while (1) {
> > + pthread_mutex_lock(&locks[i]);
> > + if (!chunks[i]) {
> > + chunks[i] = malloc(CHUNK_SIZE);
> > + pabort(!chunks[i], 0, "chunks alloc failed");
> > + memset(chunks[i], 0, CHUNK_SIZE);
> > + j++;
> > + }
> > + pthread_mutex_unlock(&locks[i]);
> > +
> > + if (j >= num_chunks / 10) {
> > + add_reclaimable(num_chunks / 10);
>
> Shouldn't it use j instead of num_chunks / 10 here?

Um.. They should be equal. Or am I missing the point?

> > + printf("added %d reclaimable chunks\n", j);
> > + j = 0;

Here, we reset it.

> > + }
> > +
> > + i = (i + 1) % num_chunks;
> > + }
> > +}

Thanks!
Anton.


\
 
 \ /
  Last update: 2012-12-10 21:41    [W:0.944 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site