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] [thread-next>] [day] [month] [year] [list]
Message-ID: <87r6cvxdd4.fsf@basil.nowhere.org>
Date:	Thu, 24 Apr 2008 21:27:19 +0200
From:	Andi Kleen <andi@...stfloor.org>
To:	Timur Tabi <timur@...escale.com>
Cc:	lkml <linux-kernel@...r.kernel.org>
Subject: Re: Calling free_pages on part of the memory returned by get_free_pages?

Timur Tabi <timur@...escale.com> writes:

> According to LDD3, if I call get_free_pages() to allocate X bytes, I have to
> free all of those pages with free_pages().  The VM internals are a little bit
> over my head, but I looked at the code and I didn't see why that is a requirement.
>
> For example, let's say I want to allocated 6MB of physically-contiguous memory.
>  If I call x = get_free_pages(11) to get 8MB.  What happens if I then do
> "free_pages(x + 6 * 1024 * 1024, 9)"?
>
> I remember doing this on the 2.4 kernel, and it never gave me any problems.

It is ok, as long as you don't use compound pages (__GFP_COMP) and call
split_page() to fix up the reference counts.

Also you do this to save memory right? The large system hash code does it too
and I used to do it in some 2.4 change with an alloc_pages_exact()
which never made it into 2.6.

If it's reasonably common we should re-add alloc/get_pages_exact() helper to 
make this pattern clear and easier to use.

-Andi
--
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