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: <c748a3ee-bf33-e13e-d507-984277acbb32@huaweicloud.com>
Date: Thu, 31 Jul 2025 10:38:58 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: yukuai@...nel.org, Jan Kara <jack@...e.cz>,
 Yu Kuai <yukuai1@...weicloud.com>
Cc: axboe@...nel.dk, akpm@...ux-foundation.org, yang.yang@...o.com,
 dlemoal@...nel.org, ming.lei@...hat.com, linux-block@...r.kernel.org,
 linux-kernel@...r.kernel.org, yi.zhang@...wei.com, yangerkun@...wei.com,
 johnny.chenyi@...wei.com, Omar Sandoval <osandov@...com>,
 "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH v2 1/2] lib/sbitmap: convert shallow_depth from one word
 to the whole sbitmap

Hi,

在 2025/07/31 2:24, Yu Kuai 写道:
> hi, Jan!
> 
> 在 2025/7/30 21:03, Jan Kara 写道:
>> I think having two APIs will be even more confusing than the current 
>> state.
>> But as I wrote I think you can have API to specify shallow depth in total
>> size and in sbitmap_queue_get_shallow() do:
>>
>> shallow_per_word = (shallow_depth << sb->shift) / sb->depth;
In order to consider the last word, I think we should use __map_depth()
here.

>> rounding_index = shallow_depth - shallow_per_word * sb->depth;
And then it's not possible to calculate this rounding index easily. How
about following, although the reminder handling is not perfect.

  static unsigned int __map_depth_with_shallow(const struct sbitmap *sb,
                                              int index,
                                              unsigned int shallow_depth)
  {
         unsigned int word_depth = __map_depth(sb, index);
         unsigned int shallow_word_depth = word_depth * shallow_depth;
         unsigned reminder = do_div(shallow_word_depth, sb->depth);

         if (reminder && !(index & 0x1))
                 shallow_word_depth++;

         return shallow_word_depth;
  }


>>
>> and allow depth shallow_per_word + 1 if current index < rounding_index 
>> and
>> exactly shallow_per_word if current index >= rounding_index. This will
>> still evenly distribute shallow depth among words and I don't think the
>> additional overhead of the several arithmetic operations will be visible.
> Yes, you're right, I did not get your idea before. Thanks for the 
> explanation
> and the suggestion :) Will follow this idea in the next version.

> 
> Thanks
> 
> .
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ