fix page_list_splice()
PATCH 1/1 fix page_list_splice()
Other than in __list_splice(), the first element's prev pointer doesn't need adjustment here - it already is PAGE_LIST_NULL. Rather than fixing the assignment (to formally match __list_splice()), simply assert that this assignment is really unnecessary.
xen/include/xen/mm.h +2 -1
@@ -270,7 +270,8 @@ page_list_splice(struct page_list_head * last = list->tail; at = head->next; - first->list.prev =page_to_pdx (head->next); +/* Both first->list.prev and at->list.prev are PAGE_LIST_NULL. */ +ASSERT (first->list.prev == at->list.prev); head->next = first; last->list.next =page_to_pdx (at);
fix page_list_splice()
Other than in __list_splice(), the first element's prev pointer doesn't need adjustment here - it already is PAGE_LIST_NULL. Rather than fixing the assignment (to formally match __list_splice()), simply assert that this assignment is really unnecessary.
xen/include/xen/mm.h +2 -1
@@ -270,7 +270,8 @@ page_list_splice(struct page_list_head * last = list->tail; at = head->next; - first->list.prev =page_to_pdx (head->next); +/* Both first->list.prev and at->list.prev are PAGE_LIST_NULL. */ +ASSERT (first->list.prev == at->list.prev); head->next = first; last->list.next =page_to_pdx (at);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 11 lines · Jan Beulich
Other than in
__list_splice(), the first element's prev pointer doesn't need adjustment here - it already isPAGE_LIST_NULL. Rather than fixing the assignment (to formally match__list_splice()), simply assert that this assignment is really unnecessary.Reported-by Jisoo Yang <[email protected]>Signed-off-by Jan Beulich <[email protected]>
xen/include/xen/mm.h page_list_splice(struct page_list_head * · line 273
Quoted 5 lines
xen/include/xen/mm.h +1
-1@@ -270,7 +270,8 @@ page_list_splice(struct page_list_head * last = list->tail; at = head->next; - first->list.prev =page_to_pdx (head->next); +/* Both first->list.prev and at->list.prev are PAGE_LIST_NULL. */
ASSERT(first->list.prev == PAGE_LIST_NULL); ?
It seems odd to have one assumption encoded as an ASSERTion, and one as a code comment... A second assertion makes the assumption explicit, and run-time checked in debug builds.
-- Keir
Quoted 11 lines
xen/include/xen/mm.h +1
-0+ASSERT (first->list.prev == at->list.prev); head->next = first; last->list.next =page_to_pdx (at);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 17 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 14 lines · Jan Beulich
Other than in
__list_splice(), the first element's prev pointer doesn't need adjustment here - it already isPAGE_LIST_NULL. Rather than fixing the assignment (to formally match__list_splice()), simply assert that this assignment is really unnecessary.Reported-by Jisoo Yang <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/include/xen/mm.h +0
-0@@ -270,7 +270,8 @@ page_list_splice(struct page_list_head * last = list->tail; at = head->next;
Quoted 8 lines
xen/include/xen/mm.h page_list_splice(struct page_list_head * · line 273
Quoted 2 lines
xen/include/xen/mm.h +1
-1- first->list.prev =page_to_pdx (head->next); +/* Both first->list.prev and at->list.prev are PAGE_LIST_NULL. */
ASSERT(first->list.prev == PAGE_LIST_NULL); ?It seems odd to have one assumption encoded as an ASSERTion, and one as a code comment... A second assertion makes the assumption explicit, and run-time checked in debug builds.
But the __list_splice() equivalent assignment would be
first->list.prev = at->list.prev;
which is why I chose the assert expression that way, yet made the comment clarify what the actual state is. If the comment just repeated what the ASSERT() already says, I'd rather drop the comment altogether.
Jan
Quoted 26 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 14 lines · Jan Beulich
Other than in
__list_splice(), the first element's prev pointer doesn't need adjustment here - it already isPAGE_LIST_NULL. Rather than fixing the assignment (to formally match__list_splice()), simply assert that this assignment is really unnecessary.Reported-by Jisoo Yang <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/include/xen/mm.h +0
-0@@ -270,7 +270,8 @@ page_list_splice(struct page_list_head * last = list->tail; at = head->next;Quoted 8 lines
xen/include/xen/mm.h page_list_splice(struct page_list_head * · line 273
Quoted 2 lines
xen/include/xen/mm.h +1
-1- first->list.prev =page_to_pdx (head->next); +/* Both first->list.prev and at->list.prev are PAGE_LIST_NULL. */
ASSERT(first->list.prev == PAGE_LIST_NULL); ?It seems odd to have one assumption encoded as an ASSERTion, and one as a code comment... A second assertion makes the assumption explicit, and run-time checked in debug builds.
Quoted 8 lines
But the
__list_splice()equivalent assignment would befirst->list.prev = at->list.prev;which is why I chose the assert expression that way, yet made the comment clarify what the actual state is. If the comment just repeated what the
ASSERT()already says, I'd rather drop the comment altogether.
I mean to replace the comment with a second assertion, not to replace the assertion your patch already adds. Does that make sense?
-- Keir
Quoted 2 lines
Jan
Quoted 21 lines
Quoted 1 line
Quoted 1 line
Keir Fraser <[email protected]> 06/06/12 1:28 PM >>>
Quoted 10 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
On 06/06/2012 09:23, "Jan Beulich" <[email protected]> wrote:
+ /* Bothfirst->list.prevandat->list.prevarePAGE_LIST_NULL. */
ASSERT(first->list.prev == PAGE_LIST_NULL); ?It seems odd to have one assumption encoded as an ASSERTion, and one as a code comment... A second assertion makes the assumption explicit, and run-time checked in debug builds.
Quoted 8 lines
But the
__list_splice()equivalent assignment would befirst->list.prev = at->list.prev;which is why I chose the assert expression that way, yet made the comment clarify what the actual state is. If the comment just repeated what the
ASSERT()already says, I'd rather drop the comment altogether.
Quoted 4 lines
I mean to replace the comment with a second assertion, not to replace the assertion your patch already adds. Does that make sense?
From the perspective of the operation here, we really just want to make
sure that the new list head's prev points to where the old one's pointed; the fact that they're both supposed to be PAGE_LIST_NULL doesn't really matter. Hence simply asserting that the assignment is superfluous seems the best choice to me, with the comment explaining why. If you have suggestions for better wording of the comment, I'll gladly take those.
The second best choice imo would be to just have the superfluous assignment there (making it likely that later someone will come and ask why it's there when not really needed).
Jan
Quoted 10 lines · Jan Beulich
Quoted 2 lines
I mean to replace the comment with a second assertion, not to replace the assertion your patch already adds. Does that make sense?
From the perspective of the operation here, we really just want to make sure that the new list head's prev points to where the old one's pointed; the fact that they're both supposed to be
PAGE_LIST_NULLdoesn't really matter. Hence simply asserting that the assignment is superfluous seems the best choice to me, with the comment explaining why. If you have suggestions for better wording of the comment, I'll gladly take those.
Quoted 3 lines
The second best choice imo would be to just have the superfluous assignment there (making it likely that later someone will come and ask why it's there when not really needed).
Well, I already did check in a version with two assertions, yesterday. :) I like assertions, and asserting things about the good form of the data structure being manipulated, even if that good form is not essential to this specific operation, is not necessarily bad. Especially while we're already asserting other things about those same list pointers.
It's not a major point here of course, it just seemed silly to to me to take up a source line with a comment which could be stated just as clearly with an assertion, and with added benefit (imo).
-- Keir
Quoted 2 lines
Jan