[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YajJqY2ByC8uwa46@casper.infradead.org>
Date: Thu, 2 Dec 2021 13:27:05 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Charan Teja Reddy <quic_charante@...cinc.com>
Cc: hughd@...gle.com, akpm@...ux-foundation.org, vbabka@...e.cz,
rientjes@...gle.com, david@...hat.com, mhocko@...e.com,
surenb@...gle.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Charan Teja Reddy <charante@...eaurora.org>
Subject: Re: [PATCH v2] mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for
shmem
On Thu, Dec 02, 2021 at 04:20:53PM +0530, Charan Teja Reddy wrote:
> +static int shmem_fadvise_willneed(struct address_space *mapping,
> + pgoff_t start, pgoff_t long end)
> +{
> + XA_STATE(xas, &mapping->i_pages, start);
> + struct page *page;
> +
> + rcu_read_lock();
> + page = xas_find(&xas, end);
> + rcu_read_unlock();
> +
> + while (page) {
> + if (xa_is_value(page)) {
> + page = shmem_read_mapping_page(mapping, xas.xa_index);
> + if (!IS_ERR(page))
> + put_page(page);
> + }
> +
> + if (need_resched()) {
> + xas_pause(&xas);
> + cond_resched();
> + }
> +
> + rcu_read_lock();
> + page = xas_next_entry(&xas, end);
> + rcu_read_unlock();
> + }
> +
> + return 0;
> +}
What part of the XArray documentation led you to believe that this is a
safe thing to do? Because it needs to be rewritten immediately!
Powered by blists - more mailing lists