lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 02 Feb 2011 15:58:48 +0100
From:	"Michal Nazarewicz" <mina86@...a86.com>
To:	"Michal Nazarewicz" <m.nazarewicz@...sung.com>,
	"Ankita Garg" <ankita@...ibm.com>
Cc:	"Andrew Morton" <akpm@...ux-foundation.org>,
	"Daniel Walker" <dwalker@...eaurora.org>,
	"Johan MOSSBERG" <johan.xx.mossberg@...ricsson.com>,
	"KAMEZAWA Hiroyuki" <kamezawa.hiroyu@...fujitsu.com>,
	"Marek Szyprowski" <m.szyprowski@...sung.com>,
	"Mel Gorman" <mel@....ul.ie>, linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
	linux-mm@...ck.org
Subject: Re: [PATCHv8 07/12] mm: cma: Contiguous Memory Allocator added

> On Wed, Dec 15, 2010 at 09:34:27PM +0100, Michal Nazarewicz wrote:
>> +unsigned long cma_reserve(unsigned long start, unsigned long size,
>> +			  unsigned long alignment)
>> +{
>> +	pr_debug("%s(%p+%p/%p)\n", __func__, (void *)start, (void *)size,
>> +		 (void *)alignment);
>> +
>> +	/* Sanity checks */
>> +	if (!size || (alignment & (alignment - 1)))
>> +		return (unsigned long)-EINVAL;
>> +
>> +	/* Sanitise input arguments */
>> +	start = PAGE_ALIGN(start);
>> +	size  = PAGE_ALIGN(size);
>> +	if (alignment < PAGE_SIZE)
>> +		alignment = PAGE_SIZE;
>> +
>> +	/* Reserve memory */
>> +	if (start) {
>> +		if (memblock_is_region_reserved(start, size) ||
>> +		    memblock_reserve(start, size) < 0)
>> +			return (unsigned long)-EBUSY;
>> +	} else {
>> +		/*
>> +		 * Use __memblock_alloc_base() since
>> +		 * memblock_alloc_base() panic()s.
>> +		 */
>> +		u64 addr = __memblock_alloc_base(size, alignment, 0);
>> +		if (!addr) {
>> +			return (unsigned long)-ENOMEM;
>> +		} else if (addr + size > ~(unsigned long)0) {
>> +			memblock_free(addr, size);
>> +			return (unsigned long)-EOVERFLOW;
>> +		} else {
>> +			start = addr;
>> +		}
>> +	}
>> +

On Wed, 02 Feb 2011 13:43:33 +0100, Ankita Garg <ankita@...ibm.com> wrote:
> Reserving the areas of memory belonging to CMA using memblock_reserve,
> would preclude that range from the zones, due to which it would not be
> available for buddy allocations right ?

Correct.  CMA however, injects allocated pageblocks to buddy so they end
up in buddy with migratetype set to MIGRATE_CMA.

>> +	return start;
>> +}

-- 
Best regards,                                       _     _
.o. | Liege of Serenly Enlightened Majesty of     o' \,=./ `o
..o | Computer Science,  Michal "mina86" Nazarewicz  (o o)
ooo +-<email/jid: mnazarewicz@...gle.com>--------ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ