linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Sam Ravnborg <sam@ravnborg.org>
Cc: linux-fbdev@vger.kernel.org, deller@gmx.de,
	linux-staging@lists.linux.dev, javierm@redhat.com,
	dri-devel@lists.freedesktop.org, bernie@plugable.com,
	noralf@tronnes.org, andriy.shevchenko@linux.intel.com,
	jayalk@intworks.biz
Subject: Re: [PATCH 2/2] fbdev: Don't sort deferred-I/O pages by default
Date: Fri, 11 Feb 2022 09:25:55 +0100	[thread overview]
Message-ID: <96539edd-4b78-e460-786d-db9581eccdee@suse.de> (raw)
In-Reply-To: <20220211075844.GM1951@kadam>


[-- Attachment #1.1: Type: text/plain, Size: 2179 bytes --]

Hi

Am 11.02.22 um 08:58 schrieb Dan Carpenter:
> On Thu, Feb 10, 2022 at 10:16:45PM +0100, Sam Ravnborg wrote:
>>> diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
>>> index 3727b1ca87b1..1f672cf253b2 100644
>>> --- a/drivers/video/fbdev/core/fb_defio.c
>>> +++ b/drivers/video/fbdev/core/fb_defio.c
>>> @@ -132,15 +132,20 @@ static vm_fault_t fb_deferred_io_mkwrite(struct vm_fault *vmf)
>>>   	if (!list_empty(&page->lru))
>>>   		goto page_already_added;
>>>   
>>> -	/* we loop through the pagelist before adding in order
>>> -	to keep the pagelist sorted */
>>> -	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
>>> -		if (cur->index > page->index)
>>> -			break;
>>> +	if (fbdefio->sort_pagelist) {
>>> +		/*
>>> +		 * We loop through the pagelist before adding in order
>>> +		 * to keep the pagelist sorted.
>>> +		 */
>>> +		list_for_each_entry(cur, &fbdefio->pagelist, lru) {
>>> +			if (cur->index > page->index)
>>> +				break;
>>> +		}
>>> +		list_add_tail(&page->lru, &cur->lru);
>>> +	} else {
>>> +		list_add_tail(&page->lru, &fbdefio->pagelist);
>>>   	}
>> Bikeshedding - my personal style is to have the likely part first.
>> This makes reading the code easier.
> 
> I've thought about this quite a bit...  I guess my rule is to avoid
> negatives as much as possible so I prefer the original code.  My rules
> right now are:
> 
> 1) Always do error handling.  Don't do success handling.
> 2) Return as quickly as possible and pull the code in an indent.
> 3) Avoid negatives.  Never had negatives in the variable names.

 From what I know, CPUs' branch prediction prefers backward jumps (e.g., 
loops) but avoids forward jumps. Compilers arrange the code to optimize 
for this pattern. So I tend to put the exception or error handling into 
the if branch.  But I have no idea if that really makes a difference at 
runtime.

Best regards
Thomas

> 
> regards,
> dan carpenter

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

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

  reply	other threads:[~2022-02-11  8:26 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
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 [this message]
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=96539edd-4b78-e460-786d-db9581eccdee@suse.de \
    --to=tzimmermann@suse.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bernie@plugable.com \
    --cc=dan.carpenter@oracle.com \
    --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=sam@ravnborg.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;
as well as URLs for NNTP newsgroup(s).