public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* use persistent allocation for cursor blinking.
@ 2006-08-01 18:56 Dave Jones
  2006-08-01 19:15 ` Roland Dreier
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Dave Jones @ 2006-08-01 18:56 UTC (permalink / raw)
  To: Linux Kernel

Every time the console cursor blinks, we do a kmalloc/kfree pair.
This patch turns that into a single allocation.

This allocation was the most frequent kmalloc I saw on my test box.

Signed-off-by: Dave Jones <davej@redhat.com>


--- linux-2.6.14/drivers/video/console/softcursor.c~	2005-12-28 18:40:08.000000000 -0500
+++ linux-2.6.14/drivers/video/console/softcursor.c	2005-12-28 18:45:50.000000000 -0500
@@ -23,7 +23,9 @@ int soft_cursor(struct fb_info *info, st
 	unsigned int buf_align = info->pixmap.buf_align - 1;
 	unsigned int i, size, dsize, s_pitch, d_pitch;
 	struct fb_image *image;
-	u8 *dst, *src;
+	u8 *dst;
+	static u8 *src=NULL;
+	static int allocsize=0;
 
 	if (info->state != FBINFO_STATE_RUNNING)
 		return 0;
@@ -31,9 +33,15 @@ int soft_cursor(struct fb_info *info, st
 	s_pitch = (cursor->image.width + 7) >> 3;
 	dsize = s_pitch * cursor->image.height;
 
-	src = kmalloc(dsize + sizeof(struct fb_image), GFP_ATOMIC);
-	if (!src)
-		return -ENOMEM;
+	if (dsize + sizeof(struct fb_image) != allocsize) {
+		if (src != NULL)
+			kfree(src);
+		allocsize = dsize + sizeof(struct fb_image);
+
+		src = kmalloc(allocsize, GFP_ATOMIC);
+		if (!src)
+			return -ENOMEM;
+	}
 
 	image = (struct fb_image *) (src + dsize);
 	*image = cursor->image;
@@ -61,7 +69,6 @@ int soft_cursor(struct fb_info *info, st
 	fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height);
 	image->data = dst;
 	info->fbops->fb_imageblit(info, image);
-	kfree(src);
 	return 0;
 }
 

-- 
http://www.codemonkey.org.uk

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-08-06 23:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01 18:56 use persistent allocation for cursor blinking Dave Jones
2006-08-01 19:15 ` Roland Dreier
2006-08-01 19:31   ` Dave Jones
2006-08-01 22:20   ` Alan Cox
2006-08-02  1:20     ` [PATCH] fbcon: Use " Antonino A. Daplas
2006-08-02  1:28       ` [PATCH RESEND] " Antonino A. Daplas
2006-08-02  1:28       ` [PATCH] " Dave Jones
2006-08-01 22:17 ` use " Alan Cox
2006-08-01 22:39   ` Dave Jones
2006-08-01 23:12     ` Alan Cox
2006-08-05 21:26 ` Pavel Machek
2006-08-06 23:46   ` Antonino A. Daplas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox