[PATCH] ida: document IDA_BITMAP_LONGS calculation

From: Namhyung Kim
Date: Thu Sep 02 2010 - 13:44:47 EST


IDA_BITMAP_LONGS value is calculated take into account struct ida_bitmap
not to waste memory space. Comment it.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
---
include/linux/idr.h | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/linux/idr.h b/include/linux/idr.h
index e968db7..7807e4b 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -119,9 +119,16 @@ void idr_init(struct idr *idp);
* pointer isn't necessary.
*/
#define IDA_CHUNK_SIZE 128 /* 128 bytes per chunk */
+/*
+ * -1 is needed here to fit total chunk size into 128 bytes because
+ * struct ida_bitmap consists of nr_busy and bitmap. Since it is
+ * allocated by kmalloc(), chunk size should be matched with kmalloc
+ * size so that it will not waste memory.
+ */
#define IDA_BITMAP_LONGS (128 / sizeof(long) - 1)
-#define IDA_BITMAP_BITS (IDA_BITMAP_LONGS * sizeof(long) * 8)
+#define IDA_BITMAP_BITS (IDA_BITMAP_LONGS * sizeof(long) * 8)

+/* IDA bitmap chunk */
struct ida_bitmap {
long nr_busy;
unsigned long bitmap[IDA_BITMAP_LONGS];
--
1.7.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/