From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/2] mark lists to be repacked as dirty
Date: Thu, 17 Nov 2016 18:25:59 +0100 [thread overview]
Message-ID: <20161117172559.29417-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20161117172559.29417-1-luc.vanoostenryck@gmail.com>
Use a bit in the head of a ptrlist and set it when
DELETE_PTR() is called.
Check the bit when repacking a list and do nothing if the
bit is not set.
Note: delete_ptr_list_entry() & delete_ptr_list_last()
don't need any handling because they either always call
pack_ptr_list() or remove the last block when it becomes empty.
Suggested-by: Christopher Li <sparse@chrisli.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
ptrlist.c | 7 +++++++
ptrlist.h | 4 +++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/ptrlist.c b/ptrlist.c
index 5dc1117c..e817bad1 100644
--- a/ptrlist.c
+++ b/ptrlist.c
@@ -70,6 +70,11 @@ void pack_ptr_list(struct ptr_list **listp)
if (head) {
struct ptr_list *entry = head;
+
+ if (!head->dirty)
+ return;
+ head->dirty = 0;
+
do {
struct ptr_list *next;
restart:
@@ -138,6 +143,7 @@ void **__add_ptr_list(struct ptr_list **listp, void *ptr, unsigned long tag)
list->prev = newlist;
last->next = newlist;
}
+ newlist->dirty = 0;
last = newlist;
nr = 0;
}
@@ -188,6 +194,7 @@ void * undo_ptr_list_last(struct ptr_list **head)
if (!first)
return NULL;
+ first->dirty = 1;
last = first;
do {
last = last->prev;
diff --git a/ptrlist.h b/ptrlist.h
index 61e159fd..c24bfb82 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -25,7 +25,8 @@
#define LIST_NODE_NR (29)
struct ptr_list {
- int nr;
+ int nr:31;
+ unsigned int dirty:1; // will need to be repacked
struct ptr_list *prev;
struct ptr_list *next;
void *list[LIST_NODE_NR];
@@ -254,6 +255,7 @@ extern void split_ptr_list_head(struct ptr_list *);
__this++; \
} \
*__this = (void *)0xf0f0f0f0; \
+ __head->dirty = 1; \
__list->nr--; __nr--; \
} while (0)
--
2.10.2
next prev parent reply other threads:[~2016-11-17 17:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-17 17:25 [PATCH 0/2] be more generous with ptrlist repacking Luc Van Oostenryck
2016-11-17 17:25 ` [PATCH 1/2] add missing PACK_PTR_LIST() Luc Van Oostenryck
2016-11-17 17:25 ` Luc Van Oostenryck [this message]
2016-11-17 17:40 ` [PATCH 0/2] be more generous with ptrlist repacking Linus Torvalds
2016-11-17 18:17 ` Christopher Li
2016-11-17 20:25 ` Luc Van Oostenryck
2016-11-17 22:03 ` Linus Torvalds
2016-11-18 0:29 ` Luc Van Oostenryck
2016-11-28 21:15 ` Luc Van Oostenryck
2016-12-06 0:24 ` Christopher Li
2016-11-18 12:26 ` Luc Van Oostenryck
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=20161117172559.29417-3-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/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).