CC: l...@lists.linux.dev
CC: kbuild-...@lists.01.org
BCC: l...@intel.com
CC: linux-ker...@vger.kernel.org
TO: "Kirill A. Shutemov" <kirill.shute...@linux.intel.com>

tree:   https://github.com/intel/tdx.git guest-unaccepted-memory
head:   83a8442434ff3bbf432df7508f1fefd447ca2c86
commit: 0845556ccd9555f5245d3bdd6cb646c2ea3fa9c2 [3/15] mm: Add support for 
unaccepted memory
:::::: branch date: 4 days ago
:::::: commit date: 9 days ago
config: x86_64-randconfig-c007 
(https://download.01.org/0day-ci/archive/20220515/202205150421.5zbu2z3i-...@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
38189438b69ca27b4c6ce707c52dbd217583d046)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # 
https://github.com/intel/tdx/commit/0845556ccd9555f5245d3bdd6cb646c2ea3fa9c2
        git remote add intel-tdx https://github.com/intel/tdx.git
        git fetch --no-tags intel-tdx guest-unaccepted-memory
        git checkout 0845556ccd9555f5245d3bdd6cb646c2ea3fa9c2
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
   19 warnings generated.
   Suppressed 19 warnings (19 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   25 warnings generated.
   Suppressed 25 warnings (25 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   25 warnings generated.
   Suppressed 25 warnings (25 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   55 warnings generated.
   drivers/clk/clk.c:1972:3: warning: Value stored to 'best_parent_rate' is 
never read [clang-analyzer-deadcode.DeadStores]
                   best_parent_rate = parent->rate;
                   ^                  ~~~~~~~~~~~~
   drivers/clk/clk.c:1972:3: note: Value stored to 'best_parent_rate' is never 
read
                   best_parent_rate = parent->rate;
                   ^                  ~~~~~~~~~~~~
   drivers/clk/clk.c:2793:3: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(&core->duty, &core->parent->duty, sizeof(core->duty));
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   drivers/clk/clk.c:2793:3: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
                   memcpy(&core->duty, &core->parent->duty, sizeof(core->duty));
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   drivers/clk/clk.c:2821:3: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(&core->duty, duty, sizeof(*duty));
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   drivers/clk/clk.c:2821:3: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
                   memcpy(&core->duty, duty, sizeof(*duty));
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   drivers/clk/clk.c:2836:3: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(&core->duty, &core->parent->duty, sizeof(core->duty));
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   drivers/clk/clk.c:2836:3: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
                   memcpy(&core->duty, &core->parent->duty, sizeof(core->duty));
                   ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   Suppressed 51 warnings (51 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   45 warnings generated.
   Suppressed 45 warnings (45 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   64 warnings generated.
>> mm/page_alloc.c:1183:6: warning: Branch condition evaluates to a garbage 
>> value [clang-analyzer-core.uninitialized.Branch]
           if (!page_needs_acceptance && (fpi_flags & FPI_UNACCEPTED_SLOWPATH))
               ^
   mm/page_alloc.c:8453:2: note: Calling 'drain_pages'
           drain_pages(cpu);
           ^~~~~~~~~~~~~~~~
   mm/page_alloc.c:3211:2: note: Loop condition is true.  Entering loop body
           for_each_populated_zone(zone) {
           ^
   include/linux/mmzone.h:1145:2: note: expanded from macro 
'for_each_populated_zone'
           for (zone = (first_online_pgdat())->node_zones; \
           ^
   mm/page_alloc.c:3211:2: note: Assuming the condition is false
           for_each_populated_zone(zone) {
           ^
   include/linux/mmzone.h:1148:7: note: expanded from macro 
'for_each_populated_zone'
                   if (!populated_zone(zone))              \
                       ^~~~~~~~~~~~~~~~~~~~~
   mm/page_alloc.c:3211:2: note: Taking false branch
           for_each_populated_zone(zone) {
           ^
   include/linux/mmzone.h:1148:3: note: expanded from macro 
'for_each_populated_zone'
                   if (!populated_zone(zone))              \
                   ^
   mm/page_alloc.c:3212:3: note: Calling 'drain_pages_zone'
                   drain_pages_zone(cpu, zone);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/page_alloc.c:3191:2: note: Loop condition is false.  Exiting loop
           local_lock_irqsave(&pagesets.lock, flags);
           ^
   include/linux/local_lock.h:31:2: note: expanded from macro 
'local_lock_irqsave'
           __local_lock_irqsave(lock, flags)
           ^
   include/linux/local_lock_internal.h:79:3: note: expanded from macro 
'__local_lock_irqsave'
                   local_irq_save(flags);                          \
                   ^
   include/linux/irqflags.h:221:3: note: expanded from macro 'local_irq_save'
                   raw_local_irq_save(flags);              \
                   ^
   include/linux/irqflags.h:176:2: note: expanded from macro 
'raw_local_irq_save'
           do {                                            \
           ^
   mm/page_alloc.c:3191:2: note: Taking true branch
           local_lock_irqsave(&pagesets.lock, flags);
           ^
   include/linux/local_lock.h:31:2: note: expanded from macro 
'local_lock_irqsave'
           __local_lock_irqsave(lock, flags)
           ^
   include/linux/local_lock_internal.h:79:3: note: expanded from macro 
'__local_lock_irqsave'
                   local_irq_save(flags);                          \
                   ^
   include/linux/irqflags.h:222:3: note: expanded from macro 'local_irq_save'
                   if (!raw_irqs_disabled_flags(flags))    \
                   ^
   mm/page_alloc.c:3191:2: note: Loop condition is false.  Exiting loop
           local_lock_irqsave(&pagesets.lock, flags);
           ^
   include/linux/local_lock.h:31:2: note: expanded from macro 
'local_lock_irqsave'
           __local_lock_irqsave(lock, flags)
           ^
   include/linux/local_lock_internal.h:79:3: note: expanded from macro 
'__local_lock_irqsave'
                   local_irq_save(flags);                          \
                   ^
   include/linux/irqflags.h:220:2: note: expanded from macro 'local_irq_save'
           do {                                            \
           ^
   mm/page_alloc.c:3191:2: note: Loop condition is false.  Exiting loop
           local_lock_irqsave(&pagesets.lock, flags);
           ^
   include/linux/local_lock.h:31:2: note: expanded from macro 
'local_lock_irqsave'
           __local_lock_irqsave(lock, flags)
           ^
   include/linux/local_lock_internal.h:80:22: note: expanded from macro 
'__local_lock_irqsave'
                   local_lock_acquire(this_cpu_ptr(lock));         \
                                      ^
   include/linux/percpu-defs.h:252:27: note: expanded from macro 'this_cpu_ptr'
   #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
                             ^
   include/linux/percpu-defs.h:241:2: note: expanded from macro 'raw_cpu_ptr'
           __verify_pcpu_ptr(ptr);                                         \
           ^
   include/linux/percpu-defs.h:217:37: note: expanded from macro 
'__verify_pcpu_ptr'
   #define __verify_pcpu_ptr(ptr)                                          \
                                                                           ^
   mm/page_alloc.c:3191:2: note: Loop condition is false.  Exiting loop
           local_lock_irqsave(&pagesets.lock, flags);
           ^
   include/linux/local_lock.h:31:2: note: expanded from macro 
'local_lock_irqsave'
           __local_lock_irqsave(lock, flags)
           ^
   include/linux/local_lock_internal.h:78:2: note: expanded from macro 
'__local_lock_irqsave'
           do {                                                    \
           ^
   mm/page_alloc.c:3193:8: note: Loop condition is false.  Exiting loop
           pcp = per_cpu_ptr(zone->per_cpu_pageset, cpu);
                 ^
   include/linux/percpu-defs.h:235:2: note: expanded from macro 'per_cpu_ptr'
           __verify_pcpu_ptr(ptr);                                         \
           ^
   include/linux/percpu-defs.h:217:37: note: expanded from macro 
'__verify_pcpu_ptr'
   #define __verify_pcpu_ptr(ptr)                                          \

vim +1183 mm/page_alloc.c

0845556ccd9555f Kirill A. Shutemov      2021-08-25  1056  
^1da177e4c3f415 Linus Torvalds          2005-04-16  1057  /*
^1da177e4c3f415 Linus Torvalds          2005-04-16  1058   * Freeing function 
for a buddy system allocator.
^1da177e4c3f415 Linus Torvalds          2005-04-16  1059   *
^1da177e4c3f415 Linus Torvalds          2005-04-16  1060   * The concept of a 
buddy system is to maintain direct-mapped table
^1da177e4c3f415 Linus Torvalds          2005-04-16  1061   * (containing bit 
values) for memory blocks of various "orders".
^1da177e4c3f415 Linus Torvalds          2005-04-16  1062   * The bottom level 
table contains the map for the smallest allocatable
^1da177e4c3f415 Linus Torvalds          2005-04-16  1063   * units of memory 
(here, pages), and each level above it describes
^1da177e4c3f415 Linus Torvalds          2005-04-16  1064   * pairs of units 
from the levels below, hence, "buddies".
^1da177e4c3f415 Linus Torvalds          2005-04-16  1065   * At a high level, 
all that happens here is marking the table entry
^1da177e4c3f415 Linus Torvalds          2005-04-16  1066   * at the bottom 
level available, and propagating the changes upward
^1da177e4c3f415 Linus Torvalds          2005-04-16  1067   * as necessary, plus 
some accounting needed to play nicely with other
^1da177e4c3f415 Linus Torvalds          2005-04-16  1068   * parts of the VM 
system.
^1da177e4c3f415 Linus Torvalds          2005-04-16  1069   * At each level, we 
keep a list of pages, which are heads of continuous
6e292b9be7f4358 Matthew Wilcox          2018-06-07  1070   * free pages of 
length of (1 << order) and marked with PageBuddy.
6e292b9be7f4358 Matthew Wilcox          2018-06-07  1071   * Page's order is 
recorded in page_private(page) field.
^1da177e4c3f415 Linus Torvalds          2005-04-16  1072   * So when we are 
allocating or freeing one, we can derive the state of the
^1da177e4c3f415 Linus Torvalds          2005-04-16  1073   * other.  That is, 
if we allocate a small block, and both were
^1da177e4c3f415 Linus Torvalds          2005-04-16  1074   * free, the 
remainder of the region must be split into blocks.
^1da177e4c3f415 Linus Torvalds          2005-04-16  1075   * If a block is 
freed, and its buddy is also free, then this
^1da177e4c3f415 Linus Torvalds          2005-04-16  1076   * triggers 
coalescing into a block of larger size.
^1da177e4c3f415 Linus Torvalds          2005-04-16  1077   *
6d49e352ae9aed3 Nadia Yvette Chambers   2012-12-06  1078   * -- nyc
^1da177e4c3f415 Linus Torvalds          2005-04-16  1079   */
^1da177e4c3f415 Linus Torvalds          2005-04-16  1080  
48db57f8ff10eb0 Nicholas Piggin         2006-01-08  1081  static inline void 
__free_one_page(struct page *page,
dc4b0caff24d9b2 Mel Gorman              2014-06-04  1082                
unsigned long pfn,
ed0ae21dc5fe3b9 Mel Gorman              2009-06-16  1083                struct 
zone *zone, unsigned int order,
f04a5d5d913fa81 David Hildenbrand       2020-10-15  1084                int 
migratetype, fpi_t fpi_flags)
^1da177e4c3f415 Linus Torvalds          2005-04-16  1085  {
a2129f24798a993 Alexander Duyck         2020-04-06  1086        struct 
capture_control *capc = task_capc(zone);
b3d40a2b6d10c9d David Hildenbrand       2022-03-22  1087        unsigned int 
max_order = pageblock_order;
3f649ab728cda80 Kees Cook               2020-06-03  1088        unsigned long 
buddy_pfn;
a2129f24798a993 Alexander Duyck         2020-04-06  1089        unsigned long 
combined_pfn;
a2129f24798a993 Alexander Duyck         2020-04-06  1090        struct page 
*buddy;
a2129f24798a993 Alexander Duyck         2020-04-06  1091        bool to_tail;
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1092        bool 
page_needs_acceptance;
d9dddbf556674bf Vlastimil Babka         2016-03-25  1093  
d29bb9782d22063 Cody P Schafer          2013-02-22  1094        
VM_BUG_ON(!zone_is_initialized(zone));
6e9f0d582dde095 Kirill A. Shutemov      2015-02-11  1095        
VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page);
^1da177e4c3f415 Linus Torvalds          2005-04-16  1096  
ed0ae21dc5fe3b9 Mel Gorman              2009-06-16  1097        
VM_BUG_ON(migratetype == -1);
d9dddbf556674bf Vlastimil Babka         2016-03-25  1098        if 
(likely(!is_migrate_isolate(migratetype)))
8f82b55dd558a74 Joonsoo Kim             2014-11-13  1099                
__mod_zone_freepage_state(zone, 1 << order, migratetype);
ed0ae21dc5fe3b9 Mel Gorman              2009-06-16  1100  
76741e776a37973 Vlastimil Babka         2017-02-22  1101        
VM_BUG_ON_PAGE(pfn & ((1 << order) - 1), page);
309381feaee5642 Sasha Levin             2014-01-23  1102        
VM_BUG_ON_PAGE(bad_range(zone, page), page);
^1da177e4c3f415 Linus Torvalds          2005-04-16  1103  
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1104        if 
(PageUnaccepted(page)) {
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1105                
page_needs_acceptance = true;
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1106                
__ClearPageUnaccepted(page);
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1107        }
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1108  
d9dddbf556674bf Vlastimil Babka         2016-03-25  1109  continue_merging:
7ad69832f37e3ce Muchun Song             2020-12-14  1110        while (order < 
max_order) {
5e1f0f098b4649f Mel Gorman              2019-03-05  1111                if 
(compaction_capture(capc, page, order, migratetype)) {
5e1f0f098b4649f Mel Gorman              2019-03-05  1112                        
__mod_zone_freepage_state(zone, -(1 << order),
5e1f0f098b4649f Mel Gorman              2019-03-05  1113                        
                                        migratetype);
5e1f0f098b4649f Mel Gorman              2019-03-05  1114                        
return;
5e1f0f098b4649f Mel Gorman              2019-03-05  1115                }
76741e776a37973 Vlastimil Babka         2017-02-22  1116                
buddy_pfn = __find_buddy_pfn(pfn, order);
76741e776a37973 Vlastimil Babka         2017-02-22  1117                buddy = 
page + (buddy_pfn - pfn);
13ad59df67f1978 Vlastimil Babka         2017-02-22  1118  
cb2b95e1c6b56e3 Andy Whitcroft          2006-06-23  1119                if 
(!page_is_buddy(page, buddy, order))
d9dddbf556674bf Vlastimil Babka         2016-03-25  1120                        
goto done_merging;
c0a32fc5a2e470d Stanislaw Gruszka       2012-01-10  1121                /*
c0a32fc5a2e470d Stanislaw Gruszka       2012-01-10  1122                 * Our 
buddy is free or it is CONFIG_DEBUG_PAGEALLOC guard page,
c0a32fc5a2e470d Stanislaw Gruszka       2012-01-10  1123                 * 
merge with it and move up one order.
c0a32fc5a2e470d Stanislaw Gruszka       2012-01-10  1124                 */
b03641af680959d Dan Williams            2019-05-14  1125                if 
(page_is_guard(buddy))
2847cf95c68fa5f Joonsoo Kim             2014-12-12  1126                        
clear_page_guard(zone, buddy, order, migratetype);
b03641af680959d Dan Williams            2019-05-14  1127                else
6ab0136310961eb Alexander Duyck         2020-04-06  1128                        
del_page_from_free_list(buddy, zone, order);
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1129  
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1130                /* Mark 
page unaccepted if any of merged pages were unaccepted */
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1131                if 
(PageUnaccepted(buddy)) {
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1132                        
page_needs_acceptance = true;
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1133                        
__ClearPageUnaccepted(buddy);
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1134                }
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1135  
76741e776a37973 Vlastimil Babka         2017-02-22  1136                
combined_pfn = buddy_pfn & pfn;
76741e776a37973 Vlastimil Babka         2017-02-22  1137                page = 
page + (combined_pfn - pfn);
76741e776a37973 Vlastimil Babka         2017-02-22  1138                pfn = 
combined_pfn;
^1da177e4c3f415 Linus Torvalds          2005-04-16  1139                order++;
^1da177e4c3f415 Linus Torvalds          2005-04-16  1140        }
7ad69832f37e3ce Muchun Song             2020-12-14  1141        if (order < 
MAX_ORDER - 1) {
d9dddbf556674bf Vlastimil Babka         2016-03-25  1142                /* If 
we are here, it means order is >= pageblock_order.
1dd214b8f21ca46 Zi Yan                  2022-03-22  1143                 * We 
want to prevent merge between freepages on pageblock
1dd214b8f21ca46 Zi Yan                  2022-03-22  1144                 * 
without fallbacks and normal pageblock. Without this,
1dd214b8f21ca46 Zi Yan                  2022-03-22  1145                 * 
pageblock isolation could cause incorrect freepage or CMA
1dd214b8f21ca46 Zi Yan                  2022-03-22  1146                 * 
accounting or HIGHATOMIC accounting.
d9dddbf556674bf Vlastimil Babka         2016-03-25  1147                 *
d9dddbf556674bf Vlastimil Babka         2016-03-25  1148                 * We 
don't want to hit this code for the more frequent
d9dddbf556674bf Vlastimil Babka         2016-03-25  1149                 * 
low-order merging.
d9dddbf556674bf Vlastimil Babka         2016-03-25  1150                 */
d9dddbf556674bf Vlastimil Babka         2016-03-25  1151                int 
buddy_mt;
d9dddbf556674bf Vlastimil Babka         2016-03-25  1152  
76741e776a37973 Vlastimil Babka         2017-02-22  1153                
buddy_pfn = __find_buddy_pfn(pfn, order);
76741e776a37973 Vlastimil Babka         2017-02-22  1154                buddy = 
page + (buddy_pfn - pfn);
787af64d05cd528 Zi Yan                  2022-03-30  1155  
787af64d05cd528 Zi Yan                  2022-03-30  1156                if 
(!page_is_buddy(page, buddy, order))
787af64d05cd528 Zi Yan                  2022-03-30  1157                        
goto done_merging;
d9dddbf556674bf Vlastimil Babka         2016-03-25  1158                
buddy_mt = get_pageblock_migratetype(buddy);
d9dddbf556674bf Vlastimil Babka         2016-03-25  1159  
d9dddbf556674bf Vlastimil Babka         2016-03-25  1160                if 
(migratetype != buddy_mt
1dd214b8f21ca46 Zi Yan                  2022-03-22  1161                        
        && (!migratetype_is_mergeable(migratetype) ||
1dd214b8f21ca46 Zi Yan                  2022-03-22  1162                        
                !migratetype_is_mergeable(buddy_mt)))
d9dddbf556674bf Vlastimil Babka         2016-03-25  1163                        
goto done_merging;
7ad69832f37e3ce Muchun Song             2020-12-14  1164                
max_order = order + 1;
d9dddbf556674bf Vlastimil Babka         2016-03-25  1165                goto 
continue_merging;
d9dddbf556674bf Vlastimil Babka         2016-03-25  1166        }
d9dddbf556674bf Vlastimil Babka         2016-03-25  1167  
d9dddbf556674bf Vlastimil Babka         2016-03-25  1168  done_merging:
ab130f9108dcf20 Matthew Wilcox (Oracle  2020-10-15  1169)       
set_buddy_order(page, order);
6dda9d55bf54501 Corrado Zoccolo         2010-05-24  1170  
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1171        /*
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1172         * The page 
gets marked as PageUnaccepted() if any of merged-in pages
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1173         * is 
PageUnaccepted().
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1174         *
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1175         * New pages, 
just being added to buddy allocator, do not have
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1176         * 
PageUnaccepted() set. FPI_UNACCEPTED_SLOWPATH indicates that the
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1177         * page is new 
and page_is_unaccepted() check is required to
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1178         * determinate 
if acceptance is required.
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1179         *
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1180         * Avoid 
calling page_is_unaccepted() if it is known that the page
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1181         * needs 
acceptance. It can be costly.
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1182         */
0845556ccd9555f Kirill A. Shutemov      2021-08-25 @1183        if 
(!page_needs_acceptance && (fpi_flags & FPI_UNACCEPTED_SLOWPATH))
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1184                
page_needs_acceptance = page_is_unaccepted(page, order);
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1185        if 
(page_needs_acceptance)
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1186                
__SetPageUnaccepted(page);
0845556ccd9555f Kirill A. Shutemov      2021-08-25  1187  
47b6a24a23825ae David Hildenbrand       2020-10-15  1188        if (fpi_flags & 
FPI_TO_TAIL)
47b6a24a23825ae David Hildenbrand       2020-10-15  1189                to_tail 
= true;
47b6a24a23825ae David Hildenbrand       2020-10-15  1190        else if 
(is_shuffle_order(order))
a2129f24798a993 Alexander Duyck         2020-04-06  1191                to_tail 
= shuffle_pick_tail();
97500a4a54876d3 Dan Williams            2019-05-14  1192        else
a2129f24798a993 Alexander Duyck         2020-04-06  1193                to_tail 
= buddy_merge_likely(pfn, buddy_pfn, page, order);
97500a4a54876d3 Dan Williams            2019-05-14  1194  
a2129f24798a993 Alexander Duyck         2020-04-06  1195        if (to_tail)
6ab0136310961eb Alexander Duyck         2020-04-06  1196                
add_to_free_list_tail(page, zone, order, migratetype);
a2129f24798a993 Alexander Duyck         2020-04-06  1197        else
6ab0136310961eb Alexander Duyck         2020-04-06  1198                
add_to_free_list(page, zone, order, migratetype);
36e66c554b5c6a9 Alexander Duyck         2020-04-06  1199  
36e66c554b5c6a9 Alexander Duyck         2020-04-06  1200        /* Notify page 
reporting subsystem of freed page */
f04a5d5d913fa81 David Hildenbrand       2020-10-15  1201        if (!(fpi_flags 
& FPI_SKIP_REPORT_NOTIFY))
36e66c554b5c6a9 Alexander Duyck         2020-04-06  1202                
page_reporting_notify_free(order);
^1da177e4c3f415 Linus Torvalds          2005-04-16  1203  }
^1da177e4c3f415 Linus Torvalds          2005-04-16  1204  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to