[v10,04/11] drm/shmem: Put booleans in the end of struct drm_gem_shmem_object

Message ID 20230108210445.3948344-5-dmitry.osipenko@collabora.com
State New
Headers
Series Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers |

Commit Message

Dmitry Osipenko Jan. 8, 2023, 9:04 p.m. UTC
  Group all 1-bit boolean members of struct drm_gem_shmem_object in the end
of the structure, allowing compiler to pack data better and making code to
look more consistent.

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
 include/drm/drm_gem_shmem_helper.h | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
  

Comments

Thomas Zimmermann Feb. 17, 2023, 12:25 p.m. UTC | #1
Am 08.01.23 um 22:04 schrieb Dmitry Osipenko:
> Group all 1-bit boolean members of struct drm_gem_shmem_object in the end
> of the structure, allowing compiler to pack data better and making code to
> look more consistent.
> 
> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   include/drm/drm_gem_shmem_helper.h | 30 +++++++++++++++---------------
>   1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
> index a2201b2488c5..5994fed5e327 100644
> --- a/include/drm/drm_gem_shmem_helper.h
> +++ b/include/drm/drm_gem_shmem_helper.h
> @@ -60,20 +60,6 @@ struct drm_gem_shmem_object {
>   	 */
>   	struct list_head madv_list;
>   
> -	/**
> -	 * @pages_mark_dirty_on_put:
> -	 *
> -	 * Mark pages as dirty when they are put.
> -	 */
> -	unsigned int pages_mark_dirty_on_put    : 1;
> -
> -	/**
> -	 * @pages_mark_accessed_on_put:
> -	 *
> -	 * Mark pages as accessed when they are put.
> -	 */
> -	unsigned int pages_mark_accessed_on_put : 1;
> -
>   	/**
>   	 * @sgt: Scatter/gather table for imported PRIME buffers
>   	 */
> @@ -97,10 +83,24 @@ struct drm_gem_shmem_object {
>   	 */
>   	unsigned int vmap_use_count;
>   
> +	/**
> +	 * @pages_mark_dirty_on_put:
> +	 *
> +	 * Mark pages as dirty when they are put.
> +	 */
> +	bool pages_mark_dirty_on_put : 1;
> +
> +	/**
> +	 * @pages_mark_accessed_on_put:
> +	 *
> +	 * Mark pages as accessed when they are put.
> +	 */
> +	bool pages_mark_accessed_on_put : 1;
> +
>   	/**
>   	 * @map_wc: map object write-combined (instead of using shmem defaults).
>   	 */
> -	bool map_wc;
> +	bool map_wc : 1;
>   };
>   
>   #define to_drm_gem_shmem_obj(obj) \

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
  

Patch

diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
index a2201b2488c5..5994fed5e327 100644
--- a/include/drm/drm_gem_shmem_helper.h
+++ b/include/drm/drm_gem_shmem_helper.h
@@ -60,20 +60,6 @@  struct drm_gem_shmem_object {
 	 */
 	struct list_head madv_list;
 
-	/**
-	 * @pages_mark_dirty_on_put:
-	 *
-	 * Mark pages as dirty when they are put.
-	 */
-	unsigned int pages_mark_dirty_on_put    : 1;
-
-	/**
-	 * @pages_mark_accessed_on_put:
-	 *
-	 * Mark pages as accessed when they are put.
-	 */
-	unsigned int pages_mark_accessed_on_put : 1;
-
 	/**
 	 * @sgt: Scatter/gather table for imported PRIME buffers
 	 */
@@ -97,10 +83,24 @@  struct drm_gem_shmem_object {
 	 */
 	unsigned int vmap_use_count;
 
+	/**
+	 * @pages_mark_dirty_on_put:
+	 *
+	 * Mark pages as dirty when they are put.
+	 */
+	bool pages_mark_dirty_on_put : 1;
+
+	/**
+	 * @pages_mark_accessed_on_put:
+	 *
+	 * Mark pages as accessed when they are put.
+	 */
+	bool pages_mark_accessed_on_put : 1;
+
 	/**
 	 * @map_wc: map object write-combined (instead of using shmem defaults).
 	 */
-	bool map_wc;
+	bool map_wc : 1;
 };
 
 #define to_drm_gem_shmem_obj(obj) \