public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Charan Teja Kalla <quic_charante@quicinc.com>,
	"Christian Brauner (Microsoft)" <brauner@kernel.org>,
	Giuseppe Scrivano <gscrivan@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the mm tree with Linus' tree
Date: Sat, 25 Feb 2023 10:39:51 +1100	[thread overview]
Message-ID: <20230225103951.59997ec3@canb.auug.org.au> (raw)

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

Hi all,

Today's linux-next merge of the mm tree got a conflict in:

  mm/shmem.c

between commit:

  7a80e5b8c6fa ("shmem: support idmapped mounts for tmpfs")

from Linus' tree and commit:

  9323c8b93d95 ("mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem")

from the mm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc mm/shmem.c
index 448f393d8ab2,31bd5e1f9faa..000000000000
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@@ -2344,9 -2347,120 +2347,121 @@@ static void shmem_set_inode_flags(struc
  #define shmem_initxattrs NULL
  #endif
  
+ static void shmem_isolate_pages_range(struct address_space *mapping, loff_t start,
+ 				loff_t end, struct list_head *list)
+ {
+ 	XA_STATE(xas, &mapping->i_pages, start);
+ 	struct folio *folio;
+ 
+ 	rcu_read_lock();
+ 	xas_for_each(&xas, folio, end) {
+ 		if (xas_retry(&xas, folio))
+ 			continue;
+ 		if (xa_is_value(folio))
+ 			continue;
+ 
+ 		if (!folio_try_get(folio))
+ 			continue;
+ 		if (folio_test_unevictable(folio) || folio_mapped(folio) ||
+ 				folio_isolate_lru(folio)) {
+ 			folio_put(folio);
+ 			continue;
+ 		}
+ 		folio_put(folio);
+ 
+ 		/*
+ 		 * Prepare the folios to be passed to reclaim_pages().
+ 		 * VM can't reclaim a folio unless young bit is
+ 		 * cleared in its flags.
+ 		 */
+ 		folio_clear_referenced(folio);
+ 		folio_test_clear_young(folio);
+ 		list_add(&folio->lru, list);
+ 		if (need_resched()) {
+ 			xas_pause(&xas);
+ 			cond_resched_rcu();
+ 		}
+ 	}
+ 	rcu_read_unlock();
+ }
+ 
+ static int shmem_fadvise_dontneed(struct address_space *mapping, loff_t start,
+ 				loff_t end)
+ {
+ 	LIST_HEAD(folio_list);
+ 
+ 	if (!total_swap_pages || mapping_unevictable(mapping))
+ 		return 0;
+ 
+ 	lru_add_drain();
+ 	shmem_isolate_pages_range(mapping, start, end, &folio_list);
+ 	reclaim_pages(&folio_list);
+ 
+ 	return 0;
+ }
+ 
+ static int shmem_fadvise_willneed(struct address_space *mapping,
+ 				 pgoff_t start, pgoff_t long end)
+ {
+ 	struct folio *folio;
+ 	pgoff_t index;
+ 
+ 	xa_for_each_range(&mapping->i_pages, index, folio, start, end) {
+ 		if (!xa_is_value(folio))
+ 			continue;
+ 		folio = shmem_read_folio(mapping, index);
+ 		if (!IS_ERR(folio))
+ 			folio_put(folio);
+ 	}
+ 
+ 	return 0;
+ }
+ 
+ static int shmem_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
+ {
+ 	loff_t endbyte;
+ 	pgoff_t start_index;
+ 	pgoff_t end_index;
+ 	struct address_space *mapping;
+ 	struct inode *inode = file_inode(file);
+ 	int ret = 0;
+ 
+ 	if (S_ISFIFO(inode->i_mode))
+ 		return -ESPIPE;
+ 
+ 	mapping = file->f_mapping;
+ 	if (!mapping || len < 0 || !shmem_mapping(mapping))
+ 		return -EINVAL;
+ 
+ 	endbyte = fadvise_calc_endbyte(offset, len);
+ 
+ 	start_index = offset >> PAGE_SHIFT;
+ 	end_index   = endbyte >> PAGE_SHIFT;
+ 	switch (advice) {
+ 	case POSIX_FADV_DONTNEED:
+ 		ret = shmem_fadvise_dontneed(mapping, start_index, end_index);
+ 		break;
+ 	case POSIX_FADV_WILLNEED:
+ 		ret = shmem_fadvise_willneed(mapping, start_index, end_index);
+ 		break;
+ 	case POSIX_FADV_NORMAL:
+ 	case POSIX_FADV_RANDOM:
+ 	case POSIX_FADV_SEQUENTIAL:
+ 	case POSIX_FADV_NOREUSE:
+ 		/*
+ 		 * No bad return value, but ignore advice.
+ 		 */
+ 		break;
+ 	default:
+ 		return -EINVAL;
+ 	}
+ 
+ 	return ret;
+ }
+ 
 -static struct inode *shmem_get_inode(struct super_block *sb, struct inode *dir,
 -				     umode_t mode, dev_t dev, unsigned long flags)
 +static struct inode *shmem_get_inode(struct mnt_idmap *idmap, struct super_block *sb,
 +				     struct inode *dir, umode_t mode, dev_t dev,
 +				     unsigned long flags)
  {
  	struct inode *inode;
  	struct shmem_inode_info *info;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2023-02-24 23:40 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 23:39 Stephen Rothwell [this message]
2023-02-25  2:04 ` linux-next: manual merge of the mm tree with Linus' tree Andrew Morton
2023-02-25  7:13   ` Christian Brauner
2023-02-25 20:52     ` Andrew Morton
2023-02-27 10:18       ` Christian Brauner
2023-02-27 17:55         ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2025-02-09 22:39 Stephen Rothwell
2024-09-29 23:56 Stephen Rothwell
2024-09-30  6:01 ` Miguel Ojeda
2024-09-16 23:27 Stephen Rothwell
2024-09-17 23:40 ` Stephen Rothwell
2024-09-09  0:00 Stephen Rothwell
2024-09-09  1:53 ` Huang, Ying
2024-09-17 23:36 ` Stephen Rothwell
2024-07-28 22:41 Stephen Rothwell
2024-07-28 22:45 ` Stephen Rothwell
2024-07-28 23:31   ` Andrew Morton
2024-05-09 23:22 Stephen Rothwell
2023-07-27 23:18 Stephen Rothwell
2023-07-27 23:29 ` Stephen Rothwell
2023-07-27 23:40   ` Suren Baghdasaryan
2023-07-27 23:50     ` Matthew Wilcox
2023-07-28  0:08       ` Suren Baghdasaryan
2023-07-28  0:00   ` Stephen Rothwell
2023-07-28  3:13     ` Matthew Wilcox
2023-07-27 23:49 ` Matthew Wilcox
2023-07-28  0:21   ` Stephen Rothwell
2023-07-28  0:23     ` Suren Baghdasaryan
2023-07-28  0:29       ` Stephen Rothwell
2023-07-28  0:30         ` Suren Baghdasaryan
2023-07-06 22:54 Stephen Rothwell
2023-07-07  4:52 ` Baoquan He
2023-06-18 23:23 Stephen Rothwell
2023-06-19 20:25 ` Andrew Morton
2023-06-19 20:43 ` Will Deacon
2023-06-19 21:39   ` Andrew Morton
2023-06-20  9:43     ` Will Deacon
2023-06-20 15:00       ` Jain, Ayush
2022-11-07  2:52 Stephen Rothwell
2022-09-06  9:01 Stephen Rothwell
2022-09-06  9:21 ` Rolf Eike Beer
2022-05-26  6:09 Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230225103951.59997ec3@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=gscrivan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=quic_charante@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox