lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YEc/prj8X12/rqVI@kroah.com>
Date:   Tue, 9 Mar 2021 10:28:06 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Mike Ximing Chen <mike.ximing.chen@...el.com>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        arnd@...db.de, dan.j.williams@...el.com,
        pierre-louis.bossart@...ux.intel.com,
        Gage Eads <gage.eads@...el.com>
Subject: Re: [PATCH v10 05/20] dlb: add scheduling domain configuration

On Wed, Feb 10, 2021 at 11:54:08AM -0600, Mike Ximing Chen wrote:
> +/**
> + * dlb_bitmap_clear_range() - clear a range of bitmap entries
> + * @bitmap: pointer to dlb_bitmap structure.
> + * @bit: starting bit index.
> + * @len: length of the range.
> + *
> + * Return:
> + * Returns 0 upon success, < 0 otherwise.
> + *
> + * Errors:
> + * EINVAL - bitmap is NULL or is uninitialized, or the range exceeds the bitmap
> + *	    length.
> + */
> +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?

> +/**
> + * dlb_bitmap_find_set_bit_range() - find an range of set bits
> + * @bitmap: pointer to dlb_bitmap structure.
> + * @len: length of the range.
> + *
> + * This function looks for a range of set bits of length @len.
> + *
> + * Return:
> + * Returns the base bit index upon success, < 0 otherwise.
> + *
> + * Errors:
> + * ENOENT - unable to find a length *len* range of set bits.
> + * EINVAL - bitmap is NULL or is uninitialized, or len is invalid.
> + */
> +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?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ