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


Groups > linux.kernel > #1326422 > unrolled thread

[PATCH 2/5] mm/slub: query dynamic DEBUG_PAGEALLOC setting

Started byJoonsoo Kim <js1304@gmail.com>
First post2016-02-04 07:00 +0100
Last post2016-02-04 17:30 +0100
Articles 3 — 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 2/5] mm/slub: query dynamic DEBUG_PAGEALLOC setting Joonsoo Kim <js1304@gmail.com> - 2016-02-04 07:00 +0100
    Re: [PATCH 2/5] mm/slub: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-04 09:40 +0100
      Re: [PATCH 2/5] mm/slub: query dynamic DEBUG_PAGEALLOC setting Joonsoo Kim <js1304@gmail.com> - 2016-02-04 17:30 +0100

#1326422 — [PATCH 2/5] mm/slub: query dynamic DEBUG_PAGEALLOC setting

FromJoonsoo Kim <js1304@gmail.com>
Date2016-02-04 07:00 +0100
Subject[PATCH 2/5] mm/slub: query dynamic DEBUG_PAGEALLOC setting
Message-ID<qYl7t-4t9-21@gated-at.bofh.it>
We can disable debug_pagealloc processing even if the code is complied
with CONFIG_DEBUG_PAGEALLOC. This patch changes the code to query
whether it is enabled or not in runtime.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 mm/slub.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 7d4da68..7b5a965 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -256,11 +256,12 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)
 {
 	void *p;
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
-	probe_kernel_read(&p, (void **)(object + s->offset), sizeof(p));
-#else
-	p = get_freepointer(s, object);
-#endif
+	if (debug_pagealloc_enabled()) {
+		probe_kernel_read(&p,
+			(void **)(object + s->offset), sizeof(p));
+	} else
+		p = get_freepointer(s, object);
+
 	return p;
 }
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1326482

FromChristian Borntraeger <borntraeger@de.ibm.com>
Date2016-02-04 09:40 +0100
Message-ID<qYnCj-69d-21@gated-at.bofh.it>
In reply to#1326422
On 02/04/2016 06:56 AM, Joonsoo Kim wrote:
> We can disable debug_pagealloc processing even if the code is complied
> with CONFIG_DEBUG_PAGEALLOC. This patch changes the code to query
> whether it is enabled or not in runtime.
> 
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
>  mm/slub.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 7d4da68..7b5a965 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -256,11 +256,12 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)
>  {
>  	void *p;
> 
> -#ifdef CONFIG_DEBUG_PAGEALLOC
> -	probe_kernel_read(&p, (void **)(object + s->offset), sizeof(p));
> -#else
> -	p = get_freepointer(s, object);
> -#endif
> +	if (debug_pagealloc_enabled()) {
> +		probe_kernel_read(&p,
> +			(void **)(object + s->offset), sizeof(p));

Hmm, this might be a good case for a line longer than 80 chars....

As an alternative revert the logic and return early:


	if (!debug_pagealloc_enabled())
		return get_freepointer(s, object);
	probe_kernel_read(&p, (void **)(object + s->offset), sizeof(p));
	return p;

?


> +	} else
> +		p = get_freepointer(s, object);
> +
>  	return p;
>  }
> 

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


#1326975

FromJoonsoo Kim <js1304@gmail.com>
Date2016-02-04 17:30 +0100
Message-ID<qYuXa-4mU-53@gated-at.bofh.it>
In reply to#1326482
2016-02-04 17:31 GMT+09:00 Christian Borntraeger <borntraeger@de.ibm.com>:
> On 02/04/2016 06:56 AM, Joonsoo Kim wrote:
>> We can disable debug_pagealloc processing even if the code is complied
>> with CONFIG_DEBUG_PAGEALLOC. This patch changes the code to query
>> whether it is enabled or not in runtime.
>>
>> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>> ---
>>  mm/slub.c | 11 ++++++-----
>>  1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 7d4da68..7b5a965 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -256,11 +256,12 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)
>>  {
>>       void *p;
>>
>> -#ifdef CONFIG_DEBUG_PAGEALLOC
>> -     probe_kernel_read(&p, (void **)(object + s->offset), sizeof(p));
>> -#else
>> -     p = get_freepointer(s, object);
>> -#endif
>> +     if (debug_pagealloc_enabled()) {
>> +             probe_kernel_read(&p,
>> +                     (void **)(object + s->offset), sizeof(p));
>
> Hmm, this might be a good case for a line longer than 80 chars....
>
> As an alternative revert the logic and return early:
>
>
>         if (!debug_pagealloc_enabled())
>                 return get_freepointer(s, object);
>         probe_kernel_read(&p, (void **)(object + s->offset), sizeof(p));
>         return p;
>

Looks better!
I will fix it on next version.

Thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web