RE: [PATCH v10 05/20] dlb: add scheduling domain configuration
flat view
From: Chen, Mike Ximing <hidden>
Date: 2021-03-10 01:36:02
-----Original Message----- From: Greg KH <gregkh@linuxfoundation.org> On Wed, Feb 10, 2021 at 11:54:08AM -0600, Mike Ximing Chen wrote:quoted
+static inline int dlb_bitmap_clear_range(struct dlb_bitmap *bitmap, + unsigned int bit, + unsigned int len) +{ + if (!bitmap || !bitmap->map) + return -EINVAL; + + if (bitmap->len <= bit) + return -EINVAL; + + bitmap_clear(bitmap->map, bit, len); + + return 0; +}Why isn't logic like this just added to the lib/bitmap.c file?quoted
+static inline int dlb_bitmap_find_set_bit_range(struct dlb_bitmap *bitmap, + unsigned int len) +{ + struct dlb_bitmap *complement_mask = NULL; + int ret; + + if (!bitmap || !bitmap->map || len == 0) + return -EINVAL; + + if (bitmap->len < len) + return -ENOENT; + + ret = dlb_bitmap_alloc(&complement_mask, bitmap->len); + if (ret) + return ret; + + bitmap_zero(complement_mask->map, complement_mask->len); + + bitmap_complement(complement_mask->map, bitmap->map, bitmap->len); + + ret = bitmap_find_next_zero_area(complement_mask->map, + complement_mask->len, + 0, + len, + 0); + + dlb_bitmap_free(complement_mask); + + /* No set bit range of length len? */ + return (ret >= (int)bitmap->len) ? -ENOENT : ret; +}Same here, why not put this in the core kernel instead of a tiny random driver like this?
OK, we will put them in include/Linux/bitmap.h. Thanks Mike