* [PATCH v2 0/3] media: Optimize the code using vmalloc_array
@ 2025-10-22 3:20 tanze
2025-10-22 3:20 ` [PATCH v2 1/3] media: dvb-core: " tanze
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: tanze @ 2025-10-22 3:20 UTC (permalink / raw)
To: mchehab, mingo, hverkuil, tskd08; +Cc: linux-media, linux-kernel, tanze
Change array_size() to vmalloc_array(), Due to vmalloc_array() is optimized better,
uses fewer instructions, and handles overflow more concisely
v1->v2: Update patch #02 #03 due to typos CI robot detected some issues
v1:https://lore.kernel.org/all/20251021143122.268730-1-tanze@kylinos.cn/
tanze (3):
media: dvb-core: Optimize the code using vmalloc_array
media: vivid: Optimize the code using vmalloc_array
media: pt1: Optimize the code using vmalloc_array
drivers/media/dvb-core/dmxdev.c | 4 ++--
drivers/media/dvb-core/dvb_demux.c | 9 +++++----
drivers/media/pci/pt1/pt1.c | 2 +-
drivers/media/test-drivers/vivid/vivid-core.c | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/3] media: dvb-core: Optimize the code using vmalloc_array
2025-10-22 3:20 [PATCH v2 0/3] media: Optimize the code using vmalloc_array tanze
@ 2025-10-22 3:20 ` tanze
2025-10-22 3:20 ` [PATCH v2 2/3] media: vivid: " tanze
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: tanze @ 2025-10-22 3:20 UTC (permalink / raw)
To: mchehab, mingo, hverkuil, tskd08; +Cc: linux-media, linux-kernel, tanze
Change array_size() to vmalloc_array(), Due to vmalloc_array() is optimized better,
uses fewer instructions, and handles overflow more concisely
Signed-off-by: tanze <tanze@kylinos.cn>
---
drivers/media/dvb-core/dmxdev.c | 4 ++--
drivers/media/dvb-core/dvb_demux.c | 9 +++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 151177e5a06d..8c6f5aafda1d 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -1414,8 +1414,8 @@ int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
if (dmxdev->demux->open(dmxdev->demux) < 0)
return -EUSERS;
- dmxdev->filter = vmalloc(array_size(sizeof(struct dmxdev_filter),
- dmxdev->filternum));
+ dmxdev->filter = vmalloc_array(dmxdev->filternum,
+ sizeof(struct dmxdev_filter));
if (!dmxdev->filter)
return -ENOMEM;
diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
index 7c4d86bfdd6c..9d5600501cf8 100644
--- a/drivers/media/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb-core/dvb_demux.c
@@ -1238,14 +1238,15 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
dvbdemux->cnt_storage = NULL;
dvbdemux->users = 0;
- dvbdemux->filter = vmalloc(array_size(sizeof(struct dvb_demux_filter),
- dvbdemux->filternum));
+ dvbdemux->filter = vmalloc_array(dvbdemux->filternum,
+ sizeof(struct dvb_demux_filter));
if (!dvbdemux->filter)
return -ENOMEM;
- dvbdemux->feed = vmalloc(array_size(sizeof(struct dvb_demux_feed),
- dvbdemux->feednum));
+ dvbdemux->feed = vmalloc_array(dvbdemux->feednum,
+ sizeof(struct dvb_demux_feed));
+
if (!dvbdemux->feed) {
vfree(dvbdemux->filter);
dvbdemux->filter = NULL;
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] media: vivid: Optimize the code using vmalloc_array
2025-10-22 3:20 [PATCH v2 0/3] media: Optimize the code using vmalloc_array tanze
2025-10-22 3:20 ` [PATCH v2 1/3] media: dvb-core: " tanze
@ 2025-10-22 3:20 ` tanze
2025-10-22 3:20 ` [PATCH v2 3/3] media: pt1: " tanze
2025-11-03 8:41 ` [PATCH v2 0/3] media: " Hans Verkuil
3 siblings, 0 replies; 5+ messages in thread
From: tanze @ 2025-10-22 3:20 UTC (permalink / raw)
To: mchehab, mingo, hverkuil, tskd08; +Cc: linux-media, linux-kernel, tanze
Change array_size() to vmalloc_array(), Due to vmalloc_array() is optimized better,
uses fewer instructions, and handles overflow more concisely
Signed-off-by: tanze <tanze@kylinos.cn>
---
drivers/media/test-drivers/vivid/vivid-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c
index 86506be36acb..ef71d76e7397 100644
--- a/drivers/media/test-drivers/vivid/vivid-core.c
+++ b/drivers/media/test-drivers/vivid/vivid-core.c
@@ -1864,7 +1864,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
goto free_dev;
/* load the edid */
- dev->edid = vmalloc(array_size(256, 128));
+ dev->edid = vmalloc_array(256, 128);
if (!dev->edid)
goto free_dev;
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] media: pt1: Optimize the code using vmalloc_array
2025-10-22 3:20 [PATCH v2 0/3] media: Optimize the code using vmalloc_array tanze
2025-10-22 3:20 ` [PATCH v2 1/3] media: dvb-core: " tanze
2025-10-22 3:20 ` [PATCH v2 2/3] media: vivid: " tanze
@ 2025-10-22 3:20 ` tanze
2025-11-03 8:41 ` [PATCH v2 0/3] media: " Hans Verkuil
3 siblings, 0 replies; 5+ messages in thread
From: tanze @ 2025-10-22 3:20 UTC (permalink / raw)
To: mchehab, mingo, hverkuil, tskd08; +Cc: linux-media, linux-kernel, tanze
Change array_size() to vmalloc_array(), Due to vmalloc_array() is optimized better,
uses fewer instructions, and handles overflow more concisely
Signed-off-by: tanze <tanze@kylinos.cn>
---
drivers/media/pci/pt1/pt1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index 121a4a92ea10..1ced093583ac 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -639,7 +639,7 @@ static int pt1_init_tables(struct pt1 *pt1)
if (!pt1_nr_tables)
return 0;
- tables = vmalloc(array_size(pt1_nr_tables, sizeof(struct pt1_table)));
+ tables = vmalloc_array(pt1_nr_tables, sizeof(struct pt1_table));
if (tables == NULL)
return -ENOMEM;
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] media: Optimize the code using vmalloc_array
2025-10-22 3:20 [PATCH v2 0/3] media: Optimize the code using vmalloc_array tanze
` (2 preceding siblings ...)
2025-10-22 3:20 ` [PATCH v2 3/3] media: pt1: " tanze
@ 2025-11-03 8:41 ` Hans Verkuil
3 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2025-11-03 8:41 UTC (permalink / raw)
To: tanze, mchehab, mingo, hverkuil, tskd08; +Cc: linux-media, linux-kernel
On 22/10/2025 05:20, tanze wrote:
> Change array_size() to vmalloc_array(), Due to vmalloc_array() is optimized better,
> uses fewer instructions, and handles overflow more concisely
>
> v1->v2: Update patch #02 #03 due to typos CI robot detected some issues
>
> v1:https://lore.kernel.org/all/20251021143122.268730-1-tanze@kylinos.cn/
>
> tanze (3):
> media: dvb-core: Optimize the code using vmalloc_array
> media: vivid: Optimize the code using vmalloc_array
> media: pt1: Optimize the code using vmalloc_array
FYI: all three patches are duplicates of:
https://lore.kernel.org/linux-media/20250812035310.497233-1-rongqianfeng@vivo.com/
which has already been merged.
So I'm skipping these patches.
Regards,
Hans
>
> drivers/media/dvb-core/dmxdev.c | 4 ++--
> drivers/media/dvb-core/dvb_demux.c | 9 +++++----
> drivers/media/pci/pt1/pt1.c | 2 +-
> drivers/media/test-drivers/vivid/vivid-core.c | 2 +-
> 4 files changed, 9 insertions(+), 8 deletions(-)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-03 8:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-22 3:20 [PATCH v2 0/3] media: Optimize the code using vmalloc_array tanze
2025-10-22 3:20 ` [PATCH v2 1/3] media: dvb-core: " tanze
2025-10-22 3:20 ` [PATCH v2 2/3] media: vivid: " tanze
2025-10-22 3:20 ` [PATCH v2 3/3] media: pt1: " tanze
2025-11-03 8:41 ` [PATCH v2 0/3] media: " Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®