Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1486626 > unrolled thread

[PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2016-09-19 18:00 +0200
Last post2016-09-19 18:00 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
    [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in  drm_legacy_addbufs_sg() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
      Re: [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in  drm_legacy_addbufs_sg() Daniel Vetter <daniel@ffwll.ch> - 2016-09-21 13:30 +0200
    [PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in  drm_legacy_addbufs_agp() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
    [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
    [PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() in  drm_legacy_addbufs_pci() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200

#1486626 — [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-19 18:00 +0200
Subject[PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations
Message-ID<sj998-7ii-9@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:47:37 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  Use kmalloc_array() in drm_legacy_addbufs_pci()
  Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci()
  Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp()
  Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()
  Rename a jump label in drm_legacy_mapbufs()

 drivers/gpu/drm/drm_bufs.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

-- 
2.10.0

[toc] | [next] | [standalone]


#1486628 — [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-19 18:00 +0200
Subject[PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()
Message-ID<sj998-7ii-27@gated-at.bofh.it>
In reply to#1486626
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:30:31 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 36dd685..adb1dd7 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1117,8 +1117,7 @@ static int drm_legacy_addbufs_sg(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	entry->buflist = kzalloc(count * sizeof(*entry->buflist),
-				GFP_KERNEL);
+	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
-- 
2.10.0

[toc] | [prev] | [next] | [standalone]


#1488051 — Re: [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()

FromDaniel Vetter <daniel@ffwll.ch>
Date2016-09-21 13:30 +0200
SubjectRe: [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()
Message-ID<sjNSW-8oB-9@gated-at.bofh.it>
In reply to#1486628
On Mon, Sep 19, 2016 at 05:56:49PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 19 Sep 2016 17:30:31 +0200
> 
> The script "checkpatch.pl" can point information out like the following.
> 
> WARNING: Prefer kcalloc over kzalloc with multiply
> 
> Thus fix the affected source code place.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Merged patches 1-4. I agree with Jani that changing jump labels is a pure
bikeshed, so didn't apply them.

Also I'll repeat that imo checkpatch patches are great to get started, but
it's much better to do more involved work. Both since that tends to be
more interesting, and fixing all the checkpatch issues will rob the next
newbies of some great starting opportunity. Which means from now on I'll
only selectively apply your checkpatch patches.

We have todo list with some ideas at:

https://www.x.org/wiki/DRMJanitors/

Thanks, Daniel
> ---
>  drivers/gpu/drm/drm_bufs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index 36dd685..adb1dd7 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -1117,8 +1117,7 @@ static int drm_legacy_addbufs_sg(struct drm_device *dev,
>  		return -EINVAL;
>  	}
>  
> -	entry->buflist = kzalloc(count * sizeof(*entry->buflist),
> -				GFP_KERNEL);
> +	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
>  	if (!entry->buflist) {
>  		mutex_unlock(&dev->struct_mutex);
>  		atomic_dec(&dev->buf_alloc);
> -- 
> 2.10.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

[toc] | [prev] | [next] | [standalone]


#1486629 — [PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-19 18:00 +0200
Subject[PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp()
Message-ID<sj998-7ii-25@gated-at.bofh.it>
In reply to#1486626
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:24:20 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 8a31dac..36dd685 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -755,7 +755,7 @@ int drm_legacy_addbufs_agp(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
+	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
-- 
2.10.0

[toc] | [prev] | [next] | [standalone]


#1486632 — [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-19 18:00 +0200
Subject[PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci()
Message-ID<sj998-7ii-31@gated-at.bofh.it>
In reply to#1486626
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:07:06 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3219151..ed33f43 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -923,8 +923,9 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
 	/* Keep the original pagelist until we know all the allocations
 	 * have succeeded
 	 */
-	temp_pagelist = kmalloc((dma->page_count + (count << page_order)) *
-			       sizeof(*dma->pagelist), GFP_KERNEL);
+	temp_pagelist = kmalloc_array(dma->page_count + (count << page_order),
+				      sizeof(*dma->pagelist),
+				      GFP_KERNEL);
 	if (!temp_pagelist) {
 		kfree(entry->buflist);
 		kfree(entry->seglist);
-- 
2.10.0

[toc] | [prev] | [next] | [standalone]


#1486633 — [PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-19 18:00 +0200
Subject[PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci()
Message-ID<sj999-7ii-33@gated-at.bofh.it>
In reply to#1486626
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:17:34 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index ed33f43..8a31dac 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -905,14 +905,14 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
+	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
 
-	entry->seglist = kzalloc(count * sizeof(*entry->seglist), GFP_KERNEL);
+	entry->seglist = kcalloc(count, sizeof(*entry->seglist), GFP_KERNEL);
 	if (!entry->seglist) {
 		kfree(entry->buflist);
 		mutex_unlock(&dev->struct_mutex);
-- 
2.10.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web