[PATCH] video/lfb: switch to xv[mz]alloc*()

Jan Beulich posted 1 patch 3 months, 1 week ago
Failed in applying to current master (apply log)
[PATCH] video/lfb: switch to xv[mz]alloc*()
Posted by Jan Beulich 3 months, 1 week ago
Use the more "modern" form, thus doing away with effectively open-coding
xmalloc_array() at the same time. While there is a difference in
generated code, as xmalloc_bytes() forces SMP_CACHE_BYTES alignment, if
code really cared about such higher than default alignment, it should
request so explicitly.

Also clear the pointers when freeing them.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v3: Use xv[mz]alloc_array().

--- a/xen/drivers/video/lfb.c
+++ b/xen/drivers/video/lfb.c
@@ -7,6 +7,8 @@
 #include <xen/kernel.h>
 #include <xen/lib.h>
 #include <xen/errno.h>
+#include <xen/xvmalloc.h>
+
 #include "lfb.h"
 #include "font.h"
 
@@ -147,9 +149,10 @@ int __init lfb_init(struct lfb_prop *lfb
 {
     lfb.lfbp = *lfbp;
 
-    lfb.lbuf = xmalloc_bytes(lfb.lfbp.bytes_per_line);
-    lfb.text_buf = xzalloc_bytes(lfb.lfbp.text_columns * lfb.lfbp.text_rows);
-    lfb.line_len = xzalloc_array(unsigned int, lfb.lfbp.text_columns);
+    lfb.lbuf = xvmalloc_array(unsigned char, lfb.lfbp.bytes_per_line);
+    lfb.text_buf = xvzalloc_array(unsigned char,
+                                  lfb.lfbp.text_columns * lfb.lfbp.text_rows);
+    lfb.line_len = xvzalloc_array(unsigned int, lfb.lfbp.text_columns);
 
     if ( !lfb.lbuf || !lfb.text_buf || !lfb.line_len )
         goto fail;
@@ -165,8 +168,8 @@ fail:
 
 void lfb_free(void)
 {
-    xfree(lfb.lbuf);
-    xfree(lfb.text_buf);
-    xfree(lfb.line_len);
+    XVFREE(lfb.lbuf);
+    XVFREE(lfb.text_buf);
+    XVFREE(lfb.line_len);
     lfb.lfbp.lfb = ZERO_BLOCK_PTR;
 }
Re: [PATCH] video/lfb: switch to xv[mz]alloc*()
Posted by Roger Pau Monné 3 months, 1 week ago
On Thu, Jul 24, 2025 at 10:18:37AM +0200, Jan Beulich wrote:
> Use the more "modern" form, thus doing away with effectively open-coding
> xmalloc_array() at the same time. While there is a difference in
> generated code, as xmalloc_bytes() forces SMP_CACHE_BYTES alignment, if
> code really cared about such higher than default alignment, it should
> request so explicitly.
> 
> Also clear the pointers when freeing them.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

> ---
> v3: Use xv[mz]alloc_array().

I don't really get this v3 changelog, patch is v1 AFAICT?  Maybe it
was split from a different series?

Thanks, Roger.

Re: [PATCH] video/lfb: switch to xv[mz]alloc*()
Posted by Jan Beulich 3 months, 1 week ago
On 24.07.2025 16:09, Roger Pau Monné wrote:
> On Thu, Jul 24, 2025 at 10:18:37AM +0200, Jan Beulich wrote:
>> Use the more "modern" form, thus doing away with effectively open-coding
>> xmalloc_array() at the same time. While there is a difference in
>> generated code, as xmalloc_bytes() forces SMP_CACHE_BYTES alignment, if
>> code really cared about such higher than default alignment, it should
>> request so explicitly.
>>
>> Also clear the pointers when freeing them.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Acked-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks.

>> ---
>> v3: Use xv[mz]alloc_array().
> 
> I don't really get this v3 changelog, patch is v1 AFAICT?  Maybe it
> was split from a different series?

Oops, yes, I omitted the v3 by mistake. There was a losely connected set
of similar changes, submitted as v2 at [1]. I decided to rather submit
the v3 patches individually.

Jan

[1] https://lists.xen.org/archives/html/xen-devel/2021-04/msg01232.html