lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 Mar 2019 15:51:33 -0800
From:   John Hubbard <jhubbard@...dia.com>
To:     Arnd Bergmann <arnd@...db.de>,
        Jérôme Glisse <jglisse@...hat.com>
CC:     Andrew Morton <akpm@...ux-foundation.org>,
        Ralph Campbell <rcampbell@...dia.com>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        Dan Williams <dan.j.williams@...el.com>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm/hmm: fix unused variable warnings

On 3/4/19 12:00 PM, Arnd Bergmann wrote:
> When CONFIG_HUGETLB_PAGE is disabled, the only use of the variable 'h'
> is compiled out, and the compiler thinks it is unnecessary:
> 
> mm/hmm.c: In function 'hmm_range_snapshot':
> mm/hmm.c:1015:19: error: unused variable 'h' [-Werror=unused-variable]
>     struct hstate *h = hstate_vma(vma);
> 
> Rephrase the code to avoid the temporary variable instead, so the
> compiler stops warning.
> 
> Fixes: 5409a90d4212 ("mm/hmm: support hugetlbfs (snapshotting, faulting and DMA mapping)")
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  mm/hmm.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/hmm.c b/mm/hmm.c
> index 3c9781037918..c4beb1628cad 100644
> --- a/mm/hmm.c
> +++ b/mm/hmm.c
> @@ -1012,9 +1012,8 @@ long hmm_range_snapshot(struct hmm_range *range)
>  			return -EFAULT;
>  
>  		if (is_vm_hugetlb_page(vma)) {
> -			struct hstate *h = hstate_vma(vma);
> -
> -			if (huge_page_shift(h) != range->page_shift &&
> +			if (range->page_shift !=
> +				huge_page_shift(hstate_vma(vma)) &&
>  			    range->page_shift != PAGE_SHIFT)
>  				return -EINVAL;
>  		} else {
> @@ -1115,9 +1114,8 @@ long hmm_range_fault(struct hmm_range *range, bool block)
>  			return -EFAULT;
>  
>  		if (is_vm_hugetlb_page(vma)) {
> -			struct hstate *h = hstate_vma(vma);
> -
> -			if (huge_page_shift(h) != range->page_shift &&
> +			if (range->page_shift !=
> +				huge_page_shift(hstate_vma(vma)) &&
>  			    range->page_shift != PAGE_SHIFT)
>  				return -EINVAL;
>  		} else {
> 

Hi Arnd,

With some Kconfig local hacks that removed all HUGE* support, while leaving
HMM enabled, I was able to reproduce your results, and also to verify the
fix. It also makes sense from reading it.

Also, I ran into one more warning as well:

mm/hmm.c: In function ‘hmm_vma_walk_pud’:
mm/hmm.c:764:25: warning: unused variable ‘vma’ [-Wunused-variable]
  struct vm_area_struct *vma = walk->vma;
                         ^~~

...which can be fixed like this:

diff --git a/mm/hmm.c b/mm/hmm.c
index c4beb1628cad..c1cbe82d12b5 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -761,7 +761,6 @@ static int hmm_vma_walk_pud(pud_t *pudp,
 {
        struct hmm_vma_walk *hmm_vma_walk = walk->private;
        struct hmm_range *range = hmm_vma_walk->range;
-       struct vm_area_struct *vma = walk->vma;
        unsigned long addr = start, next;
        pmd_t *pmdp;
        pud_t pud;
@@ -807,7 +806,7 @@ static int hmm_vma_walk_pud(pud_t *pudp,
                return 0;
        }
 
-       split_huge_pud(vma, pudp, addr);
+       split_huge_pud(walk->vma, pudp, addr);
        if (pud_none(*pudp))
                goto again;

...so maybe you'd like to fold that into your patch?



thanks,
-- 
John Hubbard
NVIDIA

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ