Try   HackMD

linux2021: adamtsai

測驗 α-1

Linux kernel bit rotation operation source:
include/linux/bitops.h: roll*, rolr*

TODO: Illustrate the use cases inside the Linux kernel.

Bit rotation or whatever any of bitwise operation are very essential
operations. You can find there are lots of usage in hashcode like SHA,
checksum, etc.

測驗 α-2

may be, cause there are some discussion in gcc mailing list about the optimization for common constructs of bit operation.
FYI, https://gcc.gnu.org/legacy-ml/gcc-patches/2007-11/msg01112.html

TODO: analyze the IR generated by GCC and see if the optimizer really works as expected.

測驗 β-1

For power of 2 cases, alignment can be done with bit clear simply.
It is a trivial problem.

Can you write an efficient implementation which deals with any sizes of alignments?

測驗 β-2

There are various power of 2 round up/down macros in Linux kernel.

They are used in lots of places. For what I most familier with, block layer or filesytem use them to calculate the maximum size of data they can handle at a time.