Re: [PATCH] mm: optimize memory allocation

From: kernel test robot
Date: Mon Apr 12 2021 - 07:29:20 EST


Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.12-rc7]
[cannot apply to hnaz-linux-mm/master next-20210409]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/ultrachin-163-com/mm-optimize-memory-allocation/20210412-155259
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 5e46d1b78a03d52306f21f77a4e4a144b6d31486
config: openrisc-randconfig-r032-20210412 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0
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/0day-ci/linux/commit/6994280da115271cf4083439e5d4dcdb3ce00720
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review ultrachin-163-com/mm-optimize-memory-allocation/20210412-155259
git checkout 6994280da115271cf4083439e5d4dcdb3ce00720
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=openrisc

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

mm/page_alloc.c:3605:15: warning: no previous prototype for 'should_fail_alloc_page' [-Wmissing-prototypes]
3605 | noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
| ^~~~~~~~~~~~~~~~~~~~~~
mm/page_alloc.c: In function '__alloc_pages_nodemask':
mm/page_alloc.c:4992:10: error: implicit declaration of function 'get_mem_cgroup_from_current'; did you mean 'get_mem_cgroup_from_mm'? [-Werror=implicit-function-declaration]
4992 | memcg = get_mem_cgroup_from_current();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| get_mem_cgroup_from_mm
mm/page_alloc.c:4992:8: warning: assignment to 'struct mem_cgroup *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
4992 | memcg = get_mem_cgroup_from_current();
| ^
>> mm/page_alloc.c:4996:18: error: dereferencing pointer to incomplete type 'struct mem_cgroup'
4996 | css_put(&memcg->css);
| ^~
>> mm/page_alloc.c:5035:7: error: 'struct page' has no member named 'memcg_data'
5035 | page->memcg_data = (unsigned long)memcg | MEMCG_DATA_KMEM;
| ^~
>> mm/page_alloc.c:5035:45: error: 'MEMCG_DATA_KMEM' undeclared (first use in this function)
5035 | page->memcg_data = (unsigned long)memcg | MEMCG_DATA_KMEM;
| ^~~~~~~~~~~~~~~
mm/page_alloc.c:5035:45: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors


vim +4996 mm/page_alloc.c

4967
4968 /*
4969 * This is the 'heart' of the zoned buddy allocator.
4970 */
4971 struct page *
4972 __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,
4973 nodemask_t *nodemask)
4974 {
4975 struct page *page;
4976 unsigned int alloc_flags = ALLOC_WMARK_LOW;
4977 gfp_t alloc_mask; /* The gfp_t that was actually used for allocation */
4978 struct alloc_context ac = { };
4979 struct mem_cgroup *memcg;
4980 bool charged = false;
4981
4982 /*
4983 * There are several places where we assume that the order value is sane
4984 * so bail out early if the request is out of bound.
4985 */
4986 if (unlikely(order >= MAX_ORDER)) {
4987 WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
4988 return NULL;
4989 }
4990
4991 gfp_mask &= gfp_allowed_mask;
> 4992 memcg = get_mem_cgroup_from_current();
4993 if (memcg && memcg_kmem_enabled() && (gfp_mask & __GFP_ACCOUNT) &&
4994 !mem_cgroup_is_root(memcg)) {
4995 if (unlikely(__memcg_kmem_charge_page(memcg, gfp_mask, order) != 0)) {
> 4996 css_put(&memcg->css);
4997 return NULL;
4998 }
4999 charged = true;
5000 }
5001 alloc_mask = gfp_mask;
5002 if (!prepare_alloc_pages(gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags))
5003 return NULL;
5004
5005 /*
5006 * Forbid the first pass from falling back to types that fragment
5007 * memory until all local zones are considered.
5008 */
5009 alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone, gfp_mask);
5010
5011 /* First allocation attempt */
5012 page = get_page_from_freelist(alloc_mask, order, alloc_flags, &ac);
5013 if (likely(page))
5014 goto out;
5015
5016 /*
5017 * Apply scoped allocation constraints. This is mainly about GFP_NOFS
5018 * resp. GFP_NOIO which has to be inherited for all allocation requests
5019 * from a particular context which has been marked by
5020 * memalloc_no{fs,io}_{save,restore}.
5021 */
5022 alloc_mask = current_gfp_context(gfp_mask);
5023 ac.spread_dirty_pages = false;
5024
5025 /*
5026 * Restore the original nodemask if it was potentially replaced with
5027 * &cpuset_current_mems_allowed to optimize the fast-path attempt.
5028 */
5029 ac.nodemask = nodemask;
5030
5031 page = __alloc_pages_slowpath(alloc_mask, order, &ac);
5032
5033 out:
5034 if (page && charged)
> 5035 page->memcg_data = (unsigned long)memcg | MEMCG_DATA_KMEM;
5036 else if (charged)
5037 __memcg_kmem_uncharge_page(NULL, order, memcg);
5038
5039 trace_mm_page_alloc(page, order, alloc_mask, ac.migratetype);
5040
5041 return page;
5042 }
5043 EXPORT_SYMBOL(__alloc_pages_nodemask);
5044

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip