All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] Let pseudo->users loop on duplicate version of list
@ 2017-07-10 15:32 Christopher Li
  2017-07-11 20:53 ` Christopher Li
  0 siblings, 1 reply; 44+ messages in thread
From: Christopher Li @ 2017-07-10 15:32 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: Linux-Sparse, Dibyendu Majumdar, Linus Torvalds

I found a temporary solution is simple enough.

Instead of marking the entry deleted. I just use a duplicate
version of the list->list[] when doing the loop. It will have
unwanted effect that iterator will issue some ptr are already
deleted. Other than that, it is very straight forward.

It pass the kernel compile test without issue different warnings.
It also pass the ptrlist ref checking. The ref count patch can now
complete the full kernel check without die() on it. Again no difference
in warning.

Chris


From 18453b4b920ae53f25bc389609218d97e7f583a1 Mon Sep 17 00:00:00 2001
From: Christopher Li <sparse@chrisli.org>
Date: Mon, 10 Jul 2017 07:53:21 -0700
Subject: [PATCH] Let pseudo->users loop on duplicate version of list

pseudo->users list will change during find dominator.
That cause a bug in the ptrlist because the outer loop iterator
is not award of the deletion of the entry.

Let the outer loop using a duplicate version of entry
to avoid this problem for now.

This is to fix the bug report by the ptrlist ref counting check.
With this change, the ptrlist ref counting check can complete
the kernel compile without reporting an error.

Signed-of-By: Christopher Li <sparse@chrisli.org>
---
 flow.c    |  7 ++++++-
 ptrlist.h | 17 +++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/flow.c b/flow.c
index fce8bde..2705448 100644
--- a/flow.c
+++ b/flow.c
@@ -730,7 +730,12 @@ multi_def:
 complex_def:
 external_visibility:
  all = 1;
- FOR_EACH_PTR_REVERSE(pseudo->users, pu) {
+ /*
+ * FIXME: pseudo->users will have some entry deleted during looping.
+ * The loop will run on a duplicated version of the list entry for now.
+ * Should fix it properly later.
+ */
+ FOR_EACH_PTR_REVERSE_DUP(pseudo->users, pu) {
  struct instruction *insn = pu->insn;
  if (insn->opcode == OP_LOAD)
  all &= find_dominating_stores(pseudo, insn, ++bb_generation, !mod);
diff --git a/ptrlist.h b/ptrlist.h
index d09be2f..5299ee5 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -184,6 +184,20 @@ static inline void *last_ptr_list(struct ptr_list *list)
  ptr = PTR_ENTRY(__list,__nr); \
  do {

+#define DO_FOR_EACH_REVERSE_DUP(head, ptr, __head, __list, __dup,
__nr, PTR_ENTRY) do { \
+ struct ptr_list *__head = (struct ptr_list *) (head); \
+ struct ptr_list *__list = __head; \
+ CHECK_TYPE(head,ptr); \
+ if (__head) { \
+ do { int __nr; \
+ __list = __list->prev; \
+ __nr = __list->nr; \
+ struct ptr_list __dup; \
+ memcpy(__dup.list, __list->list, sizeof(ptr)*__nr); \
+ while (--__nr >= 0) { \
+ do { \
+ ptr = PTR_ENTRY(&__dup,__nr); \
+ do {

 #define DO_END_FOR_EACH_REVERSE(ptr, __head, __list, __nr) \
  } while (0); \
@@ -231,6 +245,9 @@ static inline void *last_ptr_list(struct ptr_list *list)
 #define FOR_EACH_PTR_REVERSE(head, ptr) \
  DO_FOR_EACH_REVERSE(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY)

+#define FOR_EACH_PTR_REVERSE_DUP(head, ptr) \
+ DO_FOR_EACH_REVERSE_DUP(head, ptr, __head##ptr, __list##ptr,
__dup##ptr, __nr##ptr, PTR_ENTRY)
+
 #define END_FOR_EACH_PTR_REVERSE(ptr) \
  DO_END_FOR_EACH_REVERSE(ptr, __head##ptr, __list##ptr, __nr##ptr)

-- 
2.9.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2017-08-04 21:34 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 15:32 [PATCH RFC] Let pseudo->users loop on duplicate version of list Christopher Li
2017-07-11 20:53 ` Christopher Li
2017-07-11 21:04   ` Dibyendu Majumdar
2017-07-12  5:29     ` Christopher Li
2017-07-12 15:56       ` Dibyendu Majumdar
2017-07-12 17:03         ` Christopher Li
2017-07-12 18:05           ` Dibyendu Majumdar
2017-07-13  5:27             ` Christopher Li
2017-07-19 21:14               ` Luc Van Oostenryck
2017-07-19 21:42                 ` Christopher Li
2017-07-19 22:51                   ` Luc Van Oostenryck
2017-07-20  2:34                     ` Christopher Li
2017-08-02 23:44                       ` Luc Van Oostenryck
2017-08-03  0:50                         ` Christopher Li
2017-08-03 10:18                           ` Luc Van Oostenryck
2017-08-03 23:48                             ` Christopher Li
2017-08-04  0:41                               ` Luc Van Oostenryck
2017-08-04  2:22                                 ` Christopher Li
2017-08-04 10:38                                   ` Luc Van Oostenryck
2017-08-04 14:48                                     ` Christopher Li
2017-08-04 16:58                                       ` Luc Van Oostenryck
     [not found]                               ` <20170804002230.5047-1-luc.vanoostenryck@gmail.com>
2017-08-04 14:54                                 ` Fwd: [PATCH] mark pseudo user as deleted instead of removing them Christopher Li
2017-08-04 15:29                                   ` Christopher Li
2017-08-04 15:58                                     ` Luc Van Oostenryck
2017-08-04 18:19                                       ` Christopher Li
2017-08-04 19:12                                         ` Luc Van Oostenryck
2017-08-04 19:24                                           ` Christopher Li
2017-08-04 20:09                                             ` [PATCH 0/4] fix list corruption with recursive remove_usage() Luc Van Oostenryck
2017-08-04 20:09                                               ` [PATCH 1/4] ptrlist: add a counter for the number of removed elemnets Luc Van Oostenryck
2017-08-04 20:09                                               ` [PATCH 2/4] ptrlist: adjust ptr_list_size for the new ->rm field Luc Van Oostenryck
2017-08-04 20:09                                               ` [PATCH 3/4] ptrlist: add MARK_CURRENT_DELETED Luc Van Oostenryck
2017-08-04 20:09                                               ` [PATCH 4/4] mark pseudo users as deleted instead of removing them Luc Van Oostenryck
2017-08-04 20:17                                                 ` Christopher Li
2017-08-04 20:18                                                   ` Christopher Li
2017-08-04 20:34                                                   ` Luc Van Oostenryck
2017-08-04 20:48                                                     ` Christopher Li
2017-08-04 21:03                                                       ` Luc Van Oostenryck
2017-08-04 21:14                                                         ` Christopher Li
2017-08-04 21:34                                                           ` Luc Van Oostenryck
2017-08-04 16:54                                     ` [PATCH] mark pseudo user " Linus Torvalds
2017-08-04 18:33                                       ` Christopher Li
2017-08-04 20:08                                         ` Christopher Li
2017-08-04 20:37                                           ` Christopher Li
2017-07-13 12:23             ` [PATCH RFC] Let pseudo->users loop on duplicate version of list Christopher Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.