diff mbox

[2/3] fbuffer: introduce the invert-region helper

Message ID 20150528131319.5240.4785.stgit@bahia.lab.toulouse-stg.fr.ibm.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Greg Kurz May 28, 2015, 1:13 p.m. UTC
The inner loop in fb8-toggle-cursor can be implemented with hv-logical-memop
in board-qemu and get an incredible performance boost.

Let's introduce a per-board helper:
- board-js2x: slow RB based, taken from current fb8-toggle-cursor
- board-qemu: faster hv-logical-memop based

With standard graphical settings on board-qemu, we go from 512 hcall
invocations per character down to 16.

Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 board-js2x/slof/helper.fs |    4 ++++
 board-qemu/slof/helper.fs |    3 +++
 slof/fs/fbuffer.fs        |    2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

Comments

Thomas Huth May 28, 2015, 5:19 p.m. UTC | #1
On Thu, 28 May 2015 15:13:19 +0200
Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:

> The inner loop in fb8-toggle-cursor can be implemented with hv-logical-memop
> in board-qemu and get an incredible performance boost.
> 
> Let's introduce a per-board helper:
> - board-js2x: slow RB based, taken from current fb8-toggle-cursor
> - board-qemu: faster hv-logical-memop based
> 
> With standard graphical settings on board-qemu, we go from 512 hcall
> invocations per character down to 16.
> 
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
>  board-js2x/slof/helper.fs |    4 ++++
>  board-qemu/slof/helper.fs |    3 +++
>  slof/fs/fbuffer.fs        |    2 +-
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
> index 34d60da..918fdc4 100644
> --- a/board-js2x/slof/helper.fs
> +++ b/board-js2x/slof/helper.fs
> @@ -26,3 +26,7 @@
>     s" , " $cat
>     bdate2human $cat encode-string THEN
>  ;
> +
> +: invert-region ( addr len -- )
> +   0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
> +;
> diff --git a/board-qemu/slof/helper.fs b/board-qemu/slof/helper.fs
> index 96da498..da676c7 100644
> --- a/board-qemu/slof/helper.fs
> +++ b/board-qemu/slof/helper.fs
> @@ -33,3 +33,6 @@
>    swap -
>  ;
>  
> +: invert-region ( addr len -- )
> +   over swap 0 swap 1 hv-logical-memop drop
> +;
> diff --git a/slof/fs/fbuffer.fs b/slof/fs/fbuffer.fs
> index faae6a9..deeba6b 100644
> --- a/slof/fs/fbuffer.fs
> +++ b/slof/fs/fbuffer.fs
> @@ -99,7 +99,7 @@ CREATE bitmap-buffer 400 4 * allot
>  : fb8-toggle-cursor ( -- )
>  	line# fb8-line2addr column# fb8-columns2bytes +
>  	char-height 0 ?DO
> -		dup char-width screen-depth * 0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
> +		dup char-width screen-depth * invert-region
>  		screen-width screen-depth * +
>  	LOOP drop
>  ;

Reviewed-by: Thomas Huth <thuth@redhat.com>
Nikunj A Dadhania May 29, 2015, 4:17 a.m. UTC | #2
Greg Kurz <gkurz@linux.vnet.ibm.com> writes:

> The inner loop in fb8-toggle-cursor can be implemented with hv-logical-memop
> in board-qemu and get an incredible performance boost.
>
> Let's introduce a per-board helper:
> - board-js2x: slow RB based, taken from current fb8-toggle-cursor
> - board-qemu: faster hv-logical-memop based
>
> With standard graphical settings on board-qemu, we go from 512 hcall
> invocations per character down to 16.
>
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>

Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>

> ---
>  board-js2x/slof/helper.fs |    4 ++++
>  board-qemu/slof/helper.fs |    3 +++
>  slof/fs/fbuffer.fs        |    2 +-
>  3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
> index 34d60da..918fdc4 100644
> --- a/board-js2x/slof/helper.fs
> +++ b/board-js2x/slof/helper.fs
> @@ -26,3 +26,7 @@
>     s" , " $cat
>     bdate2human $cat encode-string THEN
>  ;
> +
> +: invert-region ( addr len -- )
> +   0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
> +;
> diff --git a/board-qemu/slof/helper.fs b/board-qemu/slof/helper.fs
> index 96da498..da676c7 100644
> --- a/board-qemu/slof/helper.fs
> +++ b/board-qemu/slof/helper.fs
> @@ -33,3 +33,6 @@
>    swap -
>  ;
>
> +: invert-region ( addr len -- )
> +   over swap 0 swap 1 hv-logical-memop drop
> +;
> diff --git a/slof/fs/fbuffer.fs b/slof/fs/fbuffer.fs
> index faae6a9..deeba6b 100644
> --- a/slof/fs/fbuffer.fs
> +++ b/slof/fs/fbuffer.fs
> @@ -99,7 +99,7 @@ CREATE bitmap-buffer 400 4 * allot
>  : fb8-toggle-cursor ( -- )
>  	line# fb8-line2addr column# fb8-columns2bytes +
>  	char-height 0 ?DO
> -		dup char-width screen-depth * 0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
> +		dup char-width screen-depth * invert-region
>  		screen-width screen-depth * +
>  	LOOP drop
>  ;
diff mbox

Patch

diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
index 34d60da..918fdc4 100644
--- a/board-js2x/slof/helper.fs
+++ b/board-js2x/slof/helper.fs
@@ -26,3 +26,7 @@ 
    s" , " $cat
    bdate2human $cat encode-string THEN
 ;
+
+: invert-region ( addr len -- )
+   0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
+;
diff --git a/board-qemu/slof/helper.fs b/board-qemu/slof/helper.fs
index 96da498..da676c7 100644
--- a/board-qemu/slof/helper.fs
+++ b/board-qemu/slof/helper.fs
@@ -33,3 +33,6 @@ 
   swap -
 ;
 
+: invert-region ( addr len -- )
+   over swap 0 swap 1 hv-logical-memop drop
+;
diff --git a/slof/fs/fbuffer.fs b/slof/fs/fbuffer.fs
index faae6a9..deeba6b 100644
--- a/slof/fs/fbuffer.fs
+++ b/slof/fs/fbuffer.fs
@@ -99,7 +99,7 @@  CREATE bitmap-buffer 400 4 * allot
 : fb8-toggle-cursor ( -- )
 	line# fb8-line2addr column# fb8-columns2bytes +
 	char-height 0 ?DO
-		dup char-width screen-depth * 0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
+		dup char-width screen-depth * invert-region
 		screen-width screen-depth * +
 	LOOP drop
 ;