kernel

https://ja.wikipedia.org/wiki/CentOS

https://ubuntu.com/security/livepatch/docs/livepatch/reference/kernels

# module param

```sh
tokunori@tokunori-desktop:~/linux$ ls /sys/module/nvme/parameters/
io_queue_depth  max_host_mem_size_mb  noacpi  poll_queues  sgl_threshold  use_cmb_sqes  use_threaded_interrupts  write_queues
tokunori@tokunori-desktop:~/linux$ cat /sys/module/nvme/parameters/sgl_threshold 
32768
tokunori@tokunori-desktop:~/linux$ ls -la /sys/module/nvme/parameters/sgl_threshold 
-rw-r--r-- 1 root root 4096  4月  7 21:56 /sys/module/nvme/parameters/sgl_threshold
tokunori@tokunori-desktop:~/linux$ ls /sys/module/nvme_core/parameters/
admin_timeout                apst_primary_timeout_ms        apst_secondary_timeout_ms  force_apst  iopolicy     multipath
apst_primary_latency_tol_us  apst_secondary_latency_tol_us  default_ps_max_latency_us  io_timeout  max_retries  shutdown_timeout
tokunori@tokunori-desktop:~/linux$ cat /sys/module/nvme_core/parameters/
admin_timeout                  apst_primary_timeout_ms        apst_secondary_timeout_ms      force_apst                     iopolicy                       multipath                      
apst_primary_latency_tol_us    apst_secondary_latency_tol_us  default_ps_max_latency_us      io_timeout                     max_retries                    shutdown_timeout               
tokunori@tokunori-desktop:~/linux$ ls -la /sys/module/nvme_core/parameters/io_timeout 
-rw-r--r-- 1 root root 4096  4月  7 21:57 /sys/module/nvme_core/parameters/io_timeout
tokunori@tokunori-desktop:~/linux$ cat /sys/module/nvme_core/parameters/io_timeout 
30
tokunori@tokunori-desktop:~/linux$ ls /sys/module/nvme_fabrics/
coresize    holders/    initsize    initstate   notes/      refcnt      sections/   srcversion  taint       uevent      
```

# link

https://www.kernel.org/

https://github.com/torvalds/linux

https://elixir.bootlin.com/linux/latest/source

# macro

## GENMASK

```c

include/uapi/linux/bits.h

#define __GENMASK(h, l) \
        (((~_UL(0)) - (_UL(1) << (l)) + 1) & \
         (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))

include/bits.h

#define GENMASK(h, l) \
	(GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))

include/linux/nvme.h:   NVME_CMD_EFFECTS_CSE_MASK       = GENMASK(18, 16),
```

## BIT_MASK

```c
include/asm-generic/bitsperlong.h

#ifdef CONFIG_64BIT
#define BITS_PER_LONG 64
#else
#define BITS_PER_LONG 32
#endif /* CONFIG_64BIT */

include/bits.h

#define BIT_MASK(nr)		(UL(1) << ((nr) % BITS_PER_LONG))
```

## kelvin_to_millicelsius, millicelsius_to_kelvin

```c
include/linux/units.h

#define ABSOLUTE_ZERO_MILLICELSIUS -273150

static inline long milli_kelvin_to_millicelsius(long t)
{
	return t + ABSOLUTE_ZERO_MILLICELSIUS;
}

static inline long millicelsius_to_milli_kelvin(long t)
{
	return t - ABSOLUTE_ZERO_MILLICELSIUS;
}

#define MILLIDEGREE_PER_DEGREE 1000

static inline long kelvin_to_millicelsius(long t)
{
	return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DEGREE);
}

static inline long millicelsius_to_kelvin(long t)
{
	t = millicelsius_to_milli_kelvin(t);

	return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
}
```

## FIELD_GET

```c
include/linux/bitfield.h

/**
 * FIELD_GET() - extract a bitfield element
 * @_mask: shifted mask defining the field's length and position
 * @_reg:  value of entire bitfield
 *
 * FIELD_GET() extracts the field specified by @_mask from the
 * bitfield passed in as @_reg by masking and shifting it down.
 */
#define FIELD_GET(_mask, _reg)						\
	({								\
		__BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: ");	\
		(typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask));	\
	})
```