mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: wuchi <wuchi.zero@gmail.com>
Cc: tglx@linutronix.de, hch@lst.de, keescook@chromium.org,
	longman@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/debugobjects: Fix stat count and optimize debug_objects_mem_init.
Date: Sun, 17 Jul 2022 17:24:24 -0700	[thread overview]
Message-ID: <20220717172424.4d9689133fd688fb57308e1c@linux-foundation.org> (raw)
In-Reply-To: <20220611130634.99741-1-wuchi.zero@gmail.com>

On Sat, 11 Jun 2022 21:06:34 +0800 wuchi <wuchi.zero@gmail.com> wrote:

> 1. Var debug_objects_allocated tracks valid kmem_cache_alloc calls, so
> track it in debug_objects_replace_static_objects. Do similar things in
> object_cpu_offline.
> 
> 2. In debug_objects_mem_init, there is no need to call function
> cpuhp_setup_state_nocalls when debug_objects_enabled = 0 (out of memory).
> 

Could we please have some review input here?

> --- a/lib/debugobjects.c
> +++ b/lib/debugobjects.c
> @@ -437,6 +437,7 @@ static int object_cpu_offline(unsigned int cpu)
>  	struct debug_percpu_free *percpu_pool;
>  	struct hlist_node *tmp;
>  	struct debug_obj *obj;
> +	unsigned long flags;
>  
>  	/* Remote access is safe as the CPU is dead already */
>  	percpu_pool = per_cpu_ptr(&percpu_obj_pool, cpu);
> @@ -444,6 +445,12 @@ static int object_cpu_offline(unsigned int cpu)
>  		hlist_del(&obj->node);
>  		kmem_cache_free(obj_cache, obj);
>  	}
> +
> +	raw_spin_lock_irqsave(&pool_lock, flags);
> +	obj_pool_used -= percpu_pool->obj_free;
> +	debug_objects_freed += percpu_pool->obj_free;
> +	raw_spin_unlock_irqrestore(&pool_lock, flags);
> +
>  	percpu_pool->obj_free = 0;
>  
>  	return 0;
> @@ -1318,6 +1325,8 @@ static int __init debug_objects_replace_static_objects(void)
>  		hlist_add_head(&obj->node, &objects);
>  	}
>  
> +	debug_objects_allocated += i;
> +
>  	/*
>  	 * debug_objects_mem_init() is now called early that only one CPU is up
>  	 * and interrupts have been disabled, so it is safe to replace the
> @@ -1386,6 +1395,7 @@ void __init debug_objects_mem_init(void)
>  		debug_objects_enabled = 0;
>  		kmem_cache_destroy(obj_cache);
>  		pr_warn("out of memory.\n");
> +		return;
>  	} else
>  		debug_objects_selftest();
>  


      reply	other threads:[~2022-07-18  0:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-11 13:06 wuchi
2022-07-18  0:24 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220717172424.4d9689133fd688fb57308e1c@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=wuchi.zero@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®