<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/lib/math, branch v6.16</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.16</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.16'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2025-02-12T22:00:11Z</updated>
<entry>
<title>lib/prime_numbers: convert self-test to KUnit</title>
<updated>2025-02-12T22:00:11Z</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@gmail.com</email>
</author>
<published>2025-02-09T02:44:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=313b38a6ecb46db4002925af91b64df4f2b76d1f'/>
<id>urn:sha1:313b38a6ecb46db4002925af91b64df4f2b76d1f</id>
<content type='text'>
Extract a private header and convert the prime_numbers self-test to a
KUnit test. I considered parameterizing the test using
`KUNIT_CASE_PARAM` but didn't see how it was possible since the test
logic is entangled with the test parameter generation logic.

Signed-off-by: Tamir Duberstein &lt;tamird@gmail.com&gt;
Link: https://lore.kernel.org/r/20250208-prime_numbers-kunit-convert-v5-2-b0cb82ae7c7d@gmail.com
Signed-off-by: Kees Cook &lt;kees@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/math: Add Kunit test suite for gcd()</title>
<updated>2025-02-12T22:00:11Z</updated>
<author>
<name>Yu-Chun Lin</name>
<email>eleanor15x@gmail.com</email>
</author>
<published>2025-02-03T07:54:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9ab61886ac683e8ff1b261a1738d5e68cd645604'/>
<id>urn:sha1:9ab61886ac683e8ff1b261a1738d5e68cd645604</id>
<content type='text'>
Add a KUnit test suite for the gcd() function.
This test suite verifies the correctness of gcd() across various
scenarios, including edge cases.

Signed-off-by: Yu-Chun Lin &lt;eleanor15x@gmail.com&gt;
Reviewed-by: Kuan-Wei Chiu &lt;visitorckw@gmail.com&gt;
Link: https://lore.kernel.org/r/20250203075400.3431330-1-eleanor15x@gmail.com
Signed-off-by: Kees Cook &lt;kees@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/math: Add int_log test suite</title>
<updated>2025-02-11T02:25:37Z</updated>
<author>
<name>Bruno Sobreira França</name>
<email>brunofrancadevsec@gmail.com</email>
</author>
<published>2024-12-02T07:55:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=84ec093f55f58f5a4a66eb98bd6b6af413190bde'/>
<id>urn:sha1:84ec093f55f58f5a4a66eb98bd6b6af413190bde</id>
<content type='text'>
This commit introduces KUnit tests for the intlog2 and intlog10
functions, which compute logarithms in base 2 and base 10, respectively.
The tests cover a range of inputs to ensure the correctness of these
functions across common and edge cases.

Signed-off-by: Bruno Sobreira França &lt;brunofrancadevsec@gmail.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Link: https://lore.kernel.org/r/20241202075545.3648096-3-davidgow@google.com
Signed-off-by: Kees Cook &lt;kees@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib: math: Move KUnit tests into tests/ subdir</title>
<updated>2025-02-11T02:24:57Z</updated>
<author>
<name>Luis Felipe Hernandez</name>
<email>luis.hernandez093@gmail.com</email>
</author>
<published>2024-12-02T07:55:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3e50ba8fc834cadead733e4feeb969fce2f3b6e1'/>
<id>urn:sha1:3e50ba8fc834cadead733e4feeb969fce2f3b6e1</id>
<content type='text'>
This patch is a follow-up task from a discussion stemming from point 3
in a recent patch introducing the int_pow kunit test [1] and
documentation regarding kunit test style and nomenclature [2].

Colocate all kunit test suites in lib/math/tests/ and
follow recommended naming convention for files &lt;suite&gt;_kunit.c
and kconfig entries CONFIG_&lt;name&gt;_KUNIT_TEST.

Link: https://lore.kernel.org/all/CABVgOS=-vh5TqHFCq_jo=ffq8v_nGgr6JsPnOZag3e6+19ysxQ@mail.gmail.com/ [1]
Link: https://docs.kernel.org/dev-tools/kunit/style.html [2]

Signed-off-by: Luis Felipe Hernandez &lt;luis.hernandez093@gmail.com&gt;
Acked-by: Nicolas Pitre &lt;npitre@baylibre.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Rae Moar &lt;rmoar@google.com&gt;
Link: https://lore.kernel.org/r/20241202075545.3648096-2-davidgow@google.com
Signed-off-by: Kees Cook &lt;kees@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/math: add int_sqrt test suite</title>
<updated>2025-01-13T04:21:08Z</updated>
<author>
<name>Luis Felipe Hernandez</name>
<email>luis.hernandez093@gmail.com</email>
</author>
<published>2024-12-13T04:26:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0fafc9e1563fbacb92b19ccbde5b8e73280d34b7'/>
<id>urn:sha1:0fafc9e1563fbacb92b19ccbde5b8e73280d34b7</id>
<content type='text'>
Adds test suite for integer based square root function.

The test suite is designed to verify the correctness of the int_sqrt()
math library function.

Link: https://lkml.kernel.org/r/20241213042701.1037467-1-luis.hernandez093@gmail.com
Signed-off-by: Luis Felipe Hernandez &lt;luis.hernandez093@gmail.com&gt;
Reviewed-by: Kuan-Wei Chiu &lt;visitorckw@gmail.com&gt;
Cc: David Gow &lt;davidgow@google.com&gt;
Cc: Ricardo B. Marliere &lt;rbm@suse.com&gt;
Cc: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>lib/math/test_div64: add some edge cases relevant to __div64_const32()</title>
<updated>2024-10-28T21:44:28Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>npitre@baylibre.com</email>
</author>
<published>2024-10-03T21:16:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1dc82675cb79200d5e140520efd7ce88b38ea56d'/>
<id>urn:sha1:1dc82675cb79200d5e140520efd7ce88b38ea56d</id>
<content type='text'>
Be sure to test the extreme cases with and without bias.

Signed-off-by: Nicolas Pitre &lt;npitre@baylibre.com&gt;
Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
</content>
</entry>
<entry>
<title>Merge tag 'mm-nonmm-stable-2024-09-21-07-52' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm</title>
<updated>2024-09-21T15:20:50Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2024-09-21T15:20:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7856a565416e0cf091f825b0e25c7a1b7abb650e'/>
<id>urn:sha1:7856a565416e0cf091f825b0e25c7a1b7abb650e</id>
<content type='text'>
Pull non-MM updates from Andrew Morton:
 "Many singleton patches - please see the various changelogs for
  details.

  Quite a lot of nilfs2 work this time around.

  Notable patch series in this pull request are:

   - "mul_u64_u64_div_u64: new implementation" by Nicolas Pitre, with
     assistance from Uwe Kleine-König. Reimplement mul_u64_u64_div_u64()
     to provide (much) more accurate results. The current implementation
     was causing Uwe some issues in the PWM drivers.

   - "xz: Updates to license, filters, and compression options" from
     Lasse Collin. Miscellaneous maintenance and kinor feature work to
     the xz decompressor.

   - "Fix some GDB command error and add some GDB commands" from
     Kuan-Ying Lee. Fixes and enhancements to the gdb scripts.

   - "treewide: add missing MODULE_DESCRIPTION() macros" from Jeff
     Johnson. Adds lots of MODULE_DESCRIPTIONs, thus fixing lots of
     warnings about this.

   - "nilfs2: add support for some common ioctls" from Ryusuke Konishi.
     Adds various commonly-available ioctls to nilfs2.

   - "This series fixes a number of formatting issues in kernel doc
     comments" from Ryusuke Konishi does that.

   - "nilfs2: prevent unexpected ENOENT propagation" from Ryusuke
     Konishi. Fix issues where -ENOENT was being unintentionally and
     inappropriately returned to userspace.

   - "nilfs2: assorted cleanups" from Huang Xiaojia.

   - "nilfs2: fix potential issues with empty b-tree nodes" from Ryusuke
     Konishi fixes some issues which can occur on corrupted nilfs2
     filesystems.

   - "scripts/decode_stacktrace.sh: improve error reporting and
     usability" from Luca Ceresoli does those things"

* tag 'mm-nonmm-stable-2024-09-21-07-52' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (103 commits)
  list: test: increase coverage of list_test_list_replace*()
  list: test: fix tests for list_cut_position()
  proc: use __auto_type more
  treewide: correct the typo 'retun'
  ocfs2: cleanup return value and mlog in ocfs2_global_read_info()
  nilfs2: remove duplicate 'unlikely()' usage
  nilfs2: fix potential oob read in nilfs_btree_check_delete()
  nilfs2: determine empty node blocks as corrupted
  nilfs2: fix potential null-ptr-deref in nilfs_btree_insert()
  user_namespace: use kmemdup_array() instead of kmemdup() for multiple allocation
  tools/mm: rm thp_swap_allocator_test when make clean
  squashfs: fix percpu address space issues in decompressor_multi_percpu.c
  lib: glob.c: added null check for character class
  nilfs2: refactor nilfs_segctor_thread()
  nilfs2: use kthread_create and kthread_stop for the log writer thread
  nilfs2: remove sc_timer_task
  nilfs2: do not repair reserved inode bitmap in nilfs_new_inode()
  nilfs2: eliminate the shared counter and spinlock for i_generation
  nilfs2: separate inode type information from i_state field
  nilfs2: use the BITS_PER_LONG macro
  ...
</content>
</entry>
<entry>
<title>lib/math: Add int_pow test suite</title>
<updated>2024-09-12T16:03:00Z</updated>
<author>
<name>Luis Felipe Hernandez</name>
<email>luis.hernandez093@gmail.com</email>
</author>
<published>2024-09-10T01:10:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7fcc9b53216cd87f73cc6dbb404220350ddc93b8'/>
<id>urn:sha1:7fcc9b53216cd87f73cc6dbb404220350ddc93b8</id>
<content type='text'>
Adds test suite for integer based power function which performs integer
exponentiation.

The test suite is designed to verify that the implementation of int_pow
correctly computes the power of a given base raised to a given exponent.

The tests check various scenarios and edge cases to ensure the accuracy
and reliability of the exponentiation function.

Updated commit with test information at commit time: Shuah Khan

Signed-off-by: Luis Felipe Hernandez &lt;luis.hernandez093@gmail.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>mul_u64_u64_div_u64: basic sanity test</title>
<updated>2024-09-02T03:43:22Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>npitre@baylibre.com</email>
</author>
<published>2024-07-07T19:05:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1635e62e75a7bbb1c6274f6b43911cedfe0da60a'/>
<id>urn:sha1:1635e62e75a7bbb1c6274f6b43911cedfe0da60a</id>
<content type='text'>
Verify that edge cases produce proper results, and some more.

[npitre@baylibre.com: avoid undefined shift value]
  Link: https://lkml.kernel.org/r/7rrs9pn1-n266-3013-9q6n-1osp8r8s0rrn@syhkavp.arg
Link: https://lkml.kernel.org/r/20240707190648.1982714-3-nico@fluxnic.net
Signed-off-by: Nicolas Pitre &lt;npitre@baylibre.com&gt;
Reviewed-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Cc: Biju Das &lt;biju.das.jz@bp.renesas.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mul_u64_u64_div_u64: make it precise always</title>
<updated>2024-09-02T03:43:22Z</updated>
<author>
<name>Nicolas Pitre</name>
<email>npitre@baylibre.com</email>
</author>
<published>2024-07-07T19:05:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b29a62d87cc0af3e9d134e9e0863b2cb053070b8'/>
<id>urn:sha1:b29a62d87cc0af3e9d134e9e0863b2cb053070b8</id>
<content type='text'>
Patch series "mul_u64_u64_div_u64: new implementation", v3.

This provides an implementation for mul_u64_u64_div_u64() that always
produces exact results.


This patch (of 2):

Library facilities must always return exact results.  If the caller may be
contented with approximations then it should do the approximation on its
own.

In this particular case the comment in the code says "the algorithm
... below might lose some precision". Well, if you try it with e.g.:

	a = 18446462598732840960
	b = 18446462598732840960
	c = 18446462598732840961

then the produced answer is 0 whereas the exact answer should be
18446462598732840959.  This is _some_ precision lost indeed!

Let's reimplement this function so it always produces the exact result
regardless of its inputs while preserving existing fast paths when
possible.

Uwe said:

: My personal interest is to get the calculations in pwm drivers right. 
: This function is used in several drivers below drivers/pwm/ .  With the
: errors in mul_u64_u64_div_u64(), pwm consumers might not get the
: settings they request.  Although I have to admit that I'm not aware it
: breaks real use cases (because typically the periods used are too short
: to make the involved multiplications overflow), but I pretty sure am
: not aware of all usages and it breaks testing.
: 
: Another justification is commits like
: https://git.kernel.org/tip/77baa5bafcbe1b2a15ef9c37232c21279c95481c,
: where people start to work around the precision shortcomings of
: mul_u64_u64_div_u64().

Link: https://lkml.kernel.org/r/20240707190648.1982714-1-nico@fluxnic.net
Link: https://lkml.kernel.org/r/20240707190648.1982714-2-nico@fluxnic.net
Signed-off-by: Nicolas Pitre &lt;npitre@baylibre.com&gt;
Tested-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Reviewed-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Tested-by: Biju Das &lt;biju.das.jz@bp.renesas.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
</feed>
