Re: [RFC v2] Add mempressure cgroup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

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

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung Poland R&D Center

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]