Project

General

Profile

Actions

Bug #14678

closed

bitmap functions could be more const

Added by Patrick Mooney about 2 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
kernel
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

The kernel bitmap functions (from uts/common/os/bitmap.c) could specify const for their arguments were the ulong_t bitmap will not undergo modification.

Actions #1

Updated by Electric Monk about 2 months ago

  • Gerrit CR set to 2139
Actions #2

Updated by Patrick Mooney about 2 months ago

This should result in effectively no change in behavior or text, and so should be testable via wsdiff

Actions #3

Updated by Dan McDonald about 2 months ago

Patrick Mooney wrote in #note-2:

This should result in effectively no change in behavior or text, and so should be testable via wsdiff

IIRC sometimes const-ifying will allow callers to be less conservative about saving state. It looks like, however, your changed functions aren't calling OTHER changed functions, so wsdiff or diffs of dis(1) output should confirm no-real-change.

Actions #4

Updated by Patrick Mooney about 2 months ago

Tested with wsdiff(1), and the only differences in the kernel text (besides the normal ACPI noise) were the git SHA and the CTF for the changed functions:

platform/i86pc/kernel/amd64/unix
NOTE: ELF .data difference detected.

10398,10401c10398,10401
< 0706520  \0  \0  \0  \0  \0  \0  \0   m   a   s   t   e   r   -   0   -
<         00000000 6d000000 65747361 2d302d72
< 0706540   g   9   5   1   4   a   b   4   4   6   5  \0  \0  \0  \0  \0
<         31353967 34626134 00353634 00000000
---
> 0706520  \0  \0  \0  \0  \0  \0  \0   i   l   1   4   6   7   8   -   0
>         00000000 69000000 3634316c 302d3837
> 0706540   -   g   f   b   0   1   e   5   0   4   7   c  \0  \0  \0  \0
>         6266672d 35653130 63373430 00000000

platform/i86xpv/kernel/amd64/unix
NOTE: ELF .data difference detected.

8640,8643c8640,8643
< 1105220  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0   m   a   s   t   e
<         00000000 00000000 6d000000 65747361
< 1105240   r   -   0   -   g   9   5   1   4   a   b   4   4   6   5  \0
<         2d302d72 31353967 34626134 00353634
---
> 1105220  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0   i   l   1   4   6
>         00000000 00000000 69000000 3634316c
> 1105240   7   8   -   0   -   g   f   b   0   1   e   5   0   4   7   c
>         302d3837 6266672d 35653130 63373430

kernel/amd64/genunix
NOTE: ELF .SUNW_ctf difference detected.

42900a42901,42902
> typedef au_buff_t token_t;
>
42921,42922d42922
< typedef au_buff_t token_t;
<
46858,46862c46858,46862
< extern index_t bt_availbit(ulong_t *, size_t);
< extern void bt_copy(ulong_t *, ulong_t *, ulong_t);
< extern int bt_gethighbit(ulong_t *, int);
< extern int bt_getlowbit(ulong_t *, size_t, size_t);
< extern int bt_range(ulong_t *, size_t *, size_t *, size_t);
---
> extern index_t bt_availbit(const ulong_t *, size_t);
> extern void bt_copy(const ulong_t *, ulong_t *, ulong_t);
> extern int bt_gethighbit(const ulong_t *, int);
> extern int bt_getlowbit(const ulong_t *, size_t, size_t);
> extern int bt_range(const ulong_t *, size_t *, size_t *, size_t);

Actions #5

Updated by Patrick Mooney about 2 months ago

For a sanity smoke-test, I also booted up a BE running these bits and dtraced the bitmap functions to see that they were being called. The shipped header showed the const versions in place.

Actions #6

Updated by Electric Monk about 2 months ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit badf94ff3599fab15963f6c532929e9bc411757a

commit  badf94ff3599fab15963f6c532929e9bc411757a
Author: Patrick Mooney <pmooney@pfmooney.com>
Date:   2022-05-09T21:15:08.000Z

    14678 bitmap functions could be more const
    Reviewed by: Yuri Pankov <ypankov@tintri.com>
    Reviewed by: Dan McDonald <danmcd@mnx.io>
    Approved by: Richard Lowe <richlowe@richlowe.net>

Actions

Also available in: Atom PDF