]> Git Repo - linux.git/blobdiff - lib/sbitmap.c
mm: fs: invalidate BH LRU during page migration
[linux.git] / lib / sbitmap.c
index e395435654aa60ce6b9be39448986a3ac91bd660..47b3691058eb693a68de6a31403527f5dcc4e2c4 100644 (file)
@@ -87,19 +87,9 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
        unsigned int bits_per_word;
        unsigned int i;
 
-       if (shift < 0) {
-               shift = ilog2(BITS_PER_LONG);
-               /*
-                * If the bitmap is small, shrink the number of bits per word so
-                * we spread over a few cachelines, at least. If less than 4
-                * bits, just forget about it, it's not going to work optimally
-                * anyway.
-                */
-               if (depth >= 4) {
-                       while ((4U << shift) > depth)
-                               shift--;
-               }
-       }
+       if (shift < 0)
+               shift = sbitmap_calculate_shift(depth);
+
        bits_per_word = 1U << shift;
        if (bits_per_word > BITS_PER_LONG)
                return -EINVAL;
@@ -334,20 +324,21 @@ static unsigned int __sbitmap_weight(const struct sbitmap *sb, bool set)
        return weight;
 }
 
-static unsigned int sbitmap_weight(const struct sbitmap *sb)
+static unsigned int sbitmap_cleared(const struct sbitmap *sb)
 {
-       return __sbitmap_weight(sb, true);
+       return __sbitmap_weight(sb, false);
 }
 
-static unsigned int sbitmap_cleared(const struct sbitmap *sb)
+unsigned int sbitmap_weight(const struct sbitmap *sb)
 {
-       return __sbitmap_weight(sb, false);
+       return __sbitmap_weight(sb, true) - sbitmap_cleared(sb);
 }
+EXPORT_SYMBOL_GPL(sbitmap_weight);
 
 void sbitmap_show(struct sbitmap *sb, struct seq_file *m)
 {
        seq_printf(m, "depth=%u\n", sb->depth);
-       seq_printf(m, "busy=%u\n", sbitmap_weight(sb) - sbitmap_cleared(sb));
+       seq_printf(m, "busy=%u\n", sbitmap_weight(sb));
        seq_printf(m, "cleared=%u\n", sbitmap_cleared(sb));
        seq_printf(m, "bits_per_word=%u\n", 1U << sb->shift);
        seq_printf(m, "map_nr=%u\n", sb->map_nr);
This page took 0.032881 seconds and 4 git commands to generate.