[PATCH] mm/slub: helper macro __ATTR_XX to make code more clear

Lianjie Zhang posted 1 patch 4 years, 3 months ago
[PATCH] mm/slub: helper macro __ATTR_XX to make code more clear
Posted by Lianjie Zhang 4 years, 3 months ago
Signed-off-by: Lianjie Zhang <zhanglianjie@uniontech.com>

diff --git a/mm/slub.c b/mm/slub.c
index 07cdd999c3fe..59992de7d3db 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5358,12 +5358,10 @@ struct slab_attribute {
 };

 #define SLAB_ATTR_RO(_name) \
-	static struct slab_attribute _name##_attr = \
-	__ATTR(_name, 0400, _name##_show, NULL)
+	static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)

 #define SLAB_ATTR(_name) \
-	static struct slab_attribute _name##_attr =  \
-	__ATTR(_name, 0600, _name##_show, _name##_store)
+	static struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)

 static ssize_t slab_size_show(struct kmem_cache *s, char *buf)
 {
--
2.20.1
Re: [PATCH] mm/slub: helper macro __ATTR_XX to make code more clear
Posted by David Rientjes 4 years, 3 months ago
On Sun, 6 Mar 2022, Lianjie Zhang wrote:

> Signed-off-by: Lianjie Zhang <zhanglianjie@uniontech.com>

And VERIFY_OCTAL_PERMISSIONS() can help validate any future change.

Acked-by: David Rientjes <rientjes@google.com>
Re: [PATCH] mm/slub: helper macro __ATTR_XX to make code more clear
Posted by Vlastimil Babka 4 years, 3 months ago
On 3/6/22 23:11, David Rientjes wrote:
> On Sun, 6 Mar 2022, Lianjie Zhang wrote:
> 
>> Signed-off-by: Lianjie Zhang <zhanglianjie@uniontech.com>
> 
> And VERIFY_OCTAL_PERMISSIONS() can help validate any future change.
> 
> Acked-by: David Rientjes <rientjes@google.com>

Ok, adding with adjusted subject and non-empty message:

    mm/slub: use helper macro __ATTR_XX_MODE for SLAB_ATTR(_RO)
    
    This allows more concise code, and VERIFY_OCTAL_PERMISSIONS() can help
    validate any future change.