Skip to contentSkip to conversation

UBI WL-Subsys: Improvement in prot tree

PATCH Artem Bityutskiy 2 participants 2 messages Dec 9, 2008 – Dec 10, 2008 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Review

Quoted 7 lines · xiaochuan-xu
(quoted diff) +7 -0
+/*
+ * It's impossible that the first field of rb_node structure is equal to 0x2
+ * and 0x3, so Ox2 is used to check whether the physical eraseblock is in one
+ * of prot lists or not. 0x3 is used for prot list head's mark.
+ */
+#define PROT_LIST_NODE 0x2
+#define PROT_LIST_HEAD 0x3

This is hacky a bit. AFAIK, rb-tree code does have optimizations which use the lowest bits of pointers, so I am not sure 2 and 3 are completely impossible.

But I think this is anyway not needed at all. The only reason you need this is to quickly find out if the entry is in the protection list or not, right? And from the code I see the only user of this is the 'paranoid_check_in_prot_lists()' function. But this is just a debugging function, which is normally compiled out. You do not have to optimize it at all. Just let it walk the list and check.

So, please, let's get rid of these constants.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#2 lore raw
Quoted 10 lines · Artem Bityutskiy

Review

Quoted 7 lines · xiaochuan-xu
(quoted diff) +7 -0
+/*
+ * It's impossible that the first field of rb_node structure is equal to 0x2
+ * and 0x3, so Ox2 is used to check whether the physical eraseblock is in one
+ * of prot lists or not. 0x3 is used for prot list head's mark.
+ */
+#define PROT_LIST_NODE 0x2
+#define PROT_LIST_HEAD 0x3

This is hacky a bit.

Thanks for your reminding. I'll get rid of them.

Quoted 4 lines

AFAIK, rb-tree code does have optimizations which
use the lowest bits of pointers, so I am not sure 2 and 3 are completely impossible.

BTW, if I understand the RB-tree well, the 2nd bit of @rb_parent (the 1st field of struct rb_node) is impossible to be "1". Correct me, if I'm wrong. Thanks!

Quoted 8 lines

But I think this is anyway not needed at all. The only reason you need this is to quickly find out if the entry is in the protection list or not, right? And from the code I see the only user of this is the 'paranoid_check_in_prot_lists()' function. But this is just a debugging function, which is normally compiled out. You do not have to optimize it at all. Just let it walk the list and check.

So, please, let's get rid of these constants.

OK!

Quoted 1 line
Signature · 2 lines
Yours sincerely
xiaochuan-xu(cqu.edu.cn)