* Can the GFP flags to releasepage() be trusted? -- was Re: [PATCH v2 3/8] nfs: Move to using the alternate fallback fscache I/O API [not found] ` <CALF+zO=165sRYRaxPpDS7DaQCpTe-YOa4FamSoMy5FV2uuG5Yg@mail.gmail.com> @ 2021-10-01 14:51 ` David Howells 2021-10-01 15:04 ` Trond Myklebust 2021-10-05 13:15 ` David Howells 0 siblings, 2 replies; 4+ messages in thread From: David Howells @ 2021-10-01 14:51 UTC (permalink / raw) To: Trond Myklebust Cc: dhowells, dwysocha, anna.schumaker, Matthew Wilcox, linux-cachefs, linux-nfs, linux-mm Trond Myklebust <trondmy@hammerspace.com> wrote: > > > @@ -432,7 +432,12 @@ static int nfs_release_page(struct page *page, gfp_t gfp) > > > /* If PagePrivate() is set, then the page is not freeable */ > > > if (PagePrivate(page)) > > > return 0; > > > - return nfs_fscache_release_page(page, gfp); > > > + if (PageFsCache(page)) { > > > + if (!(gfp & __GFP_DIRECT_RECLAIM) || !(gfp & __GFP_FS)) > > > + return false; > > > + wait_on_page_fscache(page); > > > + } > > > + return true; > > > } > > I've found this generally not to be safe. The VM calls ->release_page() > from a variety of contexts, and often fails to report it correctly in > the gfp flags. That's particularly true of the stuff in mm/vmscan.c. > This is why we have the check above that vetos page removal upon > PagePrivate() being set. [Adding Willy and the mm crew to the cc list] I wonder if that matters in this case. In the worst case, we'll wait for the page to cease being DMA'd - but we won't return true if it is. But if vmscan is generating the wrong VM flags, we should look at fixing that. David ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can the GFP flags to releasepage() be trusted? -- was Re: [PATCH v2 3/8] nfs: Move to using the alternate fallback fscache I/O API 2021-10-01 14:51 ` Can the GFP flags to releasepage() be trusted? -- was Re: [PATCH v2 3/8] nfs: Move to using the alternate fallback fscache I/O API David Howells @ 2021-10-01 15:04 ` Trond Myklebust 2021-10-01 19:42 ` Matthew Wilcox 2021-10-05 13:15 ` David Howells 1 sibling, 1 reply; 4+ messages in thread From: Trond Myklebust @ 2021-10-01 15:04 UTC (permalink / raw) To: dhowells Cc: linux-cachefs, linux-mm, linux-nfs, willy, anna.schumaker, dwysocha On Fri, 2021-10-01 at 15:51 +0100, David Howells wrote: > Trond Myklebust <trondmy@hammerspace.com> wrote: > > > > > @@ -432,7 +432,12 @@ static int nfs_release_page(struct page > > > > *page, gfp_t gfp) > > > > /* If PagePrivate() is set, then the page is not > > > > freeable */ > > > > if (PagePrivate(page)) > > > > return 0; > > > > - return nfs_fscache_release_page(page, gfp); > > > > + if (PageFsCache(page)) { > > > > + if (!(gfp & __GFP_DIRECT_RECLAIM) || !(gfp & > > > > __GFP_FS)) > > > > + return false; > > > > + wait_on_page_fscache(page); > > > > + } > > > > + return true; > > > > } > > > > I've found this generally not to be safe. The VM calls - > > >release_page() > > from a variety of contexts, and often fails to report it correctly > > in > > the gfp flags. That's particularly true of the stuff in > > mm/vmscan.c. > > This is why we have the check above that vetos page removal upon > > PagePrivate() being set. > > [Adding Willy and the mm crew to the cc list] > > I wonder if that matters in this case. In the worst case, we'll wait > for the > page to cease being DMA'd - but we won't return true if it is. > > But if vmscan is generating the wrong VM flags, we should look at > fixing that. > > To elaborate a bit: we used to have code here that would check whether the page had been cleaned but was unstable, and if an argument of GFP_KERNEL or above was set, we'd try to call COMMIT to ensure the page was synched to disk on the server (and we'd wait for that call to complete). That code would end up deadlocking in all sorts of horrible ways, so we ended up having to pull it. -- Trond Myklebust Linux NFS client maintainer, Hammerspace trond.myklebust@hammerspace.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can the GFP flags to releasepage() be trusted? -- was Re: [PATCH v2 3/8] nfs: Move to using the alternate fallback fscache I/O API 2021-10-01 15:04 ` Trond Myklebust @ 2021-10-01 19:42 ` Matthew Wilcox 0 siblings, 0 replies; 4+ messages in thread From: Matthew Wilcox @ 2021-10-01 19:42 UTC (permalink / raw) To: Trond Myklebust Cc: dhowells, linux-cachefs, linux-mm, linux-nfs, anna.schumaker, dwysocha On Fri, Oct 01, 2021 at 03:04:08PM +0000, Trond Myklebust wrote: > On Fri, 2021-10-01 at 15:51 +0100, David Howells wrote: > > Trond Myklebust <trondmy@hammerspace.com> wrote: > > > > > > > @@ -432,7 +432,12 @@ static int nfs_release_page(struct page > > > > > *page, gfp_t gfp) > > > > > /* If PagePrivate() is set, then the page is not > > > > > freeable */ > > > > > if (PagePrivate(page)) > > > > > return 0; > > > > > - return nfs_fscache_release_page(page, gfp); > > > > > + if (PageFsCache(page)) { > > > > > + if (!(gfp & __GFP_DIRECT_RECLAIM) || !(gfp & > > > > > __GFP_FS)) > > > > > + return false; > > > > > + wait_on_page_fscache(page); > > > > > + } > > > > > + return true; > > > > > } > > > > > > I've found this generally not to be safe. The VM calls - > > > >release_page() > > > from a variety of contexts, and often fails to report it correctly > > > in > > > the gfp flags. That's particularly true of the stuff in > > > mm/vmscan.c. > > > This is why we have the check above that vetos page removal upon > > > PagePrivate() being set. > > > > [Adding Willy and the mm crew to the cc list] > > > > I wonder if that matters in this case. In the worst case, we'll wait > > for the > > page to cease being DMA'd - but we won't return true if it is. > > > > But if vmscan is generating the wrong VM flags, we should look at > > fixing that. > > > > > > To elaborate a bit: we used to have code here that would check whether > the page had been cleaned but was unstable, and if an argument of > GFP_KERNEL or above was set, we'd try to call COMMIT to ensure the page > was synched to disk on the server (and we'd wait for that call to > complete). > > That code would end up deadlocking in all sorts of horrible ways, so we > ended up having to pull it. Based on having read zero code at all in this area ... Is it possible that you can wait for an existing operation to finish, but starting a new operation will take a lock that is already being held somewhere in your call chain? So it's not that the gfp flags are being set incorrectly, it's just that you're not in a context where you can start a new operation. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can the GFP flags to releasepage() be trusted? -- was Re: [PATCH v2 3/8] nfs: Move to using the alternate fallback fscache I/O API 2021-10-01 14:51 ` Can the GFP flags to releasepage() be trusted? -- was Re: [PATCH v2 3/8] nfs: Move to using the alternate fallback fscache I/O API David Howells 2021-10-01 15:04 ` Trond Myklebust @ 2021-10-05 13:15 ` David Howells 1 sibling, 0 replies; 4+ messages in thread From: David Howells @ 2021-10-05 13:15 UTC (permalink / raw) To: Trond Myklebust Cc: dhowells, linux-cachefs, linux-mm, linux-nfs, willy, anna.schumaker, dwysocha Trond Myklebust <trondmy@hammerspace.com> wrote: > To elaborate a bit: we used to have code here that would check whether > the page had been cleaned but was unstable, and if an argument of > GFP_KERNEL or above was set, we'd try to call COMMIT to ensure the page > was synched to disk on the server (and we'd wait for that call to > complete). > > That code would end up deadlocking in all sorts of horrible ways, so we > ended up having to pull it. I don't think that a deadlock should be possible with this. PG_fscache is now only being used to indicate that a DIO write to the cache is in progress on the page. It will complete and remove the mark at some point. David ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-05 13:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <97eb17f51c8fd9a89f10d9dd0bf35f1075f6b236.camel@hammerspace.com>
[not found] ` <163189104510.2509237.10805032055807259087.stgit@warthog.procyon.org.uk>
[not found] ` <163189108292.2509237.12615909591150927232.stgit@warthog.procyon.org.uk>
[not found] ` <CALF+zO=165sRYRaxPpDS7DaQCpTe-YOa4FamSoMy5FV2uuG5Yg@mail.gmail.com>
2021-10-01 14:51 ` Can the GFP flags to releasepage() be trusted? -- was Re: [PATCH v2 3/8] nfs: Move to using the alternate fallback fscache I/O API David Howells
2021-10-01 15:04 ` Trond Myklebust
2021-10-01 19:42 ` Matthew Wilcox
2021-10-05 13:15 ` David Howells
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox