Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1565978 > unrolled thread

[PATCH 06/12] mm: convert page_mkclean_one() to page_check_walk()

Started by"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
First post2017-01-24 17:30 +0100
Last post2017-01-25 02:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 06/12] mm: convert page_mkclean_one() to page_check_walk() "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-01-24 17:30 +0100
    Re: [PATCH 06/12] mm: convert page_mkclean_one() to page_check_walk() kbuild test robot <lkp@intel.com> - 2017-01-25 02:40 +0100

#1565978 — [PATCH 06/12] mm: convert page_mkclean_one() to page_check_walk()

From"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Date2017-01-24 17:30 +0100
Subject[PATCH 06/12] mm: convert page_mkclean_one() to page_check_walk()
Message-ID<t3c8O-6zx-17@gated-at.bofh.it>
For consistency, it worth converting all page_check_address() to
page_check_walk(), so we could drop the former.

PMD handling here is future-proofing, we don't have users yet. ext4 with
huge pages will be the first.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 mm/rmap.c | 66 +++++++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 43 insertions(+), 23 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 3bbf83b32553..41874a6f6cf5 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1017,34 +1017,54 @@ int page_referenced(struct page *page,
 static int page_mkclean_one(struct page *page, struct vm_area_struct *vma,
 			    unsigned long address, void *arg)
 {
-	struct mm_struct *mm = vma->vm_mm;
-	pte_t *pte;
-	spinlock_t *ptl;
-	int ret = 0;
+	struct page_check_walk pcw = {
+		.page = page,
+		.vma = vma,
+		.address = address,
+		.flags = PAGE_CHECK_WALK_SYNC,
+	};
 	int *cleaned = arg;
 
-	pte = page_check_address(page, mm, address, &ptl, 1);
-	if (!pte)
-		goto out;
-
-	if (pte_dirty(*pte) || pte_write(*pte)) {
-		pte_t entry;
+	while (page_check_walk(&pcw)) {
+		int ret = 0;
+		address = pcw.address;
+		if (pcw.pte) {
+			pte_t entry;
+			pte_t *pte = pcw.pte;
+
+			if (!pte_dirty(*pte) && !pte_write(*pte))
+				continue;
+
+			flush_cache_page(vma, address, pte_pfn(*pte));
+			entry = ptep_clear_flush(vma, address, pte);
+			entry = pte_wrprotect(entry);
+			entry = pte_mkclean(entry);
+			set_pte_at(vma->vm_mm, address, pte, entry);
+			ret = 1;
+		} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) {
+			pmd_t *pmd = pcw.pmd;
+			pmd_t entry;
+
+			if (!pmd_dirty(*pmd) && !pmd_write(*pmd))
+				continue;
+
+			flush_cache_page(vma, address, page_to_pfn(page));
+			entry = pmdp_huge_clear_flush(vma, address, pmd);
+			entry = pmd_wrprotect(entry);
+			entry = pmd_mkclean(entry);
+			set_pmd_at(vma->vm_mm, address, pmd, entry);
+			ret = 1;
+		} else {
+			/* unexpected pmd-mapped page? */
+			WARN_ON_ONCE(1);
+		}
 
-		flush_cache_page(vma, address, pte_pfn(*pte));
-		entry = ptep_clear_flush(vma, address, pte);
-		entry = pte_wrprotect(entry);
-		entry = pte_mkclean(entry);
-		set_pte_at(mm, address, pte, entry);
-		ret = 1;
+		if (ret) {
+			mmu_notifier_invalidate_page(vma->vm_mm, address);
+			(*cleaned)++;
+		}
 	}
 
-	pte_unmap_unlock(pte, ptl);
-
-	if (ret) {
-		mmu_notifier_invalidate_page(mm, address);
-		(*cleaned)++;
-	}
-out:
 	return SWAP_AGAIN;
 }
 
-- 
2.11.0

[toc] | [next] | [standalone]


#1566268

Fromkbuild test robot <lkp@intel.com>
Date2017-01-25 02:40 +0100
Message-ID<t3kJ3-3Ay-5@gated-at.bofh.it>
In reply to#1565978

[Multipart message — attachments visible in raw view] — view raw

Hi Kirill,

[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.10-rc5 next-20170124]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Kirill-A-Shutemov/Fix-few-rmap-related-THP-bugs/20170125-081918
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: openrisc-or1ksim_defconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=openrisc 

All errors (new ones prefixed by >>):

   mm/rmap.c: In function 'page_mkclean_one':
   mm/rmap.c:1048:4: error: implicit declaration of function 'pmd_dirty'
   mm/rmap.c:1053:4: error: implicit declaration of function 'pmd_wrprotect'
>> mm/rmap.c:1053:10: error: incompatible types when assigning to type 'pmd_t' from type 'int'
   mm/rmap.c:1054:4: error: implicit declaration of function 'pmd_mkclean'
   mm/rmap.c:1054:10: error: incompatible types when assigning to type 'pmd_t' from type 'int'
   mm/rmap.c:1055:4: error: implicit declaration of function 'set_pmd_at'

vim +1053 mm/rmap.c

  1042				set_pte_at(vma->vm_mm, address, pte, entry);
  1043				ret = 1;
  1044			} else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) {
  1045				pmd_t *pmd = pcw.pmd;
  1046				pmd_t entry;
  1047	
> 1048				if (!pmd_dirty(*pmd) && !pmd_write(*pmd))
  1049					continue;
  1050	
  1051				flush_cache_page(vma, address, page_to_pfn(page));
  1052				entry = pmdp_huge_clear_flush(vma, address, pmd);
> 1053				entry = pmd_wrprotect(entry);
  1054				entry = pmd_mkclean(entry);
  1055				set_pmd_at(vma->vm_mm, address, pmd, entry);
  1056				ret = 1;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web