mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
mm: reference totalram_pages and managed_pages once per function
Patch series "mm: convert totalram_pages, totalhigh_pages and managed pages to atomic", v5. This series converts totalram_pages, totalhigh_pages and zone->managed_pages to atomic variables. totalram_pages, zone->managed_pages and totalhigh_pages updates are protected by managed_page_count_lock, but readers never care about it. Convert these variables to atomic to avoid readers potentially seeing a store tear. Main motivation was that managed_page_count_lock handling was complicating things. It was discussed in length here, https://lore.kernel.org/patchwork/patch/995739/#1181785 It seemes better to remove the lock and convert variables to atomic. With the change, preventing poteintial store-to-read tearing comes as a bonus. This patch (of 4): This is in preparation to a later patch which converts totalram_pages and zone->managed_pages to atomic variables. Please note that re-reading the value might lead to a different value and as such it could lead to unexpected behavior. There are no known bugs as a result of the current code but it is better to prevent from them in principle. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arun KS <[email protected]> Reviewed-by: Konstantin Khlebnikov <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Acked-by: Michal Hocko <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Reviewed-by: Pavel Tatashin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
fecd4a50ba
commit
3d6357de8a
12 changed files with 44 additions and 33 deletions
|
|
@ -1090,6 +1090,7 @@ static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)
|
|||
static unsigned long compute_balloon_floor(void)
|
||||
{
|
||||
unsigned long min_pages;
|
||||
unsigned long nr_pages = totalram_pages;
|
||||
#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
|
||||
/* Simple continuous piecewiese linear function:
|
||||
* max MiB -> min MiB gradient
|
||||
|
|
@ -1102,16 +1103,16 @@ static unsigned long compute_balloon_floor(void)
|
|||
* 8192 744 (1/16)
|
||||
* 32768 1512 (1/32)
|
||||
*/
|
||||
if (totalram_pages < MB2PAGES(128))
|
||||
min_pages = MB2PAGES(8) + (totalram_pages >> 1);
|
||||
else if (totalram_pages < MB2PAGES(512))
|
||||
min_pages = MB2PAGES(40) + (totalram_pages >> 2);
|
||||
else if (totalram_pages < MB2PAGES(2048))
|
||||
min_pages = MB2PAGES(104) + (totalram_pages >> 3);
|
||||
else if (totalram_pages < MB2PAGES(8192))
|
||||
min_pages = MB2PAGES(232) + (totalram_pages >> 4);
|
||||
if (nr_pages < MB2PAGES(128))
|
||||
min_pages = MB2PAGES(8) + (nr_pages >> 1);
|
||||
else if (nr_pages < MB2PAGES(512))
|
||||
min_pages = MB2PAGES(40) + (nr_pages >> 2);
|
||||
else if (nr_pages < MB2PAGES(2048))
|
||||
min_pages = MB2PAGES(104) + (nr_pages >> 3);
|
||||
else if (nr_pages < MB2PAGES(8192))
|
||||
min_pages = MB2PAGES(232) + (nr_pages >> 4);
|
||||
else
|
||||
min_pages = MB2PAGES(488) + (totalram_pages >> 5);
|
||||
min_pages = MB2PAGES(488) + (nr_pages >> 5);
|
||||
#undef MB2PAGES
|
||||
return min_pages;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue