All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mm/damon: Add access checking for hugetlb pages
@ 2021-12-16 10:38 Baolin Wang
  2021-12-22  9:10 ` SeongJae Park
  0 siblings, 1 reply; 4+ messages in thread
From: Baolin Wang @ 2021-12-16 10:38 UTC (permalink / raw)
  To: sj, akpm; +Cc: baolin.wang, mike.kravetz, linux-mm, linux-kernel

The process's VMAs can be mapped by hugetlb page, but now the DAMON
did not implement the access checking for hugetlb pte, so we can not
get the actual access count like below if a process VMAs were mapped
by hugetlb.

damon_aggregated: target_id=18446614368406014464
nr_regions=12 4194304-5476352: 0 545
damon_aggregated: target_id=18446614368406014464
nr_regions=12 140662370467840-140662372970496: 0 545
damon_aggregated: target_id=18446614368406014464
nr_regions=12 140662372970496-140662375460864: 0 545
damon_aggregated: target_id=18446614368406014464
nr_regions=12 140662375460864-140662377951232: 0 545
damon_aggregated: target_id=18446614368406014464
nr_regions=12 140662377951232-140662380449792: 0 545
damon_aggregated: target_id=18446614368406014464
nr_regions=12 140662380449792-140662382944256: 0 545
......

Thus this patch adds hugetlb access checking support, with this patch
we can see below VMA mapped by hugetlb access count.

damon_aggregated: target_id=18446613056935405824
nr_regions=12 140296486649856-140296489914368: 1 3
damon_aggregated: target_id=18446613056935405824
nr_regions=12 140296489914368-140296492978176: 1 3
damon_aggregated: target_id=18446613056935405824
nr_regions=12 140296492978176-140296495439872: 1 3
damon_aggregated: target_id=18446613056935405824
nr_regions=12 140296495439872-140296498311168: 1 3
damon_aggregated: target_id=18446613056935405824
nr_regions=12 140296498311168-140296501198848: 1 3
damon_aggregated: target_id=18446613056935405824
nr_regions=12 140296501198848-140296504320000: 1 3
damon_aggregated: target_id=18446613056935405824
nr_regions=12 140296504320000-140296507568128: 1 2
......

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
Changes from v1:
 - Move damon_hugetlb_mkold() to vaddr.c file.
 - Move some assignments in the variables definitions.
---
 mm/damon/vaddr.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 78ff2bc..69c436b 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -386,8 +386,65 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
 	return 0;
 }
 
+#ifdef CONFIG_HUGETLB_PAGE
+static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
+				struct vm_area_struct *vma, unsigned long addr)
+{
+	bool referenced = false;
+	struct hstate *h = hstate_vma(vma);
+	pte_t entry = huge_ptep_get(pte);
+	struct page *page = pte_page(entry);
+
+	if (!page)
+		return;
+
+	get_page(page);
+
+	if (pte_young(entry)) {
+		referenced = true;
+		entry = pte_mkold(entry);
+		huge_ptep_set_access_flags(vma, addr, pte, entry,
+					   vma->vm_flags & VM_WRITE);
+	}
+
+#ifdef CONFIG_MMU_NOTIFIER
+	if (mmu_notifier_clear_young(mm, addr, addr + huge_page_size(h)))
+		referenced = true;
+#endif /* CONFIG_MMU_NOTIFIER */
+
+	if (referenced)
+		set_page_young(page);
+
+	set_page_idle(page);
+	put_page(page);
+}
+
+static int damon_mkold_hugetlb_entry(pte_t *pte, unsigned long hmask,
+				     unsigned long addr, unsigned long end,
+				     struct mm_walk *walk)
+{
+	struct hstate *h = hstate_vma(walk->vma);
+	spinlock_t *ptl;
+	pte_t entry;
+
+	ptl = huge_pte_lock(h, walk->mm, pte);
+	entry = huge_ptep_get(pte);
+	if (!pte_present(entry))
+		goto out;
+
+	damon_hugetlb_mkold(pte, walk->mm, walk->vma, addr);
+
+out:
+	spin_unlock(ptl);
+	return 0;
+}
+#else
+#define damon_mkold_hugetlb_entry NULL
+#endif
+
 static const struct mm_walk_ops damon_mkold_ops = {
 	.pmd_entry = damon_mkold_pmd_entry,
+	.hugetlb_entry = damon_mkold_hugetlb_entry,
 };
 
 static void damon_va_mkold(struct mm_struct *mm, unsigned long addr)
@@ -482,8 +539,47 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
 	return 0;
 }
 
+#ifdef CONFIG_HUGETLB_PAGE
+static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask,
+				     unsigned long addr, unsigned long end,
+				     struct mm_walk *walk)
+{
+	struct damon_young_walk_private *priv = walk->private;
+	struct hstate *h = hstate_vma(walk->vma);
+	struct page *page;
+	spinlock_t *ptl;
+	pte_t entry;
+
+	ptl = huge_pte_lock(h, walk->mm, pte);
+	entry = huge_ptep_get(pte);
+	if (!pte_present(entry))
+		goto out;
+
+	page = pte_page(entry);
+	if (!page)
+		goto out;
+
+	get_page(page);
+
+	if (pte_young(entry) || !page_is_idle(page) ||
+	    mmu_notifier_test_young(walk->mm, addr)) {
+		*priv->page_sz = huge_page_size(h);
+		priv->young = true;
+	}
+
+	put_page(page);
+
+out:
+	spin_unlock(ptl);
+	return 0;
+}
+#else
+#define damon_young_hugetlb_entry NULL
+#endif
+
 static const struct mm_walk_ops damon_young_ops = {
 	.pmd_entry = damon_young_pmd_entry,
+	.hugetlb_entry = damon_young_hugetlb_entry,
 };
 
 static bool damon_va_young(struct mm_struct *mm, unsigned long addr,
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/damon: Add access checking for hugetlb pages
  2021-12-16 10:38 [PATCH v2] mm/damon: Add access checking for hugetlb pages Baolin Wang
@ 2021-12-22  9:10 ` SeongJae Park
  2021-12-22  9:32   ` Baolin Wang
  0 siblings, 1 reply; 4+ messages in thread
From: SeongJae Park @ 2021-12-22  9:10 UTC (permalink / raw)
  To: Baolin Wang; +Cc: sj, akpm, mike.kravetz, linux-mm, linux-kernel

Hi Baolin,


Basically, the code looks ok to me.  I left so trivial cosmetic nitpicks below,
though.

On Thu, 16 Dec 2021 18:38:03 +0800 Baolin Wang <baolin.wang@linux.alibaba.com> wrote:

> The process's VMAs can be mapped by hugetlb page, but now the DAMON
> did not implement the access checking for hugetlb pte, so we can not
> get the actual access count like below if a process VMAs were mapped
> by hugetlb.
> 
> damon_aggregated: target_id=18446614368406014464
> nr_regions=12 4194304-5476352: 0 545
> damon_aggregated: target_id=18446614368406014464
> nr_regions=12 140662370467840-140662372970496: 0 545
> damon_aggregated: target_id=18446614368406014464
> nr_regions=12 140662372970496-140662375460864: 0 545
> damon_aggregated: target_id=18446614368406014464
> nr_regions=12 140662375460864-140662377951232: 0 545
> damon_aggregated: target_id=18446614368406014464
> nr_regions=12 140662377951232-140662380449792: 0 545
> damon_aggregated: target_id=18446614368406014464
> nr_regions=12 140662380449792-140662382944256: 0 545
> ......

I'd prefer indenting the program output with 4 spaces and not wrapping it.
e.g.,

    damon_aggregated: target_id=18446614368406014464 nr_regions=12 4194304-5476352: 0 545
    damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662370467840-140662372970496: 0 545


> 
> Thus this patch adds hugetlb access checking support, with this patch
> we can see below VMA mapped by hugetlb access count.
> 
> damon_aggregated: target_id=18446613056935405824
> nr_regions=12 140296486649856-140296489914368: 1 3
> damon_aggregated: target_id=18446613056935405824
> nr_regions=12 140296489914368-140296492978176: 1 3
> damon_aggregated: target_id=18446613056935405824
> nr_regions=12 140296492978176-140296495439872: 1 3
> damon_aggregated: target_id=18446613056935405824
> nr_regions=12 140296495439872-140296498311168: 1 3
> damon_aggregated: target_id=18446613056935405824
> nr_regions=12 140296498311168-140296501198848: 1 3
> damon_aggregated: target_id=18446613056935405824
> nr_regions=12 140296501198848-140296504320000: 1 3
> damon_aggregated: target_id=18446613056935405824
> nr_regions=12 140296504320000-140296507568128: 1 2
> ......

ditto.

> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
> Changes from v1:
>  - Move damon_hugetlb_mkold() to vaddr.c file.
>  - Move some assignments in the variables definitions.
> ---
>  mm/damon/vaddr.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 96 insertions(+)
> 
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 78ff2bc..69c436b 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -386,8 +386,65 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr,
>  	return 0;
>  }
>  
> +#ifdef CONFIG_HUGETLB_PAGE
> +static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
> +				struct vm_area_struct *vma, unsigned long addr)
> +{
> +	bool referenced = false;
> +	struct hstate *h = hstate_vma(vma);
> +	pte_t entry = huge_ptep_get(pte);
> +	struct page *page = pte_page(entry);
> +
> +	if (!page)
> +		return;
> +
> +	get_page(page);
> +
> +	if (pte_young(entry)) {
> +		referenced = true;
> +		entry = pte_mkold(entry);
> +		huge_ptep_set_access_flags(vma, addr, pte, entry,
> +					   vma->vm_flags & VM_WRITE);
> +	}
> +
> +#ifdef CONFIG_MMU_NOTIFIER
> +	if (mmu_notifier_clear_young(mm, addr, addr + huge_page_size(h)))
> +		referenced = true;
> +#endif /* CONFIG_MMU_NOTIFIER */
> +
> +	if (referenced)
> +		set_page_young(page);
> +
> +	set_page_idle(page);
> +	put_page(page);
> +}
> +
> +static int damon_mkold_hugetlb_entry(pte_t *pte, unsigned long hmask,
> +				     unsigned long addr, unsigned long end,
> +				     struct mm_walk *walk)
> +{
> +	struct hstate *h = hstate_vma(walk->vma);
> +	spinlock_t *ptl;
> +	pte_t entry;
> +
> +	ptl = huge_pte_lock(h, walk->mm, pte);
> +	entry = huge_ptep_get(pte);
> +	if (!pte_present(entry))
> +		goto out;
> +
> +	damon_hugetlb_mkold(pte, walk->mm, walk->vma, addr);
> +
> +out:
> +	spin_unlock(ptl);
> +	return 0;
> +}
> +#else
> +#define damon_mkold_hugetlb_entry NULL
> +#endif

Could we append a comment saying this #endif is for #ifdef CONFIG_HUGETLB_PAGE,
like below?

    #endif	/* CONFIG_HUGETLB_PAGE */

> +
>  static const struct mm_walk_ops damon_mkold_ops = {
>  	.pmd_entry = damon_mkold_pmd_entry,
> +	.hugetlb_entry = damon_mkold_hugetlb_entry,
>  };
>  
>  static void damon_va_mkold(struct mm_struct *mm, unsigned long addr)
> @@ -482,8 +539,47 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
>  	return 0;
>  }
>  
> +#ifdef CONFIG_HUGETLB_PAGE
> +static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask,
> +				     unsigned long addr, unsigned long end,
> +				     struct mm_walk *walk)
> +{
> +	struct damon_young_walk_private *priv = walk->private;
> +	struct hstate *h = hstate_vma(walk->vma);
> +	struct page *page;
> +	spinlock_t *ptl;
> +	pte_t entry;
> +
> +	ptl = huge_pte_lock(h, walk->mm, pte);
> +	entry = huge_ptep_get(pte);
> +	if (!pte_present(entry))
> +		goto out;
> +
> +	page = pte_page(entry);
> +	if (!page)
> +		goto out;
> +
> +	get_page(page);
> +
> +	if (pte_young(entry) || !page_is_idle(page) ||
> +	    mmu_notifier_test_young(walk->mm, addr)) {
> +		*priv->page_sz = huge_page_size(h);
> +		priv->young = true;
> +	}
> +
> +	put_page(page);
> +
> +out:
> +	spin_unlock(ptl);
> +	return 0;
> +}
> +#else
> +#define damon_young_hugetlb_entry NULL
> +#endif

ditto.

> +
>  static const struct mm_walk_ops damon_young_ops = {
>  	.pmd_entry = damon_young_pmd_entry,
> +	.hugetlb_entry = damon_young_hugetlb_entry,
>  };
>  
>  static bool damon_va_young(struct mm_struct *mm, unsigned long addr,
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/damon: Add access checking for hugetlb pages
  2021-12-22  9:10 ` SeongJae Park
@ 2021-12-22  9:32   ` Baolin Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Baolin Wang @ 2021-12-22  9:32 UTC (permalink / raw)
  To: SeongJae Park; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel



On 12/22/2021 5:10 PM, SeongJae Park wrote:
> Hi Baolin,
> 
> 
> Basically, the code looks ok to me.  I left so trivial cosmetic nitpicks below,
> though.
> 
> On Thu, 16 Dec 2021 18:38:03 +0800 Baolin Wang <baolin.wang@linux.alibaba.com> wrote:
> 
>> The process's VMAs can be mapped by hugetlb page, but now the DAMON
>> did not implement the access checking for hugetlb pte, so we can not
>> get the actual access count like below if a process VMAs were mapped
>> by hugetlb.
>>
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 4194304-5476352: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662370467840-140662372970496: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662372970496-140662375460864: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662375460864-140662377951232: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662377951232-140662380449792: 0 545
>> damon_aggregated: target_id=18446614368406014464
>> nr_regions=12 140662380449792-140662382944256: 0 545
>> ......
> 
> I'd prefer indenting the program output with 4 spaces and not wrapping it.
> e.g.,
> 
>      damon_aggregated: target_id=18446614368406014464 nr_regions=12 4194304-5476352: 0 545
>      damon_aggregated: target_id=18446614368406014464 nr_regions=12 140662370467840-140662372970496: 0 545

Sure.

>>
>> Thus this patch adds hugetlb access checking support, with this patch
>> we can see below VMA mapped by hugetlb access count.
>>
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296486649856-140296489914368: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296489914368-140296492978176: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296492978176-140296495439872: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296495439872-140296498311168: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296498311168-140296501198848: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296501198848-140296504320000: 1 3
>> damon_aggregated: target_id=18446613056935405824
>> nr_regions=12 140296504320000-140296507568128: 1 2
>> ......
> 
> ditto.

Sure.

>> +static int damon_mkold_hugetlb_entry(pte_t *pte, unsigned long hmask,
>> +				     unsigned long addr, unsigned long end,
>> +				     struct mm_walk *walk)
>> +{
>> +	struct hstate *h = hstate_vma(walk->vma);
>> +	spinlock_t *ptl;
>> +	pte_t entry;
>> +
>> +	ptl = huge_pte_lock(h, walk->mm, pte);
>> +	entry = huge_ptep_get(pte);
>> +	if (!pte_present(entry))
>> +		goto out;
>> +
>> +	damon_hugetlb_mkold(pte, walk->mm, walk->vma, addr);
>> +
>> +out:
>> +	spin_unlock(ptl);
>> +	return 0;
>> +}
>> +#else
>> +#define damon_mkold_hugetlb_entry NULL
>> +#endif
> 
> Could we append a comment saying this #endif is for #ifdef CONFIG_HUGETLB_PAGE,
> like below?
> 
>      #endif	/* CONFIG_HUGETLB_PAGE */

Sure.

>> +#ifdef CONFIG_HUGETLB_PAGE
>> +static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask,
>> +				     unsigned long addr, unsigned long end,
>> +				     struct mm_walk *walk)
>> +{
>> +	struct damon_young_walk_private *priv = walk->private;
>> +	struct hstate *h = hstate_vma(walk->vma);
>> +	struct page *page;
>> +	spinlock_t *ptl;
>> +	pte_t entry;
>> +
>> +	ptl = huge_pte_lock(h, walk->mm, pte);
>> +	entry = huge_ptep_get(pte);
>> +	if (!pte_present(entry))
>> +		goto out;
>> +
>> +	page = pte_page(entry);
>> +	if (!page)
>> +		goto out;
>> +
>> +	get_page(page);
>> +
>> +	if (pte_young(entry) || !page_is_idle(page) ||
>> +	    mmu_notifier_test_young(walk->mm, addr)) {
>> +		*priv->page_sz = huge_page_size(h);
>> +		priv->young = true;
>> +	}
>> +
>> +	put_page(page);
>> +
>> +out:
>> +	spin_unlock(ptl);
>> +	return 0;
>> +}
>> +#else
>> +#define damon_young_hugetlb_entry NULL
>> +#endif
> 
> ditto.

Sure.

But I saw Andrew had applied this version into his branch.

Andrew, would you like me to send a new version? or an increment patch 
to fix the coding style issue? Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/damon: Add access checking for hugetlb pages
@ 2021-12-29  3:02 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-12-29  3:02 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 17121 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <6afcbd1fda5f9c7c24f320d26a98188c727ceec3.1639623751.git.baolin.wang@linux.alibaba.com>
References: <6afcbd1fda5f9c7c24f320d26a98188c727ceec3.1639623751.git.baolin.wang@linux.alibaba.com>
TO: Baolin Wang <baolin.wang@linux.alibaba.com>

Hi Baolin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on hnaz-mm/master]

url:    https://github.com/0day-ci/linux/commits/Baolin-Wang/mm-damon-Add-access-checking-for-hugetlb-pages/20211216-183925
base:   https://github.com/hnaz/linux-mm master
:::::: branch date: 13 days ago
:::::: commit date: 13 days ago
config: riscv-randconfig-c006-20211228 (https://download.01.org/0day-ci/archive/20211229/202112291022.Ut97ZGZm-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 7171af744543433ac75b232eb7dfdaef7efd4d7a)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/468a013161dfcf6a8631ea645ea9e1ec461d7c59
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Baolin-Wang/mm-damon-Add-access-checking-for-hugetlb-pages/20211216-183925
        git checkout 468a013161dfcf6a8631ea645ea9e1ec461d7c59
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
   drivers/mtd/ubi/build.c:643:7: note: Calling 'is_power_of_2'
           if (!is_power_of_2(ubi->min_io_size)) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/log2.h:47:10: note: Assuming 'n' is not equal to 0
           return (n != 0 && ((n & (n - 1)) == 0));
                   ^~~~~~
   include/linux/log2.h:47:10: note: Left side of '&&' is true
   include/linux/log2.h:47:21: note: Assuming the condition is true
           return (n != 0 && ((n & (n - 1)) == 0));
                              ^~~~~~~~~~~~~~~~~~
   include/linux/log2.h:47:2: note: Returning the value 1, which participates in a condition later
           return (n != 0 && ((n & (n - 1)) == 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/mtd/ubi/build.c:643:7: note: Returning from 'is_power_of_2'
           if (!is_power_of_2(ubi->min_io_size)) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/mtd/ubi/build.c:643:2: note: Taking false branch
           if (!is_power_of_2(ubi->min_io_size)) {
           ^
   drivers/mtd/ubi/build.c:649:13: note: Assuming field 'hdrs_min_io_size' is <= 0
           ubi_assert(ubi->hdrs_min_io_size > 0);
                      ^
   drivers/mtd/ubi/debug.h:18:17: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             \
                          ^~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/mtd/ubi/build.c:649:2: note: Taking true branch
           ubi_assert(ubi->hdrs_min_io_size > 0);
           ^
   drivers/mtd/ubi/debug.h:18:2: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             \
           ^
   drivers/mtd/ubi/build.c:649:2: note: Loop condition is false.  Exiting loop
           ubi_assert(ubi->hdrs_min_io_size > 0);
           ^
   drivers/mtd/ubi/debug.h:19:3: note: expanded from macro 'ubi_assert'
                   pr_crit("UBI assert failed in %s at %u (pid %d)\n",          \
                   ^
   include/linux/printk.h:479:2: note: expanded from macro 'pr_crit'
           printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:446:26: note: expanded from macro 'printk'
   #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
                            ^
   include/linux/printk.h:417:3: note: expanded from macro 'printk_index_wrap'
                   __printk_index_emit(_fmt, NULL, NULL);                  \
                   ^
   include/linux/printk.h:392:34: note: expanded from macro '__printk_index_emit'
   #define __printk_index_emit(...) do {} while (0)
                                    ^
   drivers/mtd/ubi/build.c:649:2: note: Loop condition is false.  Exiting loop
           ubi_assert(ubi->hdrs_min_io_size > 0);
           ^
   drivers/mtd/ubi/debug.h:17:27: note: expanded from macro 'ubi_assert'
   #define ubi_assert(expr)  do {                                               \
                             ^
   drivers/mtd/ubi/build.c:650:18: note: Field 'hdrs_min_io_size' is <= field 'min_io_size'
           ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size);
                           ^
   drivers/mtd/ubi/build.c:650:2: note: Taking false branch
           ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size);
           ^
   drivers/mtd/ubi/debug.h:18:2: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             \
           ^
   drivers/mtd/ubi/build.c:650:2: note: Loop condition is false.  Exiting loop
           ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size);
           ^
   drivers/mtd/ubi/debug.h:17:27: note: expanded from macro 'ubi_assert'
   #define ubi_assert(expr)  do {                                               \
                             ^
   drivers/mtd/ubi/build.c:651:30: note: Division by zero
           ubi_assert(ubi->min_io_size % ubi->hdrs_min_io_size == 0);
                                       ^
   drivers/mtd/ubi/debug.h:18:17: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             \
                          ^~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/mtd/ubi/build.c:1401:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(buf, val);
           ^~~~~~
   drivers/mtd/ubi/build.c:1401:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
           strcpy(buf, val);
           ^~~~~~
   drivers/mtd/ubi/build.c:1416:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(&p->name[0], tokens[0]);
           ^~~~~~
   drivers/mtd/ubi/build.c:1416:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
           strcpy(&p->name[0], tokens[0]);
           ^~~~~~
   Suppressed 2 warnings (2 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   5 warnings generated.
>> mm/damon/vaddr.c:402:17: warning: Value stored to 'h' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct hstate *h = hstate_vma(vma);
                          ^   ~~~~~~~~~~~~~~~
   mm/damon/vaddr.c:402:17: note: Value stored to 'h' during its initialization is never read
           struct hstate *h = hstate_vma(vma);
                          ^   ~~~~~~~~~~~~~~~
   Suppressed 4 warnings (3 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   mm/memfd.c:281:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(name, MFD_NAME_PREFIX);
           ^~~~~~
   mm/memfd.c:281:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
           strcpy(name, MFD_NAME_PREFIX);
           ^~~~~~
   Suppressed 3 warnings (3 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.
   2 warnings generated.
   Suppressed 2 warnings (2 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.
   2 warnings generated.
   Suppressed 2 warnings (2 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.
   2 warnings generated.
   Suppressed 2 warnings (2 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   4 warnings generated.
   drivers/gpu/drm/nouveau/nouveau_bo0039.c:55:6: warning: Value stored to 'page_count' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           u32 page_count = new_reg->num_pages;
               ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/nouveau/nouveau_bo0039.c:55:6: note: Value stored to 'page_count' during its initialization is never read
           u32 page_count = new_reg->num_pages;
               ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   3 warnings generated.
   Suppressed 3 warnings (3 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.
   6 warnings generated.
   drivers/usb/chipidea/otg_fsm.c:42:2: warning: Value stored to 'next' is never read [clang-analyzer-deadcode.DeadStores]
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:42:2: note: Value stored to 'next' is never read
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:91:2: warning: Value stored to 'next' is never read [clang-analyzer-deadcode.DeadStores]
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:91:2: note: Value stored to 'next' is never read
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:131:2: warning: Value stored to 'next' is never read [clang-analyzer-deadcode.DeadStores]
           next += t;

vim +/h +402 mm/damon/vaddr.c

3f49584b262cf8 SeongJae Park 2021-09-07  396  
468a013161dfcf Baolin Wang   2021-12-16  397  #ifdef CONFIG_HUGETLB_PAGE
468a013161dfcf Baolin Wang   2021-12-16  398  static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
468a013161dfcf Baolin Wang   2021-12-16  399  				struct vm_area_struct *vma, unsigned long addr)
468a013161dfcf Baolin Wang   2021-12-16  400  {
468a013161dfcf Baolin Wang   2021-12-16  401  	bool referenced = false;
468a013161dfcf Baolin Wang   2021-12-16 @402  	struct hstate *h = hstate_vma(vma);
468a013161dfcf Baolin Wang   2021-12-16  403  	pte_t entry = huge_ptep_get(pte);
468a013161dfcf Baolin Wang   2021-12-16  404  	struct page *page = pte_page(entry);
468a013161dfcf Baolin Wang   2021-12-16  405  
468a013161dfcf Baolin Wang   2021-12-16  406  	if (!page)
468a013161dfcf Baolin Wang   2021-12-16  407  		return;
468a013161dfcf Baolin Wang   2021-12-16  408  
468a013161dfcf Baolin Wang   2021-12-16  409  	get_page(page);
468a013161dfcf Baolin Wang   2021-12-16  410  
468a013161dfcf Baolin Wang   2021-12-16  411  	if (pte_young(entry)) {
468a013161dfcf Baolin Wang   2021-12-16  412  		referenced = true;
468a013161dfcf Baolin Wang   2021-12-16  413  		entry = pte_mkold(entry);
468a013161dfcf Baolin Wang   2021-12-16  414  		huge_ptep_set_access_flags(vma, addr, pte, entry,
468a013161dfcf Baolin Wang   2021-12-16  415  					   vma->vm_flags & VM_WRITE);
468a013161dfcf Baolin Wang   2021-12-16  416  	}
468a013161dfcf Baolin Wang   2021-12-16  417  

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-29  3:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 10:38 [PATCH v2] mm/damon: Add access checking for hugetlb pages Baolin Wang
2021-12-22  9:10 ` SeongJae Park
2021-12-22  9:32   ` Baolin Wang
2021-12-29  3:02 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.