Re: [PATCH 1/4] mm/memory: convert do_page_mkwrite() to use folios

From: Matthew Wilcox
Date: Mon Jul 03 2023 - 19:25:40 EST


On Sun, Jul 02, 2023 at 10:58:47PM -0700, Sidhartha Kumar wrote:
> @@ -2947,14 +2947,14 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *vmf)
> if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))
> return ret;
> if (unlikely(!(ret & VM_FAULT_LOCKED))) {
> - lock_page(page);
> - if (!page->mapping) {
> - unlock_page(page);
> + folio_lock(folio);
> + if (!folio_mapping(folio)) {

You don't need to call folio_mapping() here. folio->mapping works
absolutely fine in this circumstance. In fact, you may have broken a
driver with this change. I can elaborate more, but I'm not quite in the
mood to do that right now.