linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang.shi@linux.alibaba.com>
To: tglx@linutronix.de, longman@redhat.com
Cc: yang.shi@linux.alibaba.com, linux-kernel@vger.kernel.org
Subject: [PATCH 3/4 v6] lib: debugobjects: use global free list in free_object()
Date: Tue,  6 Feb 2018 07:18:27 +0800	[thread overview]
Message-ID: <1517872708-24207-4-git-send-email-yang.shi@linux.alibaba.com> (raw)
In-Reply-To: <1517872708-24207-1-git-send-email-yang.shi@linux.alibaba.com>

When the pool list is already full, just put the free objects on the
global free list, then schedule a work to move them to pool list or free
the memory later.

If the pool list is not full, just put the objects back to the pool
list.

Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman Long <longman@redhat.com>
---
 lib/debugobjects.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index c15fb5f..09f2469 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -266,27 +266,34 @@ static void free_obj_work(struct work_struct *work)
 	}
 }
 
-/*
- * Put the object back into the pool and schedule work to free objects
- * if necessary.
- */
-static void free_object(struct debug_obj *obj)
+static bool __free_object(struct debug_obj *obj)
 {
 	unsigned long flags;
-	int sched = 0;
+	bool work;
 
 	raw_spin_lock_irqsave(&pool_lock, flags);
-	/*
-	 * schedule work when the pool is filled and the cache is
-	 * initialized:
-	 */
-	if (obj_pool_free > debug_objects_pool_size && obj_cache)
-		sched = 1;
-	hlist_add_head(&obj->node, &obj_pool);
-	obj_pool_free++;
+	work = (obj_pool_free > debug_objects_pool_size) && obj_cache ?
+		true : false;
 	obj_pool_used--;
+
+	if (work) {
+		obj_nr_tofree++;
+		hlist_add_head(&obj->node, &obj_to_free);
+	} else {
+		obj_pool_free++;
+		hlist_add_head(&obj->node, &obj_pool);
+	}
 	raw_spin_unlock_irqrestore(&pool_lock, flags);
-	if (sched)
+	return work;
+}
+
+/*
+ * Put the object back into the pool and schedule work to free objects
+ * if necessary.
+ */
+static void free_object(struct debug_obj *obj)
+{
+	if (__free_object(obj))
 		schedule_work(&debug_obj_work);
 }
 
-- 
1.8.3.1

  parent reply	other threads:[~2018-02-05 23:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 23:18 [PATCH 0/4 v6] lib: debugobjects: Introduce new global free list and defer objects free via the free list Yang Shi
2018-02-05 23:18 ` [PATCH 1/4 v6] lib: debugobjects: export max loops counter Yang Shi
2018-02-12 15:04   ` Thomas Gleixner
2018-02-13 10:03   ` [tip:core/debugobjects] debugobjects: Export " tip-bot for Yang Shi
2018-02-05 23:18 ` [PATCH 2/4 v6] lib: debugobjects: add global free list and the counter Yang Shi
2018-02-12 15:52   ` Thomas Gleixner
2018-02-12 15:54     ` Thomas Gleixner
2018-02-12 18:53       ` Yang Shi
2018-02-12 16:25   ` Thomas Gleixner
2018-02-12 18:48     ` Yang Shi
2018-02-13 10:02       ` Thomas Gleixner
2018-02-14  5:33         ` Yang Shi
2018-02-13 10:04   ` [tip:core/debugobjects] debugobjects: Add " tip-bot for Yang Shi
2018-02-05 23:18 ` Yang Shi [this message]
2018-02-13 10:04   ` [tip:core/debugobjects] debugobjects: Use global free list in free_object() tip-bot for Yang Shi
2018-02-05 23:18 ` [PATCH 4/4 v6] lib: debugobjects: handle objects free in a batch outside the loop Yang Shi
2018-02-13 10:05   ` [tip:core/debugobjects] debugobjects: Use global free list in __debug_check_no_obj_freed() tip-bot for Yang Shi

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=1517872708-24207-4-git-send-email-yang.shi@linux.alibaba.com \
    --to=yang.shi@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).