lkml.org 
[lkml]   [2020]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 7/9] mm, slub: introduce kmem_cache_debug_flags()
From
Date
On 6/17/20 7:56 PM, Kees Cook wrote:
> On Wed, Jun 10, 2020 at 06:31:33PM +0200, Vlastimil Babka wrote:
>> There are few places that call kmem_cache_debug(s) (which tests if any of debug
>> flags are enabled for a cache) immediatelly followed by a test for a specific
>> flag. The compiler can probably eliminate the extra check, but we can make the
>> code nicer by introducing kmem_cache_debug_flags() that works like
>> kmem_cache_debug() (including the static key check) but tests for specifig
>> flag(s). The next patches will add more users.
>>
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> ---
>> mm/slub.c | 18 ++++++++++++++----
>> 1 file changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 24d3e5f832aa..c8e8b4ae2451 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -122,18 +122,28 @@ DEFINE_STATIC_KEY_FALSE(slub_debug_enabled);
>> #endif
>> #endif
>>
>> -static inline int kmem_cache_debug(struct kmem_cache *s)
>> +/*
>> + * Returns true if any of the specified slub_debug flags is enabled for the
>> + * cache. Use only for flags parsed by setup_slub_debug() as it also enables
>> + * the static key.
>> + */
>> +static inline int kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags)
>
> This should return slab_flag_t, yes?

bool, actually

>> {
>> #ifdef CONFIG_SLUB_DEBUG
>> if (static_branch_unlikely(&slub_debug_enabled))
>> - return s->flags & SLAB_DEBUG_FLAGS;
>> + return s->flags & flags;
>> #endif
>> return 0;
>> }
>>
>> +static inline int kmem_cache_debug(struct kmem_cache *s)
>
> And this too, as long as we're making changes here.

OK

\
 
 \ /
  Last update: 2020-06-18 10:32    [W:0.061 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site