linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: daniel@ffwll.ch, javierm@redhat.com, noralf@tronnes.org,
	andriy.shevchenko@linux.intel.com, deller@gmx.de,
	bernie@plugable.com, jayalk@intworks.biz,
	linux-fbdev@vger.kernel.org, linux-staging@lists.linux.dev,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] fbdev/defio: Early-out if page is already enlisted
Date: Thu, 10 Feb 2022 22:00:29 +0100	[thread overview]
Message-ID: <YgV87ejpzGkSMNop@ravnborg.org> (raw)
In-Reply-To: <20220210141111.5231-2-tzimmermann@suse.de>

Hi Thomas,

On Thu, Feb 10, 2022 at 03:11:11PM +0100, Thomas Zimmermann wrote:
> Return early if a page is already in the list of dirty pages for
> deferred I/O. This can be detected if the page's list head is not
> empty. Keep the list head initialized while the page is not enlisted
> to make this work reliably.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>  drivers/video/fbdev/core/fb_defio.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
> index a591d291b231..3727b1ca87b1 100644
> --- a/drivers/video/fbdev/core/fb_defio.c
> +++ b/drivers/video/fbdev/core/fb_defio.c
> @@ -59,6 +59,7 @@ static vm_fault_t fb_deferred_io_fault(struct vm_fault *vmf)
>  		printk(KERN_ERR "no mapping available\n");
>  
>  	BUG_ON(!page->mapping);
> +	INIT_LIST_HEAD(&page->lru);
>  	page->index = vmf->pgoff;
>  
>  	vmf->page = page;
> @@ -122,17 +123,19 @@ static vm_fault_t fb_deferred_io_mkwrite(struct vm_fault *vmf)
>  	 */
>  	lock_page(page);
>  
> +	/*
> +	 * This check is to catch the case where a new process could start
> +	 * writing to the same page through a new pte. this new access
> +	 * can cause the mkwrite even when the original ps's pte is marked
> +	 * writable.
> +	 */
When moving this comment it would be prudent to also fix the wording a
bit.
- Capital in start of sentence and after a period
- Spell out process and do not shorten ps


> +	if (!list_empty(&page->lru))
> +		goto page_already_added;
> +

This check says that if the page already has something in the parge->lru
then this is added by defio and thus is already added.
This matches your commit description - OK.

Maybe add something like:
* Pages added will have their lru set, and it is clered again in the
* deferred work handler.



>  	/* we loop through the pagelist before adding in order
>  	to keep the pagelist sorted */
>  	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
> -		/* this check is to catch the case where a new
> -		process could start writing to the same page
> -		through a new pte. this new access can cause the
> -		mkwrite even when the original ps's pte is marked
> -		writable */
> -		if (unlikely(cur == page))
> -			goto page_already_added;
> -		else if (cur->index > page->index)
> +		if (cur->index > page->index)
>  			break;
>  	}
>  
> @@ -194,7 +197,7 @@ static void fb_deferred_io_work(struct work_struct *work)
>  
>  	/* clear the list */
>  	list_for_each_safe(node, next, &fbdefio->pagelist) {
> -		list_del(node);
> +		list_del_init(node);
>  	}
>  	mutex_unlock(&fbdefio->lock);
>  }

With the comment adjusted as you see fit
Acked-by: Sam Ravnborg <sam@ravnborg.org>

  reply	other threads:[~2022-02-10 21:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 14:11 [PATCH 0/2] fbdev: Significantly improve performance of fbdefio mmap Thomas Zimmermann
2022-02-10 14:11 ` [PATCH 1/2] fbdev/defio: Early-out if page is already enlisted Thomas Zimmermann
2022-02-10 21:00   ` Sam Ravnborg [this message]
2022-02-11  9:12     ` Thomas Zimmermann
2022-02-10 14:11 ` [PATCH 2/2] fbdev: Don't sort deferred-I/O pages by default Thomas Zimmermann
2022-02-10 16:15   ` Andy Shevchenko
2022-02-10 21:16   ` Sam Ravnborg
2022-02-11  7:58     ` Dan Carpenter
2022-02-11  8:25       ` Thomas Zimmermann
2022-02-11  8:21     ` Thomas Zimmermann
2022-02-14  8:05   ` Geert Uytterhoeven
2022-02-14  8:28     ` Thomas Zimmermann
2022-02-14  9:05       ` Geert Uytterhoeven
2022-02-14 13:29         ` Thomas Zimmermann

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=YgV87ejpzGkSMNop@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bernie@plugable.com \
    --cc=daniel@ffwll.ch \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jayalk@intworks.biz \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=noralf@tronnes.org \
    --cc=tzimmermann@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).