diff mbox series

[v2,07/13] mm: thp: make split queue lock safe when LRU pages reparented

Message ID 20210916134748.67712-8-songmuchun@bytedance.com (mailing list archive)
State New
Headers show
Series Use obj_cgroup APIs to charge the LRU pages | expand

Commit Message

Muchun Song Sept. 16, 2021, 1:47 p.m. UTC
Similar to lruvec lock, we use the same approach to make the split
queue lock safe when LRU pages reparented.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 mm/huge_memory.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

kernel test robot Sept. 17, 2021, 6:38 a.m. UTC | #1
Hi Muchun,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tj-cgroup/for-next]
[also build test WARNING on linus/master v5.15-rc1]
[cannot apply to hnaz-mm/master next-20210916]
[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/Muchun-Song/Use-obj_cgroup-APIs-to-charge-the-LRU-pages/20210916-215452
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next
config: x86_64-randconfig-m001-20210916 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/938e77565fc42d6c0d53b0470d75b4055200afe1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Muchun-Song/Use-obj_cgroup-APIs-to-charge-the-LRU-pages/20210916-215452
        git checkout 938e77565fc42d6c0d53b0470d75b4055200afe1
        # save the attached .config to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

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

All warnings (new ones prefixed by >>):

   mm/huge_memory.c:516:1: error: expected identifier or '(' before '+' token
     516 | +static inline struct mem_cgroup *split_queue_memcg(struct deferred_split *queue)
         | ^
   In file included from include/asm-generic/bug.h:5,
                    from arch/x86/include/asm/bug.h:84,
                    from include/linux/bug.h:5,
                    from include/linux/mmdebug.h:5,
                    from include/linux/mm.h:9,
                    from mm/huge_memory.c:8:
   mm/huge_memory.c: In function 'split_queue_lock':
   mm/huge_memory.c:543:15: error: implicit declaration of function 'split_queue_memcg'; did you mean 'split_queue_lock'? [-Werror=implicit-function-declaration]
     543 |  if (unlikely(split_queue_memcg(queue) != page_memcg(head))) {
         |               ^~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
>> mm/huge_memory.c:543:40: warning: comparison between pointer and integer
     543 |  if (unlikely(split_queue_memcg(queue) != page_memcg(head))) {
         |                                        ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   mm/huge_memory.c: In function 'split_queue_lock_irqsave':
   mm/huge_memory.c:567:40: warning: comparison between pointer and integer
     567 |  if (unlikely(split_queue_memcg(queue) != page_memcg(head))) {
         |                                        ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   mm/huge_memory.c: In function 'deferred_split_huge_page':
   mm/huge_memory.c:2839:8: warning: assignment to 'struct mem_cgroup *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    2839 |  memcg = split_queue_memcg(ds_queue);
         |        ^
   cc1: some warnings being treated as errors


vim +543 mm/huge_memory.c

   533	
   534	static struct deferred_split *split_queue_lock(struct page *head)
   535	{
   536		struct deferred_split *queue;
   537	
   538		rcu_read_lock();
   539	retry:
   540		queue = page_split_queue(head);
   541		spin_lock(&queue->split_queue_lock);
   542	
 > 543		if (unlikely(split_queue_memcg(queue) != page_memcg(head))) {
   544			spin_unlock(&queue->split_queue_lock);
   545			goto retry;
   546		}
   547	
   548		/*
   549		 * Preemption is disabled in the internal of spin_lock, which can serve
   550		 * as RCU read-side critical sections.
   551		 */
   552		rcu_read_unlock();
   553	
   554		return queue;
   555	}
   556	

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

Patch

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 9d8dfa82991a..12950d4988e6 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -535,9 +535,22 @@  static struct deferred_split *split_queue_lock(struct page *head)
 {
 	struct deferred_split *queue;
 
+	rcu_read_lock();
+retry:
 	queue = page_split_queue(head);
 	spin_lock(&queue->split_queue_lock);
 
+	if (unlikely(split_queue_memcg(queue) != page_memcg(head))) {
+		spin_unlock(&queue->split_queue_lock);
+		goto retry;
+	}
+
+	/*
+	 * Preemption is disabled in the internal of spin_lock, which can serve
+	 * as RCU read-side critical sections.
+	 */
+	rcu_read_unlock();
+
 	return queue;
 }
 
@@ -546,9 +559,19 @@  split_queue_lock_irqsave(struct page *head, unsigned long *flags)
 {
 	struct deferred_split *queue;
 
+	rcu_read_lock();
+retry:
 	queue = page_split_queue(head);
 	spin_lock_irqsave(&queue->split_queue_lock, *flags);
 
+	if (unlikely(split_queue_memcg(queue) != page_memcg(head))) {
+		spin_unlock_irqrestore(&queue->split_queue_lock, *flags);
+		goto retry;
+	}
+
+	/* See the comments in split_queue_lock(). */
+	rcu_read_unlock();
+
 	return queue;
 }