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]
Message-ID: <Y8oqEOICcNV762IA@casper.infradead.org>
Date:   Fri, 20 Jan 2023 05:43:44 +0000
From:   Matthew Wilcox <willy@...radead.org>
To:     Sidhartha Kumar <sidhartha.kumar@...cle.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        akpm@...ux-foundation.org, songmuchun@...edance.com,
        mike.kravetz@...cle.com, jhubbard@...dia.com
Subject: Re: [PATCH 2/9] mm/hugetlb: convert hugetlbfs_pagecache_present() to
 folios

On Thu, Jan 19, 2023 at 01:14:39PM -0800, Sidhartha Kumar wrote:
> +++ b/mm/hugetlb.c
> @@ -5653,15 +5653,15 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
>  {
>  	struct address_space *mapping;
>  	pgoff_t idx;
> -	struct page *page;
> +	struct folio *folio;
>  
>  	mapping = vma->vm_file->f_mapping;
>  	idx = vma_hugecache_offset(h, vma, address);
>  
> -	page = find_get_page(mapping, idx);
> -	if (page)
> -		put_page(page);
> -	return page != NULL;
> +	folio = filemap_get_folio(mapping, idx);
> +	if (folio)
> +		folio_put(folio);
> +	return folio != NULL;
>  }

Seems to me this function could be ...

	struct address_space *mapping = vma->vm_file->f_mapping;
	pgoff_t index = vma_hugecache_offset(h, vma, address);
	bool present;

	rcu_read_lock();
	present = page_cache_next_miss(mapping, index, 1) != index;
	rcu_read_unlock();

	return present;

No need to get/drop a refcount on the folio.  It's a bit similar to
filemap_range_has_page(), but the API is wrong.  Maybe there's room
for a little refactoring here.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ