Displaying 20 results from an estimated 90 matches for "is_power_of_2".
2023 Mar 07
3
[PATCH 1/3] virtio_pci_modern: Remove unnecessary num zero check
is_power_of_2() already performs the zero check. Hence avoid duplicate
check. While at it, move the query of size check also adjacent to where
its used for the disabled vq.
Signed-off-by: Feng Liu <feliu at nvidia.com>
Reviewed-by: Jiri Pirko <jiri at nvidia.com>
Reviewed-by: Parav Pandit <parav...
2018 Sep 17
4
[PATCH nbdkit v2] common: isaligned: Use a macro instead of relying on implicit truncation.
...6 +36,15 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include "ispowerof2.h"
/* Return true if size is a multiple of align. align must be power of 2.
*/
-static inline bool
-is_aligned (unsigned int size, unsigned int align)
-{
- assert (is_power_of_2 (align));
- return !(size & (align - 1));
-}
+#define IS_ALIGNED(size, align) ({ \
+ assert (is_power_of_2 ((align))); \
+ !((size) & ((align) - 1)); \
+})
#endif /* NBDKIT_ISALIGNED_H */
diff --git a/plugins/file/file.c b/plugins/file/file....
2020 Jul 21
1
[PATCH 01/10] block: introduce blk_is_valid_logical_block_size
...logical block size, in bytes
> + *
> + * Description:
> + * This function checks if the block layers supports given block size
> + **/
> +bool blk_is_valid_logical_block_size(unsigned int size)
> +{
> + return size >= SECTOR_SIZE && size <= PAGE_SIZE && !is_power_of_2(size);
Shouldn't this be a ... && is_power_of_2(size)?
> if (q->limits.io_min < q->limits.physical_block_size)
> q->limits.io_min = q->limits.physical_block_size;
> +
> }
This adds a pointless empty line.
> +extern bool blk_is_valid_logical_block_...
2023 Mar 10
1
[PATCH v2 1/3] virtio_pci_modern: Allow non power of 2 sizes for virtqueues
On 2023-03-10 a.m.8:36, Parav Pandit wrote:
>
>
>> From: Feng Liu <feliu at nvidia.com>
>> Sent: Friday, March 10, 2023 12:34 AM
>
>>
>> - if (!is_power_of_2(num)) {
>> - dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u",
>> num);
>> - return ERR_PTR(-EINVAL);
>> - }
>> -
>
> The check is still valid for split q.
> Maybe the right place for such a check is not the pci transport driver.
>...
2023 Mar 11
1
[PATCH v2 1/3] virtio_pci_modern: Allow non power of 2 sizes for virtqueues
...n Fri, Mar 10, 2023 at 10:23:16AM -0500, Feng Liu wrote:
>
>
> On 2023-03-10 a.m.8:36, Parav Pandit wrote:
> >
> >
> > > From: Feng Liu <feliu at nvidia.com>
> > > Sent: Friday, March 10, 2023 12:34 AM
> >
> > >
> > > - if (!is_power_of_2(num)) {
> > > - dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u",
> > > num);
> > > - return ERR_PTR(-EINVAL);
> > > - }
> > > -
> >
> > The check is still valid for split q.
> > Maybe the right place for such...
2023 Mar 08
1
[PATCH 1/3] virtio_pci_modern: Remove unnecessary num zero check
On Tue, Mar 7, 2023 at 11:57?AM Feng Liu <feliu at nvidia.com> wrote:
>
> is_power_of_2() already performs the zero check. Hence avoid duplicate
> check. While at it, move the query of size check also adjacent to where
> its used for the disabled vq.
>
> Signed-off-by: Feng Liu <feliu at nvidia.com>
> Reviewed-by: Jiri Pirko <jiri at nvidia.com>
> Reviewe...
2023 Mar 11
1
[PATCH v2 1/3] virtio_pci_modern: Allow non power of 2 sizes for virtqueues
...10:23:16AM -0500, Feng Liu wrote:
>>
>>
>> On 2023-03-10 a.m.8:36, Parav Pandit wrote:
>>>
>>>
>>>> From: Feng Liu <feliu at nvidia.com>
>>>> Sent: Friday, March 10, 2023 12:34 AM
>>>
>>>>
>>>> - if (!is_power_of_2(num)) {
>>>> - dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u",
>>>> num);
>>>> - return ERR_PTR(-EINVAL);
>>>> - }
>>>> -
>>>
>>> The check is still valid for split q.
>>>...
2023 Mar 12
1
[PATCH v2 1/3] virtio_pci_modern: Allow non power of 2 sizes for virtqueues
...gt; On 2023-03-10 a.m.8:36, Parav Pandit wrote:
> > > >
> > > >
> > > > > From: Feng Liu <feliu at nvidia.com>
> > > > > Sent: Friday, March 10, 2023 12:34 AM
> > > >
> > > > >
> > > > > - if (!is_power_of_2(num)) {
> > > > > - dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u",
> > > > > num);
> > > > > - return ERR_PTR(-EINVAL);
> > > > > - }
> > > > > -
> > > >
> > >...
2018 Sep 17
2
[PATCH nbdkit v2] common: Introduce round up, down; and divide round
Since we're using ({ .. }) gcc/clang extension, let's rewrite the
rounding.h change too.
Rich.
2020 Jul 15
3
[PATCH] virtio-blk: check host supplied logical block size
...@ static const struct blk_mq_ops virtio_mq_ops = {
static unsigned int virtblk_queue_depth;
module_param_named(queue_depth, virtblk_queue_depth, uint, 0444);
+
+static bool virtblk_valid_block_size(unsigned int blksize)
+{
+ return blksize >= 512 && blksize <= PAGE_SIZE && is_power_of_2(blksize);
+}
+
static int virtblk_probe(struct virtio_device *vdev)
{
struct virtio_blk *vblk;
@@ -809,9 +815,16 @@ static int virtblk_probe(struct virtio_device *vdev)
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
struct virtio_blk_config, blk_size,
&blk_size);...
2020 Jul 15
3
[PATCH] virtio-blk: check host supplied logical block size
...@ static const struct blk_mq_ops virtio_mq_ops = {
static unsigned int virtblk_queue_depth;
module_param_named(queue_depth, virtblk_queue_depth, uint, 0444);
+
+static bool virtblk_valid_block_size(unsigned int blksize)
+{
+ return blksize >= 512 && blksize <= PAGE_SIZE && is_power_of_2(blksize);
+}
+
static int virtblk_probe(struct virtio_device *vdev)
{
struct virtio_blk *vblk;
@@ -809,9 +815,16 @@ static int virtblk_probe(struct virtio_device *vdev)
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
struct virtio_blk_config, blk_size,
&blk_size);...
2023 Mar 15
2
[PATCH v2 1/3] virtio_ring: Allow non power of 2 sizes for packed virtqueue
...ex 9e496e288cfa..6e713904d8e8 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -310,11 +310,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
if (!num || vp_modern_get_queue_enable(mdev, index))
return ERR_PTR(-ENOENT);
- if (!is_power_of_2(num)) {
- dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num);
- return ERR_PTR(-EINVAL);
- }
-
info->msix_vector = msix_vec;
/* create the vring */
--
2.34.1
2012 Apr 02
2
[PATCH 0/2] Fix btrfs blocksize and bind mkfs.btrfs (RHBZ#807905).
https://bugzilla.redhat.com/show_bug.cgi?id=807905
Currently if you specify the blocksize parameter to mkfs-opts with a
btrfs filesystem, then it fails, because mkfs.btrfs interprets the -b
option as meaning filesystem size.
The first patch fixes this by disallowing blocksize (it cannot be
mapped meaningfully into btrfs parameters).
The second patch adds the full /sbin/mkfs.btrfs utility to the
2019 May 24
1
[RFC][PATCH] kernel.h: Add generic roundup_64() macro
...gt;> } else { \
>>
>> You probably want
>>
>> if (!(__y & (__y - 1))
>>
>> --
>
> Yes I do. I corrected it in my next email.
>
> http://lkml.kernel.org/r/20190523133648.591f9e78 at gandalf.local.home
Or perhaps just using is_power_of_2 from include/linux/log2.h ?
>
>> #define roundup(x, y) ( \
>> { \
>> typeof(y) __y = y; \
>> typeof(x) __x; \
>> \
>> if (__y & (__y - 1)) \
>> __x = round_up(x, __y); \
>> else \
>> __x = (((x)...
2018 Sep 17
0
[PATCH nbdkit v3 1/3] common: isaligned: Use a macro instead of relying on implicit truncation.
...6 +36,15 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include "ispowerof2.h"
/* Return true if size is a multiple of align. align must be power of 2.
*/
-static inline bool
-is_aligned (unsigned int size, unsigned int align)
-{
- assert (is_power_of_2 (align));
- return !(size & (align - 1));
-}
+#define IS_ALIGNED(size, align) ({ \
+ assert (is_power_of_2 ((align))); \
+ !((size) & ((align) - 1)); \
+})
#endif /* NBDKIT_ISALIGNED_H */
diff --git a/plugins/file/file.c b/plugins/file/file....
2023 Mar 10
1
[PATCH v2 1/3] virtio_pci_modern: Allow non power of 2 sizes for virtqueues
...ex 9e496e288cfa..6e713904d8e8 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -310,11 +310,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
if (!num || vp_modern_get_queue_enable(mdev, index))
return ERR_PTR(-ENOENT);
- if (!is_power_of_2(num)) {
- dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num);
- return ERR_PTR(-EINVAL);
- }
-
info->msix_vector = msix_vec;
/* create the vring */
--
2.34.1
2020 Jul 15
2
[PATCH] virtio-blk: check host supplied logical block size
...t virtblk_queue_depth;
> > module_param_named(queue_depth, virtblk_queue_depth, uint, 0444);
> >
> > +
> > +static bool virtblk_valid_block_size(unsigned int blksize)
> > +{
> > + return blksize >= 512 && blksize <= PAGE_SIZE &&
> > is_power_of_2(blksize);
> > +}
> > +
>
> Is this a blk core assumption? in that case, does not this belong
> in blk core?
It is a blk core assumption.
I had checked other drivers and these that have variable block size all
check this manually like that.
I don't mind fixing all of the...
2020 Jul 15
2
[PATCH] virtio-blk: check host supplied logical block size
...t virtblk_queue_depth;
> > module_param_named(queue_depth, virtblk_queue_depth, uint, 0444);
> >
> > +
> > +static bool virtblk_valid_block_size(unsigned int blksize)
> > +{
> > + return blksize >= 512 && blksize <= PAGE_SIZE &&
> > is_power_of_2(blksize);
> > +}
> > +
>
> Is this a blk core assumption? in that case, does not this belong
> in blk core?
It is a blk core assumption.
I had checked other drivers and these that have variable block size all
check this manually like that.
I don't mind fixing all of the...
2018 Sep 17
0
Re: [PATCH nbdkit v2] common: isaligned: Use a macro instead of relying on implicit truncation.
...<stdint.h>
>
Not need with this change...
>
> #include "ispowerof2.h"
>
> /* Return true if size is a multiple of align. align must be power of 2.
> */
> -static inline bool
> -is_aligned (unsigned int size, unsigned int align)
> -{
> - assert (is_power_of_2 (align));
> - return !(size & (align - 1));
> -}
> +#define IS_ALIGNED(size, align) ({ \
> + assert (is_power_of_2 ((align))); \
> + !((size) & ((align) - 1)); \
> +})
>
But this version will happily accept singed int, and...
2018 Sep 17
2
Re: [PATCH nbdkit v2] common: isaligned: Use a macro instead of relying on implicit truncation.
On 9/17/18 3:39 PM, Nir Soffer wrote:
>> +#define IS_ALIGNED(size, align) ({ \
>> + assert (is_power_of_2 ((align))); \
>> + !((size) & ((align) - 1)); \
>> +})
>>
>
> But this version will happily accept singed int, and I think this code
> behavior with signed int is undefined.
Well, sort of. Bit shifts are very likely to hit undefined behav...