This patch introduces static key technique and adds a kernel module
to demostrate how to use static key to optimize an almost unlikely
branch, the module can interact with userspace thru a character device.
Signed-off-by: Peter Lin <peterlin@qilai.dev>
Since the commit b8780c363d80 ("sched: remove sleep_on() and friends
"), the description about sleep_on is incorrect and the example code has
been fixed by replacing it with wait_event family. Let's also fix the
description to match the corrected code.
Since v5.17-rc1, particularly after the commit cead1855266 ("exit:
Rename complete_and_exit to kthread_complete_and_exit"),
complete_and_exit() is renamed to kthread_complete_and_exit().
Close#188
The rule of thumb is to include the headers we are the direct user of.
In particular, if we need an atomic API, we include <linux/atomic.h>.
On the other hand we should not use headers for no reason. In particular,
if we are not doing any IRQ job, why is the <linux/irq.h> included?
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
platform_driver_register() macro already does the correct assignment for
the owner of the driver.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Since sys_open is deprecated and some architectures don't support it.
We switch the implementation to sys_openat.
Moreover, in some architectures like x86-64, the prototype of syscall,
for example, openat(), might have been changed to struct pt_regs [1]
but we cannot promise that so support the two types
(sys_openat and pt_regs).
Also, to prevent other untraced tasks print out the information, add
the uid checking in our_sys_openat().
[1] https://lore.kernel.org/lkml/20180405095307.3730-1-linux@dominikbrodowski.net/Close#159
It failed silently when crypto_alloc_tfm() failed, so add an error
message to inform the developer to enable sha256 algorithm support.
Signed-off-by: Yu Chien Peter Lin <peterlin.tw@pm.me>
To make sure the behavior of the read and write operations are correct
with offset, update it each time. Also, since it is using the offset,
modify the part of read for removing unnecessary variable.
Currently, the description of the proc_ops in the file operation section
will confuse the reader with registering the device. Add more hints to
avoid it.
Since The length of the message buffer is BUF_LEN. When writing the
BUF_LEN length of the string it will overwrite the last character
(usually it is '\0' from the initialization). And, because the read
operation uses the character in the message buffer ('\0') to stop the
read loop. It will cause the read operation will read out of the
message buffer when the length parameter of read() is not lower than
or equal to BUF_LEN. So add one more byte space to avoid this problem.