linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Jaya Kumar <jayalk@intworks.biz>, Simona Vetter <simona@ffwll.ch>,
	Helge Deller <deller@gmx.de>,
	linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	David Hildenbrand <david@redhat.com>
Subject: Re: [RFC PATCH 3/3] fb_defio: do not use deprecated page->mapping, index fields
Date: Wed, 8 Jan 2025 19:41:31 +0000	[thread overview]
Message-ID: <cf2e1d90-2d6f-464e-b8a0-805ff041604e@lucifer.local> (raw)
In-Reply-To: <Z362xoQMxQRxYUlJ@casper.infradead.org>

On Wed, Jan 08, 2025 at 05:32:54PM +0000, Matthew Wilcox wrote:
> On Wed, Jan 08, 2025 at 04:18:42PM +0000, Lorenzo Stoakes wrote:
> > @@ -280,7 +269,10 @@ static void fb_deferred_io_work(struct work_struct *work)
> >  		struct folio *folio = page_folio(pageref->page);
> >
> >  		folio_lock(folio);
> > -		folio_mkclean(folio);
> > +		rmap_wrprotect_file_page(fbdefio->mapping,
> > +					 pageref->offset >> PAGE_SHIFT,
> > +					 compound_nr(pageref->page),
> > +					 page_to_pfn(pageref->page));
> >  		folio_unlock(folio);
>
> Why do we need to lock the folio?  (since this isn't necessarily a
> folio)  Also, do we need compound_nr() here?  I _think_ for defio,
> the number of pages allocated per object are fixed, so this should be
> an fbdefio->nr_pages field?

I'm trying to keep the code as similar as possible to the way it was before,
even if there are questionable parts.

There is a comment about some timing issue around the locks and so there appears
to be an assumption about that.

As to compound_nr(), we're not write protecting everything, just each invidiual
page in the list that needs it, so we only want to do one at a time. I strongly
suspect it's a single base page each time, but for belts + braces I'm doing
compound_nr().

See below, this is wrong, it should just be '1'.

So this is iterating through a list of pagerefs that can be in any random order.

>
> (something that's always troubled me about compound_nr() is that it
> returns 1 for tail pages and the number you actually expect for head
> pages)
>

OK I changed this from '1' to compound_nr() out of an (apparently) abundance of
caution, but I was wrong:

npagerefs = DIV_ROUND_UP(info->fix.smem_len, PAGE_SIZE);

There are page refs for each PAGE_SIZE (i.e. base page size), so there is no way
anything is compound.

Will switch this to 1.


  reply	other threads:[~2025-01-08 19:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 16:18 [RFC PATCH 0/3] expose mapping wrprotect, fix fb_defio use Lorenzo Stoakes
2025-01-08 16:18 ` [RFC PATCH 1/3] mm: refactor rmap_walk_file() to separate out traversal logic Lorenzo Stoakes
2025-01-08 16:38   ` Matthew Wilcox
2025-01-08 19:23     ` Lorenzo Stoakes
2025-01-08 16:18 ` [RFC PATCH 2/3] mm: provide rmap_wrprotect_file_page() function Lorenzo Stoakes
2025-01-08 17:25   ` Matthew Wilcox
2025-01-08 19:35     ` Lorenzo Stoakes
2025-01-08 16:18 ` [RFC PATCH 3/3] fb_defio: do not use deprecated page->mapping, index fields Lorenzo Stoakes
2025-01-08 17:32   ` Matthew Wilcox
2025-01-08 19:41     ` Lorenzo Stoakes [this message]
2025-01-13 23:01       ` Lorenzo Stoakes
2025-01-08 20:14     ` David Hildenbrand
2025-01-08 20:54       ` Matthew Wilcox
2025-01-08 21:12         ` David Hildenbrand
2025-01-08 21:55           ` Matthew Wilcox
2025-01-08 22:02             ` David Hildenbrand
2025-01-13 17:18               ` Lorenzo Stoakes
2025-01-13 17:48           ` Lorenzo Stoakes

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=cf2e1d90-2d6f-464e-b8a0-805ff041604e@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jayalk@intworks.biz \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=simona@ffwll.ch \
    --cc=willy@infradead.org \
    /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